window.addEventListener('message', function(event) { if (window.handled || (window.location.href.indexOf('asgfp') >= 0)) { return; } if (event.data[0] === 'asgfp') { window.handled = true; var fp = event.data[1]; var cookieDate = new Date; cookieDate.setFullYear(cookieDate.getFullYear() + 1); var cookieString = 'asgfp=' + fp + '; expires=' + cookieDate.toUTCString() + '; path=/; SameSite=None; Secure=true' document.cookie = cookieString; if (document.cookie.indexOf('asgfp=' + fp) < 0) { var url = window.location.protocol + '//' + window.location.hostname + '/api/is_potential_advert?asgfp=' + fp; var handleResponse = function(resp) { resp.json().then(function(json) { if (json.result === true) { var newUrl = new URL(window.location.href); newUrl.searchParams.append('asgfp', fp); window.location.replace(newUrl); } }) }; // IE11 polyfill var testGlobal = (typeof globalThis !== 'undefined' && globalThis) || (typeof self !== 'undefined' && self) || (typeof global !== 'undefined' && global) if (!testGlobal.fetch) { var promiseScript = document.createElement("script"); promiseScript.type = "text/javascript"; promiseScript.src = "https://cdn.jsdelivr.net/npm/promise-polyfill@8.1.3/dist/polyfill.min.js"; var fetchScript = document.createElement("script"); fetchScript.type = "text/javascript"; fetchScript.src = "https://cdn.jsdelivr.net/npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js"; document.head.appendChild(promiseScript); document.head.appendChild(fetchScript); setTimeout(function () { window.fetch(url).then(handleResponse).catch(console.error); }, 1000); } else { fetch(url).then(handleResponse).catch(console.error); } } } });