Test: open in incognito of voer in console: localStorage.removeItem('site_cookie_consent_v1'); location.reload(); Vervang AD_ID en PRIVACY_URL onderaan indien nodig. */ (function(){ 'use strict'; const STORAGE_KEY = 'site_cookie_consent_v1'; const EXPIRE_DAYS = 180; const AD_ID = 'ca-pub-JOUW-ID-HIER'; // <-- vervang met jouw AdSense ID (of laat zo tijdens testen) const PRIVACY_URL = '/privacy.html'; // <-- vervang met jouw privacy-pagina URL function now(){ return Date.now(); } function getConsent(){ try { const raw = localStorage.getItem(STORAGE_KEY); if (!raw) return null; const obj = JSON.parse(raw); if (obj.ts && (now() - obj.ts) > EXPIRE_DAYS*24*60*60*1000) { localStorage.removeItem(STORAGE_KEY); return null; } return obj; } catch(e){ return null; } } function setConsent(obj){ obj.ts = now(); try { localStorage.setItem(STORAGE_KEY, JSON.stringify(obj)); } catch(e){} } function loadAds(consent){ if (!consent || !consent.marketing) return; if (window.adsenseLoaded) return; window.adsenseLoaded = true; const s = document.createElement('script'); s.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; s.async = true; s.setAttribute('data-ad-client', AD_ID); document.head.appendChild(s); } /* Maak en injecteer UI direct (geen DOMContentLoaded wacht) */ function injectBanner(){ if (document.getElementById('cb-wrap-v2')) return; // safety const css = ` #cb-wrap-v2{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;z-index:2147483647} #cb-back-v2{position:absolute;inset:0;background:rgba(0,0,0,0.48)} #cb-card-v2{position:relative;z-index:2;max-width:720px;width:94%;border-radius:12px;padding:18px;background:#0b0d0e;color:#d6d9db;font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial;box-shadow:0 14px 40px rgba(0,0,0,0.6)} @media(prefers-color-scheme:light){ #cb-card-v2{background:#fff;color:#111} } #cb-head-v2{display:flex;gap:12px;align-items:flex-start;justify-content:space-between} #cb-title-v2{color:#c4b454;font-weight:700;margin:0 0 6px 0;font-size:1.05rem} #cb-text-v2{margin:0;font-size:0.95rem;line-height:1.4} #cb-pref-v2{margin-top:12px;padding:12px;border-radius:8px;background:rgba(255,255,255,0.02);font-size:0.93rem} .cb-toggle-v2{display:flex;justify-content:space-between;align-items:center;padding:6px 0} #cb-controls-v2{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px;justify-content:flex-end} .cb-btn-v2{padding:8px 12px;border-radius:9px;border:0;font-weight:700;cursor:pointer} .cb-accept-v2{background:#c4b454;color:#0b0c0d} .cb-reject-v2{background:transparent;border:1px solid rgba(255,255,255,0.06);color:inherit} .cb-save-v2{background:transparent;border:1px solid rgba(255,255,255,0.06);color:inherit} #cb-settings-v2{position:fixed;right:14px;bottom:14px;padding:8px 10px;border-radius:9px;background:#0b0c0d;color:#d6d9db;border:1px solid rgba(255,255,255,0.04);z-index:2147483646;cursor:pointer;display:none} @media(prefers-color-scheme:light){ #cb-settings-v2{background:#fff;color:#222} } `; const style = document.createElement('style'); style.id = 'cb-style-v2'; style.textContent = css; document.head.appendChild(style); // wrapper const wrap = document.createElement('div'); wrap.id = 'cb-wrap-v2'; wrap.setAttribute('role','dialog'); wrap.setAttribute('aria-modal','true'); wrap.style.display = 'none'; wrap.innerHTML = `

Cookies & Privacy

Deze site gebruikt cookies voor werking, statistieken en advertenties. Advertenties & statistieken worden pas ingeschakeld na jouw toestemming. Kies wat je wilt toelaten.

Noodzakelijk
Altijd aan
Statistieken
Marketing
Zie privacy- & cookieverklaring. Keuze wordt ${EXPIRE_DAYS} dagen bewaard.
`; const settingsBtn = document.createElement('button'); settingsBtn.id = 'cb-settings-v2'; settingsBtn.textContent = 'Cookie-instellingen'; settingsBtn.setAttribute('aria-label','Cookie-instellingen'); document.body.appendChild(wrap); document.body.appendChild(settingsBtn); // refs (after appended) const stat = document.getElementById('cb-stat-v2'); const mark = document.getElementById('cb-mark-v2'); const btnAccept = document.getElementById('cb-accept-v2'); const btnReject = document.getElementById('cb-reject-v2'); const btnSave = document.getElementById('cb-save-v2'); function open(){ // ensure body exists; if not, try again shortly (rare) if (!document.body) { setTimeout(open, 10); return; } wrap.style.display = 'flex'; document.body.style.overflow = 'hidden'; wrap.setAttribute('aria-hidden','false'); try { btnAccept.focus(); } catch(e){} } function close(){ wrap.style.display = 'none'; settingsBtn.style.display = 'block'; wrap.setAttribute('aria-hidden','true'); document.body.style.overflow = ''; } btnAccept.addEventListener('click', function(){ const consent = { necessary:true, statistics:true, marketing:true }; setConsent(consent); close(); loadAds(consent); }); btnReject.addEventListener('click', function(){ const consent = { necessary:true, statistics:false, marketing:false }; setConsent(consent); close(); }); btnSave.addEventListener('click', function(){ const consent = { necessary:true, statistics:!!stat.checked, marketing:!!mark.checked }; setConsent(consent); close(); loadAds(consent); }); settingsBtn.addEventListener('click', function(){ const e = getConsent() || { necessary:true, statistics:false, marketing:false }; stat.checked = !!e.statistics; mark.checked = !!e.marketing; open(); }); // If consent exists -> apply silently; otherwise show immediately const existing = getConsent(); if (existing){ stat.checked = !!existing.statistics; mark.checked = !!existing.marketing; close(); loadAds(existing); } else { // show immediately - slight timeout to avoid blocking paint setTimeout(open, 20); } // small accessibility: ESC hides modal (but keeps settings visible) document.addEventListener('keydown', function(ev){ if (ev.key === 'Escape' && wrap.style.display === 'flex'){ close(); } }); // focus trap basic: keep focus in modal while open document.addEventListener('focusin', function(ev){ if (wrap.style.display !== 'flex') return; if (!wrap.contains(ev.target)) { try { btnAccept.focus(); } catch(e){} } }, true); } // end injectBanner // Ensure run: if body exists already, inject now; else wait very shortly if (document.readyState === 'complete' || document.readyState === 'interactive') { injectBanner(); } else { document.addEventListener('DOMContentLoaded', injectBanner); // Fallback if DOMContentLoaded doesn't fire quickly setTimeout(() => { if (!document.getElementById('cb-wrap-v2')) injectBanner(); }, 150); } // expose helpers if needed window.getCookieConsent = getConsent; window.hasConsentFor = function(k){ const c = getConsent(); return !!(c && c[k]); }; })();