Reimagine the badge

Trac 27385
This commit is contained in:
Arlo Breault 2019-07-14 09:41:51 +02:00 committed by Cecylia Bocovich
parent 0bded511b9
commit e60f22833a
29 changed files with 401 additions and 351 deletions

View file

@ -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;
}
}