//Script generado para enfoco.com.br (() => { const REFRESH_TIMEOUT = 30000; const BrowserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; const isMobile = BrowserWidth <= 768; const productsData = [{"slot":"/22562061343/0223_01_enfoco-com-br_inline__","tagId":"embi_display_video_49a17f35","type":"DISPLAY_VIDEO","ubication":"body > section.efo-article-container > section > article > section > figure > figcaption","position":"INSERT_AFTER","manualInsertion":false,"mobileSizes":[[300,250],[336,280],[300,600],[320,480],[320,100],[320,50]],"desktopSizes":[[300,250],[336,280],[300,600],[320,480],[970,250],[970,90],[728,90]],"offset":20,"adunitMobile":{"code":"embi_display_video_49a17f35","mediaTypes":{"video":{"context":"outstream","playerSize":[300,250],"mimes":["video/mp4"],"protocols":[1,2,3,4,5,6,7,8],"playbackmethod":[2],"skip":1,"playback_method":["auto_play_sound_off"]},"banner":{"sizes":[[300,250],[336,280],[300,600],[320,480],[320,100],[320,50]]}},"bids":[],"ortb2Imp":{"ext":{"gpid":"/22562061343/0223_01_enfoco-com-br_inline__","data":{"pbadslot":"/22562061343/0223_01_enfoco-com-br_inline__"}}}},"adunitDesktop":{"code":"embi_display_video_49a17f35","mediaTypes":{"video":{"context":"outstream","playerSize":[300,250],"mimes":["video/mp4"],"protocols":[1,2,3,4,5,6,7,8],"playbackmethod":[2],"skip":1,"playback_method":["auto_play_sound_off"]},"banner":{"sizes":[[300,250],[336,280],[300,600],[320,480],[970,250],[970,90],[728,90]]}},"bids":[],"ortb2Imp":{"ext":{"gpid":"/22562061343/0223_01_enfoco-com-br_inline__","data":{"pbadslot":"/22562061343/0223_01_enfoco-com-br_inline__"}}}}}]; function loadScript(path, goAsync) { if (!document.querySelector(`script[src='${path}']`)) { const script = document.createElement("script"); script.async = goAsync; script.type = "text/javascript"; script.src = path; document.head.appendChild(script); } } loadScript("https://securepubads.g.doubleclick.net/tag/js/gpt.js", false); var googletag = window.googletag || (window.googletag = { cmd: [] }); googletag.cmd.push(function () { productsData.forEach((product) => { const adUnitSizes = isMobile ? product.mobileSizes : product.desktopSizes; product.adSlot = googletag .defineSlot(product.slot, adUnitSizes, product.tagId) .setForceSafeFrame(true) .addService(googletag.pubads()); if(product.type === 'DOUBLE_BOX'){ product.adSlotB = googletag .defineSlot(product.slot2, adUnitSizes, product.tagId2) .setForceSafeFrame(true) .addService(googletag.pubads()); } }); googletag.pubads().enableSingleRequest(); googletag.pubads().enableLazyLoad({ fetchMarginPercent: 200, renderMarginPercent: 100, mobileScaling: 1.0, }); googletag.pubads().collapseEmptyDivs(true); googletag.pubads().setCentering(true); googletag.pubads().addEventListener("slotRenderEnded", function (event) { const renderedSlotId = event.slot.getSlotElementId(); productsData.forEach((product) => { if (renderedSlotId === product.tagId && !event.isEmpty) { if (product.type === 'DISPLAY_VIDEO_STICKY') { showCornerAd(cornerContainer); console.info( "Ad rendered in slot:", event.slot.getSlotElementId(), event ); } if (product.type === 'FOOTER_INTOP') { showFooterInTopAd(footerInTopContainer); } } }); }); googletag.enableServices(); }); function styleContainer(container) { container.style.display = "flex"; container.style.gap = "24px"; container.style.marginBottom = "24px" container.style.background = "transparent"; container.style.justifyContent = "center" } function renderAdunit(product) { if (product.manualInsertion) { const adUnitId = product.tagId; const observer = new MutationObserver((mutations, obs) => { const targetElement = document.getElementById(adUnitId); if (targetElement) { googletag.cmd.push(function () { googletag.display(adUnitId); }); obs.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true, }); } else { const type = product.type; const position = product.position; const ubication = product.ubication; const adUnitId = product.tagId; const bottom = product.offset; try { if (type === "HIGH_IMPACT") { createInterstitialContainer(adUnitId); } else if (type === "DISPLAY_VIDEO_STICKY") { cornerContainer = createCornerContainer(adUnitId, position, bottom); } else if (type === 'FOOTER_INTOP') { footerInTopContainer = createfooterInTopContainer(adUnitId, position); } else if (type === "DOUBLE_BOX") { const targetElement = document.querySelector(`${ubication}`); if (!targetElement) { console.error( `Elemento con clase '${ubication}' no encontrado en el DOM para el anuncio ${adUnitId}. No se pudo insertar el DIV.` ); return false; } const adUnitIdB = product.tagId2; const adsContainer = document.createElement("div"); adsContainer.id = `container_${adUnitId}`; styleContainer(adsContainer); const adDiv = document.createElement("div"); adDiv.id = adUnitId; adsContainer.appendChild(adDiv); const adScript = document.createElement("script"); adScript.textContent = ` googletag.cmd.push(function() { googletag.display('${adUnitId}'); }); `; adDiv.appendChild(adScript); const adDivB = document.createElement("div"); adDivB.id = adUnitIdB; adsContainer.appendChild(adDivB); const adScriptB = document.createElement("script"); adScriptB.textContent = ` googletag.cmd.push(function() { googletag.display('${adUnitIdB}'); }); `; adDivB.appendChild(adScript); if (position === "INSERT_BEFORE" && targetElement.parentNode) { targetElement.parentNode.insertBefore(adsContainer, targetElement); } else { targetElement.appendChild(adsContainer); } } else { const targetElement = document.querySelector(`${ubication}`); if (!targetElement) { console.error( `Elemento con clase '.${ubication}' no encontrado en el DOM para el anuncio ${adUnitId}.` ); return; } const adDiv = document.createElement('div'); adDiv.id = adUnitId; adDiv.style.marginBottom = '24px'; const adScript = document.createElement("script"); adScript.textContent = ` googletag.cmd.push(function() { googletag.display('${adUnitId}'); }); `; adDiv.appendChild(adScript); if (position === "INSERT_BEFORE") { targetElement.insertAdjacentElement("beforebegin", adDiv); } else if (position === "INSERT_AFTER") { targetElement.insertAdjacentElement("afterend", adDiv); } else { targetElement.appendChild(adDiv); } } setInterval(function () { if (product.adSlot) { googletag.pubads().refresh([product.adSlot]); } if (product.adSlotB) { googletag.pubads().refresh([product.adSlotB]); } }, REFRESH_TIMEOUT); } catch (e) { console.error(`Error procesando el anuncio ${adUnitId}:`, e); } } } document.addEventListener("DOMContentLoaded", function () { productsData.map((product) => { renderAdunit(product); }); }); })();