Skip to content

Instantly share code, notes, and snippets.

@bcaudan
Last active June 13, 2016 16:28
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 bcaudan/bfab026fa2416af9fc48dfacc4a59938 to your computer and use it in GitHub Desktop.
Save bcaudan/bfab026fa2416af9fc48dfacc4a59938 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
Math.random(); // jquery
if (Math.random() > 0.1) {
// excluded
log('');
} else {
// choose version
var totalPercentage = 100;
var versionsMatched = [1785, 1786, 1787, 1788];
var random = Math.random() * totalPercentage,
threshold = 0,
version = null;
for (var i = 0; i < versionsMatched.length; i++) {
var versionMatched = versionsMatched[i];
threshold += 25;
if (random <= threshold) {
version = versionMatched;
break;
}
}
log('?uxt=' + JSON.stringify([[977, version]]));
}
function log(params) {
var image = new Image(1, 1),
imgsrc = 'https://t.content-square.net/log' + params;
image.src = imgsrc;
image.onerror = function () {
document.body.innerHTML = '<h1 id="log">After log</h1>'
};
}
</script>
</head>
<h1>Before log</h1>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment