Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@allex
Last active February 19, 2019 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allex/94ce5362059940e9a9f24369eba8e512 to your computer and use it in GitHub Desktop.
Save allex/94ce5362059940e9a9f24369eba8e512 to your computer and use it in GitHub Desktop.
// GistID: 94ce5362059940e9a9f24369eba8e512 (https://git.io/fhdGF)
var isP2PEnable = (function(scaleName, scale) {
var setc = function(e, t, i, o) {
var a = e + "=" + escape(t), n = new Date();
n.setTime(n.getTime() + 60 * i * 60 * 1e3), o && (a += ";path=/ ; domain=" + (o || '')),
document.cookie = a + "; expires=" + n.toGMTString();
};
var getc = function(e) {
var o = new RegExp("(?:^|;+|\\s+)" + e + "=([^;]*)"), c = document.cookie.match(o);
return c ? c[1] : "";
};
var __random_seed = getc(scaleName) || Math.random();
var flg = __random_seed < scale;
setc(scaleName, __random_seed, 24 * 365 * 3, '.' + document.domain.split('.').slice(-2).join('.'));
return flg
})('__random_seed_p2p_v2', 0.2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment