PageSourceSearch

https://wisesloth.app/scripts/cookie-consent.js?v=20260814

js wisesloth.app collected 2026-09-29 11:59:20 UTC 2,598 bytes, 75 lines download raw bytes

1/**
2 * WiseSloth cookie consent — our own banner + Google Consent Mode.
3 *
4 * We do NOT rely on Google's consent dialog. Instead:
5 *  - A small banner asks the visitor to Accept (analytics + ads) or Reject
6 *    (essential cookies only: session, language/theme).
7 *  - The choice is stored in localStorage and applied to Google Consent Mode
8 *    (analytics_storage / ad_storage) so GA/AdSense only run when allowed.
9 */
10window.WiseSlothConsent = (function () {
11  'use strict';
12
13  const KEY = 'wisesloth_cookie_consent';
14
15  function read() {
16    try {
17      return JSON.parse(localStorage.getItem(KEY) || 'null');
18    } catch (e) {
19      return null;
20    }
21  }
22
23  function save(consent) {
24    try {
25      localStorage.setItem(KEY, JSON.stringify(consent));
26    } catch (e) { /* storage unavailable - just hide the banner this visit */ }
27    window.__wsConsent = consent;
28  }
29
30  function apply(consent) {
31    save(consent);
32    // Update Google Consent Mode (gtag is defined in head before this runs)
33    if (typeof window.gtag === 'function') {
34      window.gtag('consent', 'update', {
35        analytics_storage: consent.analytics ? 'granted' : 'denied',
36        ad_storage: consent.ads ? 'granted' : 'denied',
37        ad_user_data: consent.ads ? 'granted' : 'denied',
38        ad_personalization: 'denied',
39        personalization_storage: 'denied',
40      });
41    }
42    const banner = document.getElementById('cookie-banner');
43    if (banner) banner.classList.add('is-hidden');
44    // Unlock the page
45    document.documentElement.style.overflow = '';
46    document.body.style.overflow = '';
47  }
48
49  function init() {
50    const banner = document.getElementById('cookie-banner');
51    if (!banner) return;
52    // Already decided (or the visitor is a bot / no storage) - keep it hidden
53    if (read()) {
54      banner.classList.add('is-hidden');
55      return;
56    }
57    banner.classList.remove('is-hidden');
58    // Block the page until the visitor chooses (Accept or Reject)
59    document.documentElement.style.overflow = 'hidden';
60    document.body.style.overflow = 'hidden';
61
62    const acceptBtn = document.getElementById('accept-cookies');
63    const rejectBtn = document.getElementById('reject-cookies');
64    if (acceptBtn) acceptBtn.addEventListener('click', () => apply({ essential: true, analytics: true, ads: true }));
65    if (rejectBtn) rejectBtn.addEventListener('click', () => apply({ essential: true, analytics: false, ads: false }));
66  }
67
68  if (document.readyState === 'loading') {
69    document.addEventListener('DOMContentLoaded', init);
70  } else {
71    init();
72  }
73
74  return { init };
75})();

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.