Skip to content

Instantly share code, notes, and snippets.

@abhisheksliam
Created December 30, 2020 04:13
Show Gist options
  • Save abhisheksliam/8a5bf707d3e8240c71c68e791698635c to your computer and use it in GitHub Desktop.
Save abhisheksliam/8a5bf707d3e8240c71c68e791698635c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script>
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function setCookie(key, value) {
var _cookie = key + "=" + value + "; path=/;SameSite=None;secure";
var _date = new Date();
_date.setTime(_date.getTime() + (2 * 365 * 24 * 60 * 60 * 1000));
_cookie += "; expires=" + _date.toGMTString();
document.cookie = _cookie;
return value;
}
function checkAndSet(name) {
var cookieArr = document.cookie.split(";");
for (var i = 0; i < cookieArr.length; i++) {
var cookiePair = cookieArr[i].split("=");
if (name == cookiePair[0].trim()) {
return decodeURIComponent(cookiePair[1]);
}
}
return setCookie(name, (uuidv4() + '-' + Math.round(Date.now() / 1000)));
}
window.parent.postMessage({
__tiluuid: checkAndSet('__tiluuid'),
reset : false,
__tiluuid_version_date: '1609300417784', // Wed Dec 30 2020
__tiluuid_frequency_days: '7',
__tiluuid_reset_script_path : '' // https://tilanalytics.timesinternet.in/frame_v4.min.js // to check if change cross domain local storage for reset dates??
}, '*');
</script>
</head>
<body></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment