function __cb_setupFunction() { try { const scriptElm = document.getElementById('privasee-cb'); if (!scriptElm) return; // These variables are changed when the script compiles on our server const crossDomainSharing = 'false' === 'true' ? true : false; const tcfEnabled = 'false' === 'true' ? true : false; const _companyId = '649b250312f46c0014dcdae1'; const settingsId = `wmueh5--keAG8e`; const isTesting = `false` === 'true' ? true : false; const themingId = `default`; const domain = `https://products.privasee.io`; const gcm = `false` === 'true' ? true : false; const smartCookieBlocker = `false` === 'true' ? true : false; // We defined the dependencies that will be loaded onto the client's website. const arr = [ { rel: `preconnect`, href: `//app.usercentrics.eu` }, { rel: `preconnect`, href: `//api.usercentrics.eu` }, { rel: `preconnect`, href: `//privacy-proxy.usercentrics.eu` }, { rel: `preload`, href: `//app.usercentrics.eu/browser-ui/latest/loader.js`, as: 'script' } ]; // We create the and then insert onto the website's body. arr.forEach((elm, ix) => { var link; link = document.createElement('link'); link.rel = elm.rel; link.href = elm.href; link.id = `cb-assets-${ix}`; if (elm.as) { link.as = elm.as; } __cb_insertAfter(link, ix == 0 ? scriptElm : document.getElementById(`cb-assets-${ix - 1}`)); }); // This is just a listener that is needed in order to know when to load the minimal theme. window.addEventListener('UC_UI_INITIALIZED', function () { // Load the theme if any.. if (themingId !== 'default') { __cb_addStyles({ themingId, domain }); } }); // We now will create the default script which is gonna load the cookie banner. // This script is provided by Usercentrics. let script1 = document.createElement('script'); script1.id = 'usercentrics-cmp'; script1.setAttribute('data-settings-id', settingsId); script1.src = 'https://app.usercentrics.eu/browser-ui/latest/loader.js'; script1.async = true; // If we are in a testing environment, this field must be added. if (isTesting) { script1.setAttribute('data-sandbox', 'true'); } // If TCF is enabled we need to make sure the script is loaded synchronously. if (tcfEnabled) { script1.setAttribute('data-tcf-enabled', 'true'); script1.async = false; // TCF must be not async. } // We inject it onto the website's document body. __cb_insertAfter(script1, document.getElementById(`cb-assets-${arr.length - 1}`)); // These are just two comments that are good to have. It makes it clear where our code injections starts and ends. __cb_insertAfter(document.createComment('COOKIE BANNER - PRIVASEE.IO'), scriptElm); __cb_insertAfter(document.createComment('END COOKIE BANNER - PRIVASEE.IO'), document.getElementById('usercentrics-cmp')); // Deleting the original CDN Script to keep things clear. scriptElm.remove(); // If we are in a testing environment we will also announce it in the console. if (isTesting) { console.warn(`[LOADED] Cookie banner has been loaded.`); } // When Cross Domain sharing is enabled this must be invoked. if (crossDomainSharing) { // Set the dependencies up __cb_crossDomain_setFunctions(domain, _companyId); __cb_crossDomain_setEvents(domain); } // If google consent mode is enabled if (gcm) { __cb_loadGoogleConsentMode(smartCookieBlocker); } } catch (err) { console.error(`[ERROR] Privasee - Cookie Banner`, err); } } function __cb_addStyles(args) { // Find the target const target = document.getElementById('usercentrics-root'); if (!target || !target.shadowRoot) return false; // Check browser name... const browserName = __cb_getBrowserName(); if (browserName === 'Safari') return false; // not compatible. // Create a stylesheet const stylesheet = document.createElement('link'); stylesheet.rel = 'stylesheet'; stylesheet.href = `${args.domain}/assets/css/cookieBanner/${args.themingId}.css`; // Inject it target.shadowRoot.appendChild(stylesheet); } function __cb_insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } function __cb_getBrowserName() { const userAgent = navigator.userAgent; if (userAgent.indexOf('Safari') !== -1 && userAgent.indexOf('Chrome') === -1) { return 'Safari'; } else if (userAgent.indexOf('OPR') !== -1 || userAgent.indexOf('Opera') !== -1) { return 'Opera'; } else if (userAgent.indexOf('Chrome') !== -1) { return 'Chrome'; } else { return 'Others'; } } function __cb_checkIfRedirectForCookiePreferences() { const triggerPath = `?cb-manage-cookies`; // If this user was redirected from our hosted privacy portal to their main website. if (window.location.href.includes(triggerPath)) { window.privasee.cookieBanner.showPreferences(); if (typeof history.replaceState === 'undefined') return false; // something is not right. history.replaceState({}, null, window.location.href.replace(triggerPath, '')); } } function __cb_loadGoogleConsentMode(smartCookieBlockerEnabled = false) { try { // Create a script element var scriptElement = document.createElement('script'); scriptElement.type = 'text/javascript'; scriptElement.id = `privasee-cb-googleConsentMode-1`; // Add the provided code to the script scriptElement.innerHTML = ` // create dataLayer window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } // set "denied" as default for both ad and analytics storage, gtag("consent", "default", { ad_user_data: "denied", ad_personalization: "denied", ad_storage: "denied", analytics_storage: "denied", wait_for_update: 500 // milliseconds to wait for update }); // Enable ads data redaction by default [optional] gtag("set", "ads_data_redaction", true); `; // Add it. __cb_insertAfter(scriptElement, document.getElementById('usercentrics-cmp')); // If smart cookie blocker is enabled we will unlock gtm after 500 ms (We need to wait for the script cmp script to load first) if (smartCookieBlockerEnabled) { // Create a script element var scriptElementSecondary = document.createElement('script'); scriptElementSecondary.type = 'text/javascript'; scriptElementSecondary.id = `privasee-cb-googleConsentMode-2`; scriptElementSecondary.innerHTML = ` setTimeout( () => { if(window.uc) { window.uc.deactivateBlocking([ 'BJ59EidsWQ', // GTM is not blocked ]); } }, 500 ); `; __cb_insertAfter(scriptElementSecondary, document.getElementById('privasee-cb-googleConsentMode-1')); } } catch (err) { console.error(`loadGoogleConsentMode`, err); } } if (window.privasee === undefined) { window.privasee = {}; } window.privasee.cookieBanner = { showPreferences: () => { window.UC_UI.showSecondLayer(); } }; __cb_setupFunction(); setTimeout(__cb_checkIfRedirectForCookiePreferences, 400); // 400 ms for uc script to load.