1const head = document.querySelector('head'); 2 3const cookieBotSrcType = 'text/javascript'; 4const cookieBotSrc = 'https://consent.cookiebot.com/uc.js' 5const cookieBotId = 'Cookiebot'; 6const cookieBotAttribute = 'data-cbid'; 7const cookieBotAttributeValue = 'c51f0a18-5328-4114-ab42-4d6e742a4ae8'; 8 9const addCookieBot = () => { 10 const cookieBot = document.createElement('script'); 11 12 cookieBot.type = cookieBotSrcType; 13 cookieBot.async = true; 14 cookieBot.src = cookieBotSrc; 15 cookieBot.id = cookieBotId; 16 cookieBot.setAttribute(cookieBotAttribute, cookieBotAttributeValue); 17 head.appendChild(cookieBot); 18} 19 20const getCookieBotCookie = () => { 21 const match = document.cookie.match(RegExp('(?:^|;\\s*)CookieConsent=([^;]*)')); 22 return match ? match[1].toString() : ''; 23} 24 25const handleStatisticsConsent = (cookieBot) => { 26 return cookieBot.includes('statistics:true') ? 'granted' : 'denied'; 27} 28 29const handlePreferencesConsent = (cookieBot) => { 30 return cookieBot.includes('preferences:true') ? 'granted' : 'denied'; 31} 32 33const handleMarketingConsent = (cookieBot) => { 34 return cookieBot.includes('marketing:true') ? 'granted' : 'denied'; 35} 36 37const defaultAdsDataRedaction = (cookieBot) => { 38 return handleMarketingConsent(cookieBot) === 'denied'; 39} 40 41const handleCookieConsent = () => { 42 const script = document.createElement('script'); 43 44 const cookieBotCookie = getCookieBotCookie(); 45 46 script.setAttribute('data-cookieconsent', 'ignore'); 47 48 script.innerHTML = `(function () { 49 const statistics_consent = ${JSON.stringify(handleStatisticsConsent(cookieBotCookie))}; 50 const preferences_consent = ${JSON.stringify(handlePreferencesConsent(cookieBotCookie))}; 51 const marketing_consent = ${JSON.stringify(handleMarketingConsent(cookieBotCookie))}; 52 const default_ads_data_redaction = ${defaultAdsDataRedaction(cookieBotCookie)}; 53 54 window.dataLayer = window.dataLayer || []; 55 56 function gtag() { 57 dataLayer.push(arguments); 58 } 59 60 gtag("consent", "default", { 61 ad_storage: marketing_consent, 62 ad_user_data: marketing_consent, 63 ad_personalization: marketing_consent, 64 analytics_storage: statistics_consent, 65 functionality_storage: preferences_consent, 66 personalization_storage: preferences_consent, 67 security_storage: "granted", 68 wait_for_update: 2000, 69 }); 70 71 gtag("set", "ads_data_redaction", default_ads_data_redaction); 72 73 })()` 74 head.appendChild(script); 75} 76 77addCookieBot(); 78handleCookieConsent(); 79 80 81
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.