PageSourceSearch

https://namelesspace.com/wp-content/plugins/ab-cookie-consent-woocommerce-1.1.0/assets/js/front.js?ver=1.1.0

js namelesspace.com collected 2026-10-06 12:12:14 UTC 6,684 bytes, 110 lines download raw bytes

1(function(){
2  var KEY=(window.ABCC_VARS&&ABCC_VARS.localStorageKey)||'abccConsent.v2';
3  function $(s){return document.querySelector(s);} function show(el){if(el) el.hidden=false;} function hide(el){if(el) el.hidden=true;}
4  function on(dom,event,fn){dom&&dom.addEventListener(event,fn);}
5  function read(){try{return JSON.parse(localStorage.getItem(KEY)||'');}catch(e){return null;}} function store(c){localStorage.setItem(KEY,JSON.stringify(c||{}));}
6  function update(consent){
7    if(typeof gtag==='function'){
8      gtag('consent','update',{
9        analytics_storage:consent.analytics?'granted':'denied',
10        ad_storage:consent.marketing?'granted':'denied',
11        ad_user_data:consent.marketing?'granted':'denied',
12        ad_personalization:consent.marketing?'granted':'denied',
13        functionality_storage:'granted', security_storage:'granted'
14      });
15    }
16    if(window.fbq){ fbq('consent', consent.marketing ? 'grant' : 'revoke'); }
17  }
18
19  // WooCommerce eCommerce gating
20  var isWoo = !!(window.ABCC_VARS && ABCC_VARS.isWoo);
21  var ECOM_EVENTS = ['view_item','view_item_list','select_item','add_to_cart','remove_from_cart','view_cart','begin_checkout','add_shipping_info','add_payment_info','purchase','refund','view_promotion','select_promotion'];
22  var dl = window.dataLayer = window.dataLayer || [];
23  var _origPush = dl.push.bind(dl);
24  var _queue = [];
25  function shouldHold(obj, consent){
26    if(!isWoo) return false;
27    if(!obj || typeof obj !== 'object') return false;
28    var ev = obj.event || obj.ecommerce_event || obj['gtm.event'];
29    if(!ev) return false;
30    var isEcom = ECOM_EVENTS.indexOf(ev) !== -1 || (obj.ecommerce && (obj.ecommerce.items || obj.ecommerce.purchase || obj.ecommerce.add_to_cart));
31    if(!isEcom) return false;
32    return !(consent && consent.analytics === true);
33  }
34  function flushQueue(){
35    if(!_queue.length) return;
36    try { for(var i=0;i<_queue.length;i++){ _origPush(_queue[i]); } } catch(e) {}
37    _queue = [];
38  }
39  dl.push = function(){
40    var args = Array.prototype.slice.call(arguments);
41    var consent = read() || {};
42    var hold = false;
43    for(var i=0;i<args.length;i++){
44      if(typeof args[i]==='object' && shouldHold(args[i], consent)){ hold = true; break; }
45    }
46    if(hold){
47      for(var j=0;j<args.length;j++){ if(typeof args[j]==='object') _queue.push(args[j]); }
48      return _queue.length;
49    }
50    return _origPush.apply(dl,args);
51  };
52
53  function activate(consent){
54    document.querySelectorAll('script[type="text/plain"][data-cookiecategory]').forEach(function(ph){
55      var cat=ph.getAttribute('data-cookiecategory');
56      if(cat==='analytics' && !consent.analytics) return;
57      if(cat==='marketing' && !consent.marketing) return;
58      var s=document.createElement('script');
59      for(var i=0;i<ph.attributes.length;i++){
60        var a=ph.attributes[i];
61        if(a.name==='type'||a.name==='data-cookiecategory') continue;
62        s.setAttribute(a.name,a.value);
63      }
64      if(ph.textContent) s.text=ph.textContent;
65      ph.parentNode.replaceChild(s,ph);
66    });
67    if(consent.analytics) flushQueue();
68  }
69
70  function apply(c){ store(c); update(c); activate(c); }
71
72  function init(){
73    var b=$('#abcc-banner'), m=$('#abcc-modal'); if(!b||!m) return;
74    b.classList.add( (ABCC_VARS&&ABCC_VARS.position==='top')?'abcc-top':'abcc-bottom' );
75    if(ABCC_VARS&&ABCC_VARS.rtl){ b.setAttribute('dir','rtl'); m.setAttribute('dir','rtl'); }
76    b.querySelector('.abcc-title').textContent=ABCC_VARS.bannerTitle||'';
77    b.querySelector('.abcc-text').innerHTML=ABCC_VARS.bannerBody||'';
78    var wooList = b.querySelector('.abcc-woo-essential');
79    if(ABCC_VARS.isWoo && wooList){
80      wooList.setAttribute('aria-hidden','false');
81      wooList.classList.add('abcc-woo-list');
82      wooList.innerHTML = (ABCC_VARS.wooEssential||[]).map(function(n){return '<li>'+n+'</li>';}).join('');
83    } else if (wooList){ wooList.remove(); }
84    var links=b.querySelector('.abcc-links'), cookie=b.querySelector('.abcc-cookie'), sep=b.querySelector('.abcc-sep'), privacy=b.querySelector('.abcc-privacy');
85    var cu=(ABCC_VARS.cookieUrl||'').trim(), pu=(ABCC_VARS.privacyUrl||'').trim();
86    if(cu){ cookie.href=cu; cookie.textContent='Cookie Policy'; cookie.style.display='inline'; } else { cookie.style.display='none'; }
87    if(pu){ privacy.href=pu; privacy.textContent='Privacy Policy'; privacy.style.display='inline'; } else { privacy.style.display='none'; }
88    if(!cu||!pu){ if(sep) sep.style.display='none'; } if(!cu&&!pu&&links){ links.style.display='none'; }
89    var btnAccept=b.querySelector('.abcc-accept'), btnReject=b.querySelector('.abcc-reject'), bt
89nSettings=b.querySelector('.abcc-settings');
90    btnAccept.textContent=ABCC_VARS.btnAccept||'Accept All';
91    btnReject.textContent=ABCC_VARS.btnReject||'Reject All';
92    btnSettings.textContent=ABCC_VARS.btnSettings||'Settings';
93    on(btnAccept,'click',function(){ apply({analytics:true, marketing:true, ts:Date.now()}); hide(m); hide(b); });
94    on(btnReject,'click',function(){ apply({analytics:false, marketing:false, ts:Date.now()}); hide(m); hide(b); });
95    on(btnSettings,'click',function(){ show(m); });
96    m.querySelector('.abcc-pref-title').textContent=ABCC_VARS.prefTitle||'Cookie preferences';
97    m.querySelector('.abcc-pref-intro').textContent=ABCC_VARS.prefIntro||'';
98    m.querySelector('.abcc-necessary .abcc-opt-text').textContent=ABCC_VARS.catNecessary||'Necessary (always active)';
99    m.querySelector('.abcc-opt-analytics').textContent=ABCC_VARS.catAnalytics||'Analytics';
100    m.querySelector('.abcc-opt-marketing').textContent=ABCC_VARS.catMarketing||'Marketing';
101    m.querySelector('.abcc-cancel').textContent=ABCC_VARS.btnCancel||'Cancel';
102    m.querySelector('.abcc-save').textContent=ABCC_VARS.btnSave||'Save';
103    var chkA=m.querySelector('#abcc-analytics'), chkM=m.querySelector('#abcc-marketing');
104    on(m.querySelector('.abcc-cancel'),'click',function(){ hide(m); });
105    on(m.querySelector('.abcc-save'),'click',function(){ var c={analytics:!!(chkA&&chkA.checked), marketing:!!(chkM&&chkM.checked), ts:Date.now()}; apply(c); hide(m); hide(b); });
106    document.addEventListener('click',function(e){ var t=e.target&&e.target.closest('.abcc-manage'); if(!t) return; e.preventDefault(); var s=read(); if(s){ if(chkA) chkA.checked=!!s.analytics; if(chkM) chkM.checked=!!s.marketing; } show(m); });
107    var s=read(); if(s){ apply(s); hide(b);} else { b.hidden=false; }
108  }
109  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init);} else { init(); }
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.