FOSSIL
Очаквайте много скоро продукти в тази категория.
. (function (d, w) { 'use strict'; var bar = d.getElementById('bgtime-consent'); if (!bar) return; var COOKIE = 'bgtime_consent', DAYS = 180; function stored() { var match = d.cookie.match(/(?:^|;\s*)bgtime_consent=(accepted|rejected)/); return match ? match[1] : ''; } function remember(value) { d.cookie = COOKIE + '=' + value + '; max-age=' + DAYS * 86400 + '; path=/; SameSite=Lax' + (w.location.protocol === 'https:' ? '; Secure' : ''); } // Runs the scripts the server sent switched off, in page order, as if consent had been given before the page loaded. function activate() { var stub = w.fbq && w.fbq.bgtimeStub ? w.fbq : null, scripts = d.querySelectorAll('script[data-bgtime-consent]'), i, j; // The pixel snippet only loads Facebook's script when it finds no fbq, so the queue steps aside and is replayed afterwards. if (stub) { w.fbq = w._fbq = undefined; } for (i = 0; i < scripts.length; i++) { var old = scripts[i], script = d.createElement('script'); for (j = 0; j < old.attributes.length; j++) { var name = old.attributes[j].name; if (name !== 'type' && name !== 'data-bgtime-consent') { script.setAttribute(name === 'data-bgtime-src' ? 'src' : name, old.attributes[j].value); } } if (!old.hasAttribute('data-bgtime-src')) { script.text = old.text; } else if (!old.hasAttribute('async')) { script.async = false; } old.parentNode.replaceChild(script, old); } if (!stub) return; if (typeof w.fbq !== 'function') { w.fbq = stub; return; } for (i = 0; i < stub.queue.length; i++) { w.fbq.apply(w, stub.queue[i]); } } // Google Analytics and Facebook cookies set while consent was given, on this host and its parent domains. function forget() { var parts = w.location.hostname.split('.'), domains = [''], cookies = d.cookie.split(/;\s*/), i, j; for (i = 0; i < parts.length - 1; i++) { domains.push('; domain=.' + parts.slice(i).join('.')); } for (i = 0; i < cookies.length; i++) { var name = cookies[i].split('=')[0]; if (!/^(_ga|_gid|_gat|_gcl|_fbp|_fbc)/.test(name)) continue; for (j = 0; j < domains.length; j++) { d.cookie = name + '=; max-age=0; path=/' + domains[j]; } } } function choose(value) { var previous = stored(); remember(value); bar.hidden = true; if (value === 'accepted') { activate(); } // Trackers already running on this page stop only with a fresh page. else if (previous === 'accepted') { forget(); w.location.reload(); } } function open() { bar.hidden = false; bar.querySelector('button').focus(); } d.addEventListener('click', function (event) { for (var node = event.target; node && node !== d; node = node.parentNode) { if (node.hasAttribute && node.hasAttribute('data-bgtime-consent-choice')) { choose(node.getAttribute('data-bgtime-consent-choice')); return; } if (node.tagName === 'A' && /#cookie-settings$/.test(node.getAttribute('href') || '')) { event.preventDefault(); open(); return; } } }); // A link to …#cookie-settings, for example from the cookie policy page, also when it only changes the fragment. function fromAddress() { if (w.location.hash === '#cookie-settings') { open(); } } w.addEventListener('hashchange', fromAddress); fromAddress(); })(document, window);