[]
24 Best-Dressed Celebrities of April 2023 “serviceWorker”in navigator&&navigator.serviceWorker.register(“/sw.js”).then(function(e){console.log(‘Service Worker registered’)}).catch(function(e){console.warn(“Service worker registration failed: “+e)})); ]]> ]]>
0) { // Full CCPA Opt Out on successful form submission win.Optanon.RejectAll(); win.removeEventListener(‘click’, win.cmpUtils.formCompletionHandler); } }, /** * Returns the OneTrust ‘OptanonAlertBoxClosed’ cookie value * * @returns {array} */ getAlertBoxCookieValue() { // Get the OptanonAlertBoxClosed Cookie return win.cmpUtils.getCookieMatch(‘OptanonAlertBoxClosed’); }, /** * Returns a regex match on the document.cookie object, capturing the value * https://regex101.com/r/yaCpvJ/1 * * @param {*} name * @returns {*} – value passed if matched */ getCookieMatch: (name) => doc.cookie.match(`[; ]*${name}=([^;]+)`), /** * Returns the CCPA Opt Out Value from the ‘usprivacy’ cookie if present * * @returns {boolean} */ getCCPAOptOut() { const usprivacy = win.cmpUtils.getCookieMatch(‘usprivacy’); win.cmpUtils.ccpaOptOut = !!(usprivacy && usprivacy[1].charAt(2) === ‘Y’); return win.cmpUtils.ccpaOptOut; }, /** * Gets the Consent Groups via ‘OptanonConsent’ cookie value * * @returns {object} – consent groups and partial consent */ getConsentGroups() { let partialConsent = false; // Check for consent via cookie value const onetrustCookieVal = win.cmpUtils.getCookieMatch(‘OptanonConsent’); let cmpConsentGroups = ”; if (onetrustCookieVal) { let groups = onetrustCookieVal[1].match(/groups=(.*?)(&|$)/); const interactionCount = onetrustCookieVal[1].match(/interactionCount=(.*?)(&|$)/); win.cmpUtils.log(‘cmpUtils – getConsentGroups’, ‘groups’, groups); win.cmpUtils.log(‘cmpUtils – getConsentGroups’, ‘interactionCount’, interactionCount); if (groups) { groups = decodeURIComponent(groups[1]).split(‘,’); groups.forEach(function handleGroup(group) { if (group.includes(‘:’)) { const gs = group.split(‘:’); if (gs[1] === ‘1’) { cmpConsentGroups += (cmpConsentGroups ? ‘,’ : ”) + gs[0]; // show partial consent only after initial interaction } else if (gs[1] === ‘0’ && interactionCount[1] > 0) { partialConsent = true; } } }); } } return { cmpConsentGroups, partialConsent }; }, /** * Retrieves any country overrides set at site.metadata * * @param {object} locale * @param {object} metadata * @returns {object} */ getGDPRCountryOverrides(adConfig = {}) { if (!adConfig) return {}; let userCountry = false; const { modules } = adConfig ?? {}; const oneTrustModule = modules?.oneTrust; const getCountryOverrides = (countrySent) => oneTrustModule?.countries?.[countrySent] || {}; // Assign the site’s country (takes precedence over user country) let finalCountry = siteCountry; let oneTrustOverrides = getCountryOverrides(siteCountry); // Check to see if the adConfig has country overrides for OneTrust // If it doesn’t check the user country from the location_data cookie if (oneTrustOverrides && Object.keys(oneTrustOverrides).length === 0) { userCountry = win.cmpUtils.getUserCountry(); oneTrustOverrides = getCountryOverrides(userCountry); if (oneTrustOverrides && Object.keys(oneTrustOverrides).length > 0) { finalCountry = userCountry; } } return { country: finalCountry, …oneTrustOverrides, …oneTrustModule?.countries, }; }, /** * Returns the Global Privacy Control (GPC) Value from the browser * * @returns {boolean} */ getGPCStatus() { return !!(navigator && navigator.globalPrivacyControl); }, /** * Gets the User’s location data from the Fastly set `location_data` cookie * * @returns {*} */ getLocationDataCookie() { const locationData = win.cmpUtils.getCookieMatch(‘location_data’); return locationData ? JSON.parse(locationData[1]) : ”; }, /** * Retrieves the user’s country code from the Fastly ‘location_data’ cookie * @returns {string} */ getUserCountry() { // Get location cookie set by Fastly const locationDataCookie = win.cmpUtils.getLocationDataCookie(); // Get country code from location cookie const { country_code: countryCode } = locationDataCookie; return countryCode ? countryCode.toLowerCase() : false; }, /** * Check if OneTrust Modal is present */ hasModal: () => !!doc.querySelector(‘#onetrust-banner-sdk’), /** * Logs when OneTrust script is loaded */ handleOtLoad(e) { win.cmpUtils.log(‘loadCmpScript’, ‘handleOtLoad – e’, e); }, /** * Loads the IAB CCPA Script */ loadIabCcpaScript() { const script = doc.createElement(‘script’); script.id = ‘ot-ccpa-iab-script’; script.src = ‘https://cdn.cookielaw.org/opt-out/otCCPAiab.js’; script.setAttribute(‘type’, ‘text/javascript’); script.setAttribute(‘charset’, ‘UTF-8’); script.setAttribute(‘ccpa-opt-out-ids’, [‘C0004’].join(‘,’)); script.setAttribute(‘ccpa-opt-out-geo’, ‘us’); script.setAttribute(‘ccpa-opt-out-lspa’, ‘false’); docBody.appendChild(script); win.cmpUtils.log(‘loadCmpScript – loadIabCcpaScript’, ‘script’, script); // After the script loads, fire the “consent.onetrust” event // until the uspData is available or timeout reached script.addEventListener( ‘load’, function handleLoad() { let intv = 0; const t = setInterval(function checkIntv() { // eslint-disable-next-line no-undef,no-unused-vars __uspapi(‘getUSPData’, 1, function checkUspData(uspData, success) { if (uspData.uspString !== null || intv === 50) { // Get Inital CCPA Opt Out win.CMP_CCPA_OPTOUT = win.cmpUtils.getCCPAOptOut(); win.cmpUtils.log( ‘loadCmpScript – loadIabCcpaScript’, ‘uspData.uspString’, uspData.uspString ); clearInterval(t); } }); intv += 1; }, 200); }, { once: true } ); }, /** * Keeps a log of the CMP events * * @param {*} name * @param {*} evt * @param {*} msg */ log(name, evt, msg) { const ts = Date.now() – win.cmpUtils.timerStart; win.cmpUtils.debug.push({ name, evt, msg, ts, }); }, /** * Shows the OneTrust Consent Modal’s decline button * – primarily used for Italy sites/users */ showOTDeclineButton() { const otModal = doc.querySelector(‘#onetrust-banner-sdk’); if (otModal) otModal.classList.add(‘with-decline-option’); }, /** * Updates CCPA form iframe styles (heights) */ updateFormIframeStyles(formFrame) { if (formFrame) { const formContInner = formFrame.parentElement; const formContEmbed = formContInner.parentElement; const formContBody = formContEmbed.parentElement; const formContMain = formContBody.parentElement.parentElement; formContInner.classList.add(‘onetrust-do-not-sell-form-embed-inner’); formContEmbed.classList.add(‘onetrust-do-not-sell-form-embed’); formContBody.classList.add(‘onetrust-do-not-sell-form-body’); formContMain.classList.add(‘onetrust-do-not-sell-form-content’); formFrame.classList.add(‘onetrust-do-not-sell-form’); } }, /** * Sets all the global values * * window object properties: * – CMP_CONSENT * – CMP_PARTIAL_CONSTENT – depends on if opted out of some categories * – CMP_WITHDRAWN – only set when the user declines consent * – CMP_CONSENT_GROUPS – all cookie category groups consented to * – CMP_CCPA_OPT_OUT – true if user opted out of sale of data * – CMP_GPC_SET – true if global privacy control is on */ setGlobalValues() { // Global function used by video and tags to determine if a GDPR consent modal is showing // TODO: remove duplicate vars after migrate to CMP vocab win.GDPR_CONSENT_MODAL = win.cmpUtils.hasModal; win.CMP_CONSENT_MODAL = win.cmpUtils.hasModal; // Get Consent Groups const { cmpConsentGroups, partialConsent } = win.cmpUtils.getConsentGroups(); win.cmpUtils.log(‘loadCmpScript – setGlobalValues’, ‘cmpConsentGroups’, cmpConsentGroups); win.cmpUtils.log(‘loadCmpScript – setGlobalValues’, ‘partialConsent’, partialConsent); // Set Consent Groups into Global // TODO: remove duplicate vars after migrate to CMP vocab win.GDPR_CONSENT_GROUPS = cmpConsentGroups; win.CMP_CONSENT_GROUPS = cmpConsentGroups; // Get CCPA Opt Out win.CMP_CCPA_OPTOUT = win.cmpUtils.getCCPAOptOut(); win.cmpUtils.log( ‘loadCmpScript – setGlobalValues’, ‘win.CMP_CCPA_OPTOUT’, win.CMP_CCPA_OPTOUT ); // Get GPC Status win.CMP_GPC_SET = win.cmpUtils.getGPCStatus(); win.cmpUtils.log(‘loadCmpScript – setGlobalValues’, ‘win.CMP_GPC_SET’, win.CMP_GPC_SET); // If consent in any of categories 2 through 5 – check for YES consent win.cmpUtils.haveConsent = !!/C0002|C0003|C0004|C0005/.test(cmpConsentGroups); win.cmpUtils.log( ‘loadCmpScript – setGlobalValues’, ‘cmpUtils.haveConsent’, win.cmpUtils.haveConsent ); // Set consent state as a global variable for use by tags // – Caution: this is a generic consent value // – Consent should be checked by cookie category or vendor ID // – See details here: // https://www.notion.so/mediaos/GDPR-Consent-Management-38127bd6b9904408a809a9946a358d9f // TODO: remove duplicate vars after migrate to CMP vocab win.GDPR_CONSENT = !!win.cmpUtils.haveConsent; win.CMP_CONSENT = !!win.cmpUtils.haveConsent; win.cmpUtils.log(‘loadCmpScript – setGlobalValues’, ‘win.CMP_CONSENT’, win.CMP_CONSENT); // Check for partial consent and set global if true if (partialConsent) { // TODO: remove duplicate vars after migrate to CMP vocab win.GDPR_PARTIAL_CONSENT = true; win.CMP_PARTIAL_CONSENT = true; win.cmpUtils.log( ‘loadCmpScript – setGlobalValues’, ‘win.CMP_PARTIAL_CONSENT’, win.CMP_PARTIAL_CONSENT ); } // Get the OptanonAlertBoxClosed Cookie const onetrustAlertBoxCookieVal = win.cmpUtils.getAlertBoxCookieValue(); // If consent has been withdrawn set a global variable for use by tags if (!win.cmpUtils.haveConsent && onetrustAlertBoxCookieVal) { // TODO: remove duplicate vars after migrate to CMP vocab win.GDPR_WITHDRAWN = true; win.CMP_WITHDRAWN = true; win.cmpUtils.log(‘loadCmpScript – setGlobalValues’, ‘win.CMP_WITHDRAWN’, win.CMP_WITHDRAWN); } }, /** * Wait for OptanonAlertBoxClosed Cookie to be set * * @param {string} name * @returns {promise} */ waitForOTCookie(name) { // time counter to avoid infinite loop when OptanonAlertBoxClosed does not exist let counter = 0; function assignOTCookiePromise(resolve, reject) { if (counter >= 1000) reject(`${name} does not exist`); if (win.cmpUtils.getCookieMatch(name)) { resolve(true); } else if (counter { // Get the OptanonAlertBoxClosed Cookie const onetrustAlertBoxCookieVal = win.cmpUtils.getAlertBoxCookieValue(); // Reset Global Values win.cmpUtils.setGlobalValues(); // Get datestamp from the OptanonAlertBoxClosed cookie if it exists const otAbcCookieTimestamp = onetrustAlertBoxCookieVal ? new Date(onetrustAlertBoxCookieVal[1]).getTime() : 0; win.cmpUtils.log( ‘loadCmpScript – OptanonWrapper’, ‘otAbcCookieTimestamp’, otAbcCookieTimestamp ); win.cmpUtils.log(‘loadCmpScript – OptanonWrapper’, ‘overwriteCookie’, overwriteCookie); // IF there is NO consent and cookie timestamp is more than 12 hours ago if ( !win.cmpUtils.haveConsent && overwriteCookie && otAbcCookieTimestamp – (Date.now() – 1000 * 60 * 60 * 12) < 0 ) { // Expire the OptanonAlertBox cookie which allows the OneTrust modal to appear let cookieString = 'OptanonAlertBoxClosed=;expires=Thu, 01 Jan 1970 00:00:00 GMT;'; // Add path for international sites const prefix = win.URL_LANGUAGE_PREFIX; cookieString += prefix && env === 'prod' ? `path=/${prefix}/;` : 'path=/;'; // Production domains need to have cookie domain explicitly set if (hasWwwInHostName) { const cookieDomain = win.location.hostname.replace('www', ''); cookieString += `domain=${cookieDomain};`; } win.cmpUtils.log('loadCmpScript', 'expire cookie', true); doc.cookie = cookieString; } // this check if approve or not // Maximum waiting time for the last user action in milliseconds const MAX_TIME_ACTION = 250; const recentAction = otAbcCookieTimestamp ? Date.now() - otAbcCookieTimestamp doc.location.reload()); } // Send CMP Set event with consent callback // TODO: remove duplicate vars after migrate to CMP vocab win.cmpUtils.emitEvent('gdpr.consent.set', { haveConsent: !!win.cmpUtils.haveConsent }); win.cmpUtils.emitEvent('cmp.consent.set', { haveConsent: !!win.cmpUtils.haveConsent }); win.cmpUtils.log( 'loadCmpScript - OptanonWrapper', 'finished - cmpUtils.haveConsent', win.cmpUtils.haveConsent ); }); }; // Main Listener for OneTrust win.addEventListener( 'consent.onetrust', function handleConsentOneTrustEvent(e) { win.cmpUtils.log('loadCmpScript', 'Event - consent.onetrust - e', e); }, false ); // Listen for OneTrust Groups assignment win.addEventListener( 'OneTrustGroupsUpdated', function handleOneTrustGroupsUpdatedEvent(e) { // Load IAB CCPA Script if user is in US if (userCountry === 'us') win.cmpUtils.loadIabCcpaScript(); // Adjust CCPA Iframe Styles (heights) if present const oneTrustForm = doc.querySelector('iframe[data-src*="onetrust.com/webform"]'); if (oneTrustForm) win.cmpUtils.updateFormIframeStyles(oneTrustForm); win.cmpUtils.log('loadCmpScript', 'Event - OneTrustGroupsUpdated - e', e); }, false ); // Listen for OneTrust Consent Modal win.addEventListener('onetrust_modal', function handleOneTrustModalEvent() { win.cmpUtils.checkOtTextScroll('#onetrust-policy'); }, { once: true }); // Listen for OneTrust Preferences Center Modal win.addEventListener('onetrust_pc_modal', function handleOneTrustPrefCenterModalEvent() { win.cmpUtils.checkOtTextScroll('#ot-pc-content'); }, false); // A postMessage will be sent upon a successful OneTrust form submission win.addEventListener('message', win.cmpUtils.formCompletionHandler, false); } /** * Load OneTrust SDK Script */ (function loadOneTrust() { /** * Disable OneTrust CMP if: * - query param "disableCMP" is present * - the user agent is "Chrome-Lighthouse" or "PTST" from the automated build tests */ if (~search.indexOf('disableCMP') && (~ua.indexOf('Chrome-Lighthouse') || ~ua.indexOf('PTST')) ) return; // Load script with callback/onload const domainId = `${oneTrustDomainId}${(env === 'stage') ? '-test' : ''}`; const s = doc.createElement('script'); s.type = 'text/javascript'; s.async = true; s.onload = win.cmpUtils.handleOtLoad; s.charset = 'UTF-8'; s.src = 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js'; s.setAttribute('data-domain-script', domainId); s.setAttribute('data-document-language', 'true'); docBody.appendChild(s); })(); /** * Load OneTrust SDK Script Logic */ loadCmpScriptLogic(); }; /** * Loads the CMP bypass script * - Sends event to notify CMP has been bypassed */ function loadCmpBypassScript(win) { win.cmpUtils = { /** * Config */ debug: [], timerStart: Date.now(), bypassed: false, /** * Event Dispatch Wrapper Method * * @param {string} name * @param {object} options */ emitEvent: (name, options = {}) => { win.dispatchEvent(new CustomEvent(name, { detail: options })); }, /** * Keeps a log of the CMP events * * @param {*} name * @param {*} evt * @param {*} msg */ log(name, evt, msg) { const ts = Date.now() – win.cmpUtils.timerStart; win.cmpUtils.debug.push({ name, evt, msg, ts, }); }, }; /** * Loads the Consent Management Bypass Event – OneTrust */ function loadCmpBypassEvent() { win.cmpUtils.bypassed = true; // TODO: remove duplicate vars after migrate to CMP vocab win.GDPR_CONSENT = true; win.CMP_CONSENT = true; win.cmpUtils.emitEvent(‘cmp.consent.bypassed’, {}); win.cmpUtils.log(‘loadCmpBypassScript’, ‘CMP bypassed’, true); } loadCmpBypassEvent(); } // If OneTrust Domain ID load the script and logic // otherwise, run bypass if (oneTrustDomainId) { loadCmpScript(document, window); } else { loadCmpBypassScript(window); } /** * Loads the relevant tag manager scripts * considers: * – GDPR and consent status * – Ads Free status */ (function loadTagManagerScript(doc, win) { const search = window.location.search; const ua = navigator.userAgent; /** * Disable Tag Manager if: * – query param “disableTagManager” is present * – the user agent is “Chrome-Lighthouse” or “PTST” from the automated build tests */ if (~search.indexOf(‘disableTagManager’) && (~ua.indexOf(‘Chrome-Lighthouse’) || ~ua.indexOf(‘PTST’)) ) return; const docBody = doc.body || doc.getElementsByTagName(‘body’)[0]; /** * Creates a script tag to append * * @param {object} d (document) * @param {string} id * @param {string} src * @param {boolean} defer * @returns {object} – script element */ function createScript(d, id, src, defer = false) { const script = d.createElement(‘script’); script.id = id; script.src = src; // programmatic scripts are asynchronous by default script.defer = defer; return script; } /** * Load Tag Manager script */ function loadTagManager() { const isGDPR = ”; const isAdsFree = ”; const base = ‘//nexus.ensighten.com/hearst/mag/Bootstrap.js’; const dev = ‘//nexus.ensighten.com/hearst/mag-dev/Bootstrap.js’; const dnt = ‘//nexus.ensighten.com/hearst/mag-dnt/Bootstrap.js’; const gdpr = ‘//nexus.ensighten.com/hearst/mag-gdpr/Bootstrap.js’; const adsFree = ‘//nexus.ensighten.com/hearst/mag-af/Bootstrap.js’; if (!base) return; // If consent for categories 2 through 5 – check for YES consent const haveConsent = win.GDPR_CONSENT; // If chose CCPA Opt Out const ccpaOptOut = win.CMP_CCPA_OPTOUT; // If has GPC enabled const gpcSet = win.CMP_GPC_SET; let tagManagerScript = base; if (isGDPR) tagManagerScript = haveConsent ? gdpr : dnt; if (ccpaOptOut || gpcSet) tagManagerScript = dnt; if (isAdsFree) tagManagerScript = adsFree; const src = `${doc.cookie.includes(‘nsghtn=d’) ? dev : tagManagerScript}`; const addTag = () => docBody.appendChild(createScript(doc, ‘tag-manager-script’, src, true)); addTag(); } /** * Load Google Tag Manager script */ function loadGoogleTagManager() { const googleTagManagerId = ”; if (!googleTagManagerId) return; win.dataLayer = win.dataLayer || []; win.dataLayer.push({ ‘gtm.start’: new Date().getTime(), event: ‘gtm.js’, }); const src = `https://www.googletagmanager.com/gtm.js?id=${googleTagManagerId}&l=dataLayer`; const addTag = () => docBody.appendChild(createScript(doc, ‘google-tag-manager-script’, src, true)); addTag(); } if (window.cmpUtils && window.cmpUtils.bypassed) { loadTagManager(); loadGoogleTagManager(); } else { // Listen for consent event, then load the tag manager window.addEventListener(‘cmp.consent.set’, () => { loadTagManager(); loadGoogleTagManager(); }, { once: true }); window.addEventListener(‘cmp.consent.bypassed’, () => { loadTagManager(); loadGoogleTagManager(); }, false); } })(document, window); ]]>
Read The Full Article Here