<!-- --> !function (e, f, u) { e.async = 1; e.src = u; f.parentNode.insertBefore(e, f); }(document.createElement('script'), document.getElementsByTagName('script')[0], '//cdn.taboola.com/libtrc/adastapremium-assodigitale/loader.js'); /* if (!document.body.classList.contains('next-article-clistener-set')) { document.body.classList.add('next-article-clistener-set'); console.log('[ADASTA] Next article listener added'); // Carica gli slot iniziali /*document.querySelectorAll('.adastaAdv').forEach((slot) => { loadAds(true, slot.id); });*/ /* function waitForElement(selector, callback) { const el = document.querySelector(selector); if (el) { callback(el); } else { setTimeout(function() { waitForElement(selector, callback); }, 50); } } function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; } function uniqid() { var id = getRandomInt(0, Date.now()); return id; } waitForElement('.adastaAdv', () =>{loadAds()}); waitForElement('.cs-nextpost-inner', (el) => { const observer = new MutationObserver((mutation) => { const newLoadedSlots = []; mutation.forEach((mutationRecord) => { mutationRecord.addedNodes.forEach((node) => { node.querySelectorAll('.adastaAdv').forEach((slot) => { newLoadedSlots.push(slot); }); }); }); for (const slot of newLoadedSlots) { slot.id = uniqid(); loadAds(true, slot.id); } }); observer.observe(el, { childList: true }); }); }*/ /*document.addEventListener('DOMContentLoaded', function() { var elementsDiv = document.getElementsByClassName('adastaAdv'); for(i=0; i<elementsDiv.length; i++){ // elementsDiv[i].id = uniqid(); elementsDiv[i].classList.remove("adastaAdv"); }loadAds();debugger; }); document.addEventListener('scroll', function() { var elementsDiv = document.getElementsByClassName('adastaAdv'); //debugger; for(i=0; i<elementsDiv.length; i++){ var id = uniqid(); elementsDiv[i].id = id; loadAds(false, id); elementsDiv[i].classList.remove("adastaAdv"); } });*/ /* document.addEventListener('DOMContentLoaded', function() { const adsDivs = document.getElementsByClassName('adastaAdv'); for(let i = 0; i < adsDivs.length; i++){ if (!adsDivs[i].hasAttribute("data-ad-loaded")) { adsDivs[i].setAttribute("data-ad-loaded", "true"); const idAdToLoad = adsDivs[i].getAttribute("id"); loadAds(false, idAdToLoad); } } }); document.addEventListener('scroll', function() { const adsDivs = document.getElementsByClassName('adastaAdv'); for(let i = 0; i { if(!window.__tcfapi) { console.log("__tcfapi not loaded yet...") return; // Not loaded yet } // __tcfapi loaded clearInterval(intervalId); //Check if CPM API is available from here __tcfapi('addEventListener', 2, function(tcData, success) { const LOG_PREFIX = 'TCFAPI: '; console.debug("%saddEventListener", LOG_PREFIX, tcData); if (!success) { console.error("%sError in addEventListener", LOG_PREFIX); return; } switch (tcData.eventStatus) { case 'useractioncomplete': case 'tcloaded': { __tcfapi('removeEventListener', 2, function(success) { console.debug("%sremoveEventListener(%s):%s", LOG_PREFIX, tcData.listenerId, success); }, tcData.listenerId); if (success) { resolve(true) } else { resolve(null) console.error("%sCall to CMP failed", LOG_PREFIX); } break; } } }); }, 50) }); } function initTeads() { const Teads = document.createElement('script'); Teads.async = true; Teads.type = 'text/javascript'; Teads.src = 'https:' + '//a.teads.tv/page/207579/tag'; const node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(Teads, node); console.log("attivazione TEads"); } isCMPWaiting().then(function(cmpResponse) { console.log("TCF verifica consenso per TEads"); if (cmpResponse !== null) { initTeads(); } });