PageSourceSearch

https://www.sou-skoda.cz/o/lfaas-skoda-theme/js/liferay-analytics-consent.js?t=1788451512000

js sou-skoda.cz collected 2026-10-06 05:16:55 UTC 3,873 bytes, 110 lines download raw bytes

1(function() {
2  'use strict';
3
4  const CONSENT_COOKIE_NAME = 'liferay_ac_consent';
5  const RELOAD_FLAG = 'ac_sync=1';
6  
7  const GROUP_NAMES = {
8    'C0001': 'Strictly Necessary',
9    'C0002': 'Performance & Analytics',
10    'C0003': 'Functional',
11    'C0004': 'Targeting & Advertising'
12  };
13
14  console.log('[Liferay AC Consent] Controller v5 (Clean URL) Active');
15
16  function getCookie(name) {
17    const match = document.cookie.match(RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
18    return match ? match[1] : null;
19  }
20
21  // Export to window for use in other scripts
22  window.getCookie = getCookie;
23
24  function getReadableConsent() {
25    if (!window.OptanonActiveGroups) return 'None';
26    return window.OptanonActiveGroups.split(',')
27      .filter(id => GROUP_NAMES[id])
28      .map(id => GROUP_NAMES[id])
29      .join(', ') || 'Basic only';
30  }
31
32  /**
33   * INITIALIZATION: Cleans URL and Logs Consent Type
34   */
35  function initPageLifecycle() {
36    const stored = getCookie(CONSENT_COOKIE_NAME);
37    const urlWasSynced = window.location.search.includes(RELOAD_FLAG);
38    const readableGroups = getReadableConsent();
39
40    // 1. Log what type of consent we have
41    if (stored === 'true') {
42      console.log(`%c[Liferay AC Consent] PERSISTENCE: Recovered saved consent for [${readableGroups}]. Tracking is ACTIVE.`, "color: #28a745; font-weight: bold;");
43    } else {
44      console.log(`%c[Liferay AC Consent] PERSISTENCE: No previous consent found. Tracking is BLOCKED.`, "color: #dc3545; font-weight: bold;");
45    }
46
47    // 2. Clean the URL (Remove ?ac_sync=1 without reloading)
48    if (urlWasSynced) {
49      console.log(`[Liferay AC Consent] CLEANUP: Removing sync flag from URL...`);
50      const cleanUrl = window.location.href
51        .replace(new RegExp('[?&]' + RELOAD_FLAG.replace('=', '\\=')), '')
52        .replace(/\?$/, ''); // Remove trailing ? if it exists
53      
54      window.history.replaceState({}, document.title, cleanUrl);
55    }
56  }
57
58  /**
59   * SYNC LOGIC: Only triggers on REAL changes
60   */
61  function handleConsentChange() {
62    const hasConsent = window.OptanonActiveGroups && window.OptanonActiveGroups.includes('C0002');
63    const storedConsent = getCookie(CONSENT_COOKIE_NAME) === 'true';
64    const readableGroups = getReadableConsent();
65
66    // Mismatch detection
67    if (hasConsent !== storedConsent) {
68      console.log(`[Liferay AC Consent] ACTION: User changed consent to [${readableGroups}]. Writing to cookie...`);
69      
70      const date = new Date();
71      date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
72      
73      if (hasConsent) {
74        document.cookie = `${CONSENT_COOKIE_NAME}=true; expires=${date.toUTCString()}; path=/`;
75      } else {
76        document.cookie = `${CONSENT_COOKIE_NAME}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
77      }
78
79      // Append reload flag to URL
80      const separator = window.location.search ? '&' : '?';
81      const syncUrl = window.location.href + separator + RELOAD_FLAG;
82
83      console.log('[Liferay AC Consent] RELOADING: Applying new settings to Analytics Cloud...');
84      window.location.replace(syncUrl);
85    } else {
86      console.log(`[Liferay AC Consent] STABLE: OneTrust state [${readableGroups}] matches our local storage.`);
87    }
88  }
89
90  // --- EXECUTION ---
91  
92  // Apply sync based on current cookie immediately
93  window['ac_client_disable_tracking'] = (getCookie(CONSENT_COOKIE_NAME) !== 'true');
94
95  // Wait for OneTrust
96  const checkOneTrust = setInterval(() => {
97    if (window.OneTrust && window.OneTrust.OnConsentChanged && window.OptanonActiveGroups) {
98      clearInterval(checkOneTrust);
99      
100      // Initialize logging and cleanup
101      initPageLifecycle();
102      
103      // Bind listener for future changes (clicks)
104      window.OneTrust.OnConsentChanged(handleConsentChange);
105    }
106  }, 200);
107  
108  setTimeout(() => clearInterval(checkOneTrust), 5000);
109
110})();

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.