PageSourceSearch

https://americanjir.com/wp-content/plugins/ss-cookie-consent/assets/js/sscc.js?ver=0.1.2

js americanjir.com collected 2026-09-28 09:35:38 UTC 6,076 bytes, 83 lines download raw bytes

1(function(){
2  'use strict';
3  var cfg = window.SSCC_CONFIG || {};
4  var cookieName = 'sscc_consent';
5  var categories = ['necessary','preferences','analytics','functional','marketing'];
6
7  function uuid(){ return 'sscc-' + Math.random().toString(16).slice(2) + '-' + Date.now(); }
8  function getCookie(name){ var m=document.cookie.match(new RegExp('(?:^|; )'+name.replace(/([.$?*|{}()\[\]\\\/\+^])/g,'\\$1')+'=([^;]*)')); return m ? decodeURIComponent(m[1]) : null; }
9  function setCookie(name, val, days){ var d=new Date(); d.setTime(d.getTime()+days*864e5); document.cookie=name+'='+encodeURIComponent(val)+'; expires='+d.toUTCString()+'; path=/; SameSite=Lax'; }
10  function readConsent(){ try { var raw=getCookie(cookieName); return raw ? JSON.parse(raw) : null; } catch(e){ return null; } }
11  function writeConsent(data){ data.policyVersion = cfg.policyVersion || '1.0'; data.updatedAt = new Date().toISOString(); if(!data.consentId) data.consentId = uuid(); setCookie(cookieName, JSON.stringify(data), parseInt(cfg.consentDays || 180,10)); return data; }
12  function isGpc(){ return !!(navigator.globalPrivacyControl || window.globalPrivacyControl); }
13
14  function updateGoogleConsent(choices){
15    if(!cfg.googleConsentMode || typeof window.gtag !== 'function') return;
16    window.gtag('consent','update',{
17      ad_storage: choices.marketing ? 'granted':'denied',
18      analytics_storage: choices.analytics ? 'granted':'denied',
19      ad_user_data: choices.marketing ? 'granted':'denied',
20      ad_personalization: choices.marketing ? 'granted':'denied',
21      functionality_storage: (choices.functional || choices.preferences) ? 'granted':'denied',
22      personalization_storage: choices.preferences ? 'granted':'denied',
23      security_storage: 'granted'
24    });
25  }
26
27  function activateScripts(choices){
28    var nodes = document.querySelectorAll('script[type="text/plain"][data-sscc-category]');
29    Array.prototype.forEach.call(nodes, function(old){
30      var cat = old.getAttribute('data-sscc-category');
31      if(!choices[cat] || old.getAttribute('data-sscc-loaded') === '1') return;
32      var s=document.createElement('script');
33      Array.prototype.forEach.call(old.attributes, function(a){
34        if(['type','data-sscc-category','data-src','data-sscc-loaded'].indexOf(a.name) === -1) s.setAttribute(a.name,a.value);
35      });
36      if(old.getAttribute('data-src')) s.src = old.getAttribute('data-src');
37      s.text = old.text || old.textContent || '';
38      old.setAttribute('data-sscc-loaded','1');
39      old.parentNode.insertBefore(s, old.nextSibling);
40    });
41  }
42
43  function saveLog(data){
44    if(!cfg.restUrl || cfg.logConsent === false) return;
45    try { fetch(cfg.restUrl, {method:'POST', headers:{'Content-Type':'application/json','X-WP-Nonce':cfg.nonce || ''}, body:JSON.stringify(data), credentials:'same-origin'}); } catch(e){}
46  }
47
48  function apply(data, persist){
49    data.choices = data.choices || {};
50    data.choices.necessary = true;
51    if(cfg.respectGpc && isGpc()) { data.choices.marketing = false; data.doNotSellShare = true; data.gpc = true; }
52    updateGoogleConsent(data.choices);
53    activateScripts(data.choices);
54    if(persist){ data=writeConsent(data); saveLog(data); }
55    hideBanner(); showFloating();
56  }
57
58  function showBanner(){ var el=document.getElementById('sscc-banner'); if(el) el.classList.remove('sscc-hidden'); }
59  function hideBanner(){ var el=document.getElementById('sscc-banner'); if(el) el.classList.add('sscc-hidden'); }
60  function showFloating(){ var el=document.getElementById('sscc-floating'); if(el && cfg.showFloatingButton) el.classList.remove('sscc-hidden'); }
61  function openPrefs(){ var b=document.getElementById('sscc-banner'), p=document.getElementById('sscc-preferences'), save=document.getElementById('sscc-save'); if(b) b.classList.remove('sscc-hidden'); if(p) p.classList.remove('sscc-hidden'); if(save) save.classList.remove('sscc-hidden'); }
62  function collectPrefs(){
63    var choices={necessary:true};
64    Array.prototype.forEach.call(document.querySelectorAll('[data-sscc-pref]'), function(i){ choices[i.getAttribute('data-sscc-pref')] = !!i.checked; });
65    return { consentId: (readConsent()||{}).consentId || uuid(), choices: choices, doNotSellShare: !!(document.querySelector('[data-sscc-dns]')||{}).checked, gpc: isGpc(), region:'client' };
66  }
67
68  window.SSCC = { openPreferences: openPrefs, hasConsent:function(cat){ var c=readConsent(); return !!(c && c.choices && c.choices[cat]); }, acceptCategory:function(cat){ var c=readConsent() || {consentId:uuid(), choices:{necessary:true}}; c.choices[cat]=true; apply(c,true); } };
69
70  document.addEventListener('DOMContentLoaded', function(){
71    var existing = readConsent();
72    if(existing && existing.policyVersion === (cfg.policyVersion || '1.0')) { apply(existing,fal
72se); }
73    else { showBanner(); if(cfg.respectGpc && isGpc()){ apply({consentId:uuid(), choices:{necessary:true,preferences:false,analytics:false,functional:false,marketing:false}, doNotSellShare:true, gpc:true, region:'gpc'}, true); } }
74
75    var accept=document.getElementById('sscc-accept'), reject=document.getElementById('sscc-reject'), settings=document.getElementById('sscc-settings'), save=document.getElementById('sscc-save'), floating=document.getElementById('sscc-floating');
76    if(accept) accept.onclick=function(){ apply({consentId:uuid(), choices:{necessary:true,preferences:true,analytics:true,functional:true,marketing:true}, gpc:isGpc(), region:'client'}, true); };
77    if(reject) reject.onclick=function(){ apply({consentId:uuid(), choices:{necessary:true,preferences:false,analytics:false,functional:false,marketing:false}, doNotSellShare:true, gpc:isGpc(), region:'client'}, true); };
78    if(settings) settings.onclick=openPrefs;
79    if(save) save.onclick=function(){ apply(collectPrefs(), true); };
80    if(floating) floating.onclick=openPrefs;
81    document.addEventListener('click', function(e){ var t=e.target; if(t && t.closest){ var link=t.closest('[data-sscc-open-preferences]'); if(link){ e.preventDefault(); openPrefs(); } } });
82  });
83})();

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.