mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Reimagine the badge
Trac 27385
This commit is contained in:
parent
0bded511b9
commit
e60f22833a
29 changed files with 401 additions and 351 deletions
|
@ -10,31 +10,21 @@ Contains helpers for parsing query strings and other utilities.
|
|||
class Util {
|
||||
|
||||
static mightBeTBB() {
|
||||
return Util.TBB_UAS.indexOf(window.navigator.userAgent) > -1 && (window.navigator.mimeTypes && window.navigator.mimeTypes.length === 0);
|
||||
return Util.TBB_UAS.indexOf(window.navigator.userAgent) > -1 && (
|
||||
window.navigator.mimeTypes && window.navigator.mimeTypes.length === 0
|
||||
);
|
||||
}
|
||||
|
||||
static genSnowflakeID() {
|
||||
return Math.random().toString(36).substring(2);
|
||||
}
|
||||
|
||||
static snowflakeIsDisabled(cookieName) {
|
||||
var cookies;
|
||||
cookies = Parse.cookie(document.cookie);
|
||||
// Do nothing if snowflake has not been opted in by user.
|
||||
if (cookies[cookieName] !== '1') {
|
||||
log('Not opted-in. Please click the badge to change options.');
|
||||
return true;
|
||||
}
|
||||
// Also do nothing if running in Tor Browser.
|
||||
if (Util.mightBeTBB()) {
|
||||
log('Will not run within Tor Browser.');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
static hasWebRTC() {
|
||||
return typeof PeerConnection === 'function';
|
||||
}
|
||||
|
||||
static featureDetect() {
|
||||
return typeof PeerConnection === 'function';
|
||||
static hasCookies() {
|
||||
return navigator.cookieEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue