diff --git a/scripts/delayed.js b/scripts/delayed.js index 0fd4c47c..34236d8b 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -568,9 +568,7 @@ export function initGigya() { if (userButton) userButton.replaceWith(userButton.cloneNode(true)); const favoriteButtons = document.querySelectorAll('.leaderboard-favorite-button'); if (favoriteButtons) favoriteButtons.forEach((btn) => btn.replaceWith(btn.cloneNode(true))); - loadScript( - 'https://cdns.gigya.com/JS/socialize.js?apikey=3__4H034SWkmoUfkZ_ikv8tqNIaTA0UIwoX5rsEk96Ebk5vkojWtKRZixx60tZZdob', - setupGigya, + loadScript('https://cdns.gigya.com/JS/socialize.js?apikey=3__4H034SWkmoUfkZ_ikv8tqNIaTA0UIwoX5rsEk96Ebk5vkojWtKRZixx60tZZdob', setupGigya, ); } @@ -660,7 +658,8 @@ function getCookie(cookieName) { return null; } -async function OptanonWrapper() { +const OptanonWrapper = (async function() { + console.log('test'); const geoInfo = window.Optanon.getGeolocationData(); Object.keys(geoInfo).forEach((key) => { const cookieName = `PGAT_${key.charAt(0).toUpperCase() + key.slice(1)}`; @@ -681,7 +680,7 @@ async function OptanonWrapper() { } } sendAnalyticsPageEvent(); -} +}) export const loadAds = (function() { const otId = placeholders.onetrustId; diff --git a/scripts/scripts.js b/scripts/scripts.js index dd6f011e..832fa1be 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -715,8 +715,6 @@ async function loadPage(doc) { // eslint-disable-next-line no-use-before-define await loadLazy(doc); // eslint-disable-next-line no-use-before-define - loadAds(); - // eslint-disable-next-line no-use-before-define loadDelayed(doc); } @@ -1076,6 +1074,7 @@ async function loadLazy(doc) { addFavIcon(`${window.hlx.codeBasePath}/styles/favicon.ico`); doc.querySelectorAll('div:not([class]):not([id]):empty').forEach((empty) => empty.remove()); + loadAds(); } /** @@ -1140,20 +1139,6 @@ function getPageNameAndSections() { }; } -/* setup cookie preferences */ -function getCookie(cookieName) { - const name = `${cookieName}=`; - const decodedCookie = decodeURIComponent(document.cookie); - const split = decodedCookie.split(';'); - // eslint-disable-next-line no-plusplus - for (let i = 0; i < split.length; i++) { - let c = split[i]; - while (c.charAt(0) === ' ') c = c.substring(1); - if (c.indexOf(name) === 0) return c.substring(name.length, c.length); - } - return null; -} - export async function sendAnalyticsPageEvent() { window.dataLayer = window.dataLayer || []; const dl = window.dataLayer;