//Script generado para unoentrerios.com.ar (() => { const REFRESH_TIMEOUT = 15000; const BrowserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; const isMobile = BrowserWidth <= 768; const productsData = [{"slot":"/22562061343/0435-02_unoentrerios_corner_NC","tagId":"embi_display_video_sticky_ad7fa17d","type":"DISPLAY_VIDEO_STICKY","ubication":"","position":"RIGHT_SIDE","manualInsertion":false,"mobileSizes":[[320,100],[320,50]],"desktopSizes":[[300,250],[336,280]],"adunitMobile":{"code":"embi_display_video_sticky_ad7fa17d","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":[[320,100],[320,50]]}},"bids":[],"ortb2Imp":{"ext":{"gpid":"/22562061343/0435-02_unoentrerios_corner_NC","data":{"pbadslot":"/22562061343/0435-02_unoentrerios_corner_NC"}}}},"adunitDesktop":{"code":"embi_display_video_sticky_ad7fa17d","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]]}},"bids":[],"ortb2Imp":{"ext":{"gpid":"/22562061343/0435-02_unoentrerios_corner_NC","data":{"pbadslot":"/22562061343/0435-02_unoentrerios_corner_NC"}}}}}]; 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()); }); 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); console.info( "Ad rendered in slot:", event.slot.getSlotElementId(), event ); } } }); }); googletag.enableServices(); }); let cornerContainer; function styleStickyContainer(container, position) { container.style.position = "fixed"; container.style.bottom = "128px"; container.style.left = position === "LEFT_SIDE" ? "24px" : "auto"; container.style.right = position === "RIGHT_SIDE" ? "24px" : "auto"; container.style.zIndex = "2147483647"; container.style.background = "transparent"; container.style.boxShadow = "black 0 3px 10px 0"; container.style.display = "none"; container.style.transition = "bottom 0.3s ease-in-out"; } function createStickyCloseButton(container) { const closeButton = document.createElement("div"); closeButton.textContent = "×"; Object.assign(closeButton.style, { position: "absolute", right: "0", top: "0", border: "none", background: "white", fontSize: "16px", lineHeight: "16px", width: "18px", height: "18px", cursor: "pointer", boxShadow: "black 0 2px 4px 0", borderRadius: "50%", transform: "translate(50%, -50%)", display: "flex", justifyContent: "center", alignItems: "center", }); closeButton.onclick = () => { container.style.display = "none"; }; return closeButton; } function createCornerContainer(adUnitId, position = "RIGHT_SIDE") { const container = document.createElement("div"); container.id = "embi-corner-ad-container"; styleStickyContainer(container, position); const adDiv = document.createElement("div"); adDiv.id = adUnitId; const adScript = document.createElement("script"); adScript.textContent = ` googletag.cmd.push(function() { googletag.display('${adUnitId}'); }); `; adDiv.appendChild(adScript); container.appendChild(adDiv); container.appendChild(createStickyCloseButton(container)); document.body.appendChild(container); return container; } function showCornerAd(container) { if (container) { container.style.display = "block"; } } function renderAdunit(product) { if (product.manualInsertion) { const adUnitId = product.tagId; const targetElement = document.getElementById(adUnitId); if (targetElement) { googletag.cmd.push(function () { googletag.display(adUnitId); }); } } else { const type = product.type; const position = product.position; const ubication = product.ubication; const adUnitId = product.tagId; try { if (type === "HIGH_IMPACT") { createInterstitialContainer(adUnitId); } else if (type === "DISPLAY_VIDEO_STICKY") { cornerContainer = createCornerContainer(adUnitId, position); } else if (type === 'FOOTER_INTOP') { footerInTopContainer = createfooterInTopContainer(adUnitId, position); } 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]); } }, REFRESH_TIMEOUT); } catch (e) { console.error(`Error procesando el anuncio ${adUnitId}:`, e); } } } document.addEventListener("DOMContentLoaded", function () { productsData.map((product) => { renderAdunit(product); }); }); })();