1(() => { 2 const MEASUREMENT_ID = 'G-BPCPFLDJ3M' 3 const CONSENT_KEY = 'cute-fonts:analytics-consent:v1' 4 5 window.dataLayer = window.dataLayer || [] 6 window.gtag = window.gtag || function gtag() { 7 window.dataLayer.push(arguments) 8 } 9 10 window.gtag('consent', 'default', { 11 ad_storage: 'denied', 12 analytics_storage: 'denied', 13 ad_user_data: 'denied', 14 ad_personalization: 'denied', 15 wait_for_update: 500, 16 }) 17 18 function readConsent() { 19 try { 20 const value = localStorage.getItem(CONSENT_KEY) 21 return value === 'granted' || value === 'denied' ? value : null 22 } catch { 23 return null 24 } 25 } 26 27 function saveConsent(value) { 28 try { 29 localStorage.setItem(CONSENT_KEY, value) 30 } catch { 31 // The choice still applies to this page when storage is unavailable. 32 } 33 } 34 35 function loadAnalytics() { 36 if (document.querySelector(`script[data-ga4-id="${MEASUREMENT_ID}"]`)) return 37 38 window.gtag('consent', 'update', { analytics_storage: 'granted' }) 39 window.gtag('js', new Date()) 40 window.gtag('config', MEASUREMENT_ID, { 41 allow_google_signals: false, 42 allow_ad_personalization_signals: false, 43 }) 44 45 const script = document.createElement('script') 46 script.async = true 47 script.src = `https://www.googletagmanager.com/gtag/js?id=${MEASUREMENT_ID}` 48 script.dataset.ga4Id = MEASUREMENT_ID 49 document.head.appendChild(script) 50 } 51 52 function removeBanner() { 53 document.querySelector('.consent-banner')?.remove() 54 } 55 56 function setConsent(value) { 57 saveConsent(value) 58 window.gtag('consent', 'update', { 59 analytics_storage: value, 60 ad_storage: 'denied', 61 ad_user_data: 'denied', 62 ad_personalization: 'denied', 63 }) 64 if (value === 'granted') loadAnalytics() 65 removeBanner() 66 } 67 68 function showBanner() { 69 removeBanner() 70 71 const banner = document.createElement('section') 72 banner.className = 'consent-banner' 73 banner.setAttribute('role', 'dialog') 74 banner.setAttribute('aria-modal', 'false') 75 banner.setAttribute('aria-labelledby', 'consent-title') 76 banner.innerHTML = ` 77 <div class="consent-copy"> 78 <strong id="consent-title">Help us improve Cute Fonts</strong> 79 <p>With your permission, we use Google Analytics to understand visits and interactions. Your typed or generated text is never sent to Analytics. Advertising choices are managed separately by Googleâs certified consent message where required. <a href="/privacy/">Privacy details</a></p> 80 </div> 81 <div class="consent-actions"> 82 <button type="button" data-consent="denied">Reject</button> 83 <button type="button" class="consent-accept" data-consent="granted">Accept analytics</button> 84 </div> 85 ` 86 banner.querySelector('[data-consent="denied"]').addEventListener('click', () => setConsent('denied')) 87 banner.querySelector('[data-consent="granted"]').addEventListener('click', () => setConsent('granted')) 88 document.body.appendChild(banner) 89 } 90 91 function start() { 92 document.addEventListener('click', (event) => { 93 if (event.target.closest('.analytics-preferences')) showBanner() 94 }) 95 96 const consent = readConsent() 97 if (consent === 'granted') loadAnalytics() 98 if (!consent) showBanner() 99 } 100 101 if (document.readyState === 'loading') { 102 document.addEventListener('DOMContentLoaded', start, { once: true }) 103 } else { 104 start() 105 } 106})()
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.