Files
2026-04-28 15:13:50 +02:00

1 line
17 KiB
JavaScript

(()=>{"use strict";var n={d:(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:(n,t)=>Object.prototype.hasOwnProperty.call(n,t),r:n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},t={};n.r(t),n.d(t,{addCookie:()=>d,clear:()=>g,getAll:()=>m,load:()=>p,save:()=>l,updateTrace:()=>u});var e={};function o(n){const t=n/86400,e=t/30.44,o=t/365.25;if(o>=1){const n=Math.round(o);return 1===n?"1 year":n+" years"}if(e>=2)return Math.round(e)+" months";if(t>=14)return Math.round(t/7)+" weeks";if(t>=1){const n=Math.round(t);return 1===n?"1 day":n+" days"}const s=n/3600;if(s>=1){const n=Math.round(s);return 1===n?"1 hour":n+" hours"}const i=n/60;if(i>=1){const n=Math.round(i);return 1===n?"1 minute":n+" minutes"}return"a few seconds"}function s(n){const t=n.match(/;\s*max-age\s*=\s*(-?\d+)/i);if(t){const n=parseInt(t[1],10);return n<=0?null:o(n)}const e=n.match(/;\s*expires\s*=\s*([^;]+)/i);if(e){const n=new Date(e[1].trim());if(!isNaN(n.getTime())){const t=Math.round((n.getTime()-Date.now())/1e3);return t<=0?null:o(t)}}return"Session"}function i(n){const[t,...e]=n.split("=");return{name:t.trim(),value:e.join("=").trim()}}n.r(e),n.d(e,{classifyCookies:()=>h,findMatch:()=>w,isAdminContext:()=>f});const c=["wordpress_logged_in_","wordpress_sec_","wordpress_test_cookie","wp-settings-"];const r="wpconsent_inspector";let a=null;function p(){if(null!==a)return a;try{const n=sessionStorage.getItem(r);a=n?JSON.parse(n):{}}catch(n){a={}}return a}function l(n){a=n;try{sessionStorage.setItem(r,JSON.stringify(n))}catch(n){}}function d(n){const t=p(),e=n.name;if(t[e])t[e].pages.includes(n.page)||t[e].pages.push(n.page),n.stack&&!n.preExisting&&(t[e].traces[n.page]={stack:n.stack}),t[e].lastSeen=n.timestamp,t[e].value=n.value,!t[e].duration&&n.duration&&(t[e].duration=n.duration);else{const o={};n.stack&&!n.preExisting&&(o[n.page]={stack:n.stack}),t[e]={name:n.name,value:n.value,pages:[n.page],traces:o,firstSeen:n.timestamp,lastSeen:n.timestamp,preExisting:n.preExisting||!1,consentState:n.consentState||"pre-consent",duration:n.duration||null}}return l(t),t}function u(n,t,e){const o=p();o[n]&&(o[n].traces[t]||(o[n].traces[t]={}),Object.assign(o[n].traces[t],e),l(o))}function m(){return p()}function g(){a=null,sessionStorage.removeItem(r)}function w(n,t){for(const e of t)if(e.cookie_id===n)return e;for(const e of t)if(e.cookie_id.endsWith("_")&&n.startsWith(e.cookie_id))return e;return null}function f(n,t){return!(!Array.isArray(t)||0===t.length)&&t.some(t=>n===t||n.startsWith(t))}function h(n,t,e,o=[]){const s={needsAttention:[],unknown:[],adminContext:[],ok:[]};for(const i of Object.values(n)){const n=w(i.name,t),c="pre-consent"===i.consentState,r=n?{...i,matchedTo:n}:i;n?"essential"===n.slug||"discovery"===e?s.ok.push(r):"optout"===e?c?s.ok.push(r):s.needsAttention.push(r):c?s.needsAttention.push(r):s.ok.push(r):f(i.name,o)?s.adminContext.push(r):s.unknown.push(r)}return s}const v="wpconsent_inspector_pages";function y(){try{const n=sessionStorage.getItem(v);return n?JSON.parse(n):[]}catch(n){return[]}}function b(){return y().length||1}const k="wpconsent_inspector_hint_shown",S='<svg width="20" height="20" viewBox="0 0 145 100" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#c)"><path d="M7.72 43.85l25.03-.03c1.56 0 3-.85 3.77-2.21L56.24 6.63h-.03c.4-.66.65-1.43.65-2.26C56.86 2 54.96.07 52.6.01H27.55c-1.56 0-3 .85-3.77 2.21L3.95 37.39c-1.63 2.9.46 6.47 3.79 6.47h-.02Z" fill="currentColor"/><path d="M144.42 50c0-.81-.23-1.56-.62-2.21L120.34 6.17l-17.51 30.97 6.11 10.84c.34.62.52 1.33.52 2.1 0 .7-.19 1.35-.48 1.94l-23.12 41.04c-.51.71-.82 1.59-.82 2.55 0 2.41 1.94 4.35 4.34 4.39h24.99c1.56 0 3-.85 3.77-2.21l25.86-45.88h-.03c.27-.57.44-1.2.44-1.75Z" fill="currentColor"/><path d="M99.8 30.01L116.87 0H84.68s0 0 0 .01h-.15c-1.72 0-3.21 1.01-3.91 2.47L46.63 62.56a3.44 3.44 0 0 1-3.85 1.8 3.43 3.43 0 0 1-2.08-1.67l-5.77-10.23a3.42 3.42 0 0 0-2.97-1.72H4.34c-3.32 0-5.39 3.58-3.76 6.47l23.25 41.24c.77 1.36 2.21 2.21 3.77 2.21h29.73c.04 0 .07 0 .11 0 1.66 0 3.09-.93 3.83-2.3l21.32-37.44 12.92-22.71 3.8-6.68.49-.86Z" fill="currentColor"/></g></svg>';!function(){if("undefined"==typeof wpconsentInspector)return;const n=wpconsentInspector,o="wpconsent_inspector_initialized";try{if(!sessionStorage.getItem(o))return sessionStorage.setItem(o,"1"),function(){const n=document.cookie;if(!n)return;const t=function(){const n="undefined"!=typeof window&&window.wpconsentInspector&&Array.isArray(window.wpconsentInspector.adminContextPrefixes)?window.wpconsentInspector.adminContextPrefixes:null;return n&&n.length>0?n:c}();n.split(";").forEach(n=>{const e=n.split("=")[0].trim();if(!e||function(n,t){return t.some(t=>n===t||n.startsWith(t))}(e,t))return;const o=["/",window.location.pathname],s=["",window.location.hostname,"."+window.location.hostname];o.forEach(n=>{s.forEach(t=>{let o=e+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path="+n;t&&(o+="; domain="+t),document.cookie=o})})})}(),void window.location.reload()}catch(n){}try{const n=sessionStorage.getItem(v),t=n?JSON.parse(n):[],e=window.location.pathname;t.includes(e)||(t.push(e),sessionStorage.setItem(v,JSON.stringify(t)))}catch(n){}let r=/(^|;\s*)wpconsent_preferences=/.test(document.cookie);const a={onCookieDetected:[]};let p=null;function l(n){r||"wpconsent_preferences"!==n.name||(r=!0),n.consentState=r?"post-consent":"pre-consent",d(n),a.onCookieDetected.forEach(t=>{try{t(n)}catch(n){}}),p||(p=requestAnimationFrame(()=>{p=null,u&&u.render()}))}const u=function({storage:n,matcher:t,config:e,onStop:o,onReview:s,isConsentGiven:i}){let c=null,r=null,a=null,p=!0;function l(n){const t=document.createElement("div");return t.appendChild(document.createTextNode(n)),t.innerHTML}function d(n,t){const o=n.pages?n.pages.length:0,s=[];n.matchedTo&&(s.push(l(n.matchedTo.category)),n.matchedTo.service&&s.push(l(n.matchedTo.service))),o>0&&s.push(o+" "+(1===o?e.i18n.pageSingular:e.i18n.pagePlural));let i="";"needsAttention"===t&&(i=n.matchedTo?'<div class="wpconsent-inspector-cookie-warning">'+l(e.i18n.blockingRuleWarning)+"</div>":'<div class="wpconsent-inspector-cookie-warning">'+l(e.i18n.undocumentedWarning)+"</div>");const c="adminContext"===t?`<span class="wpconsent-inspector-cookie-badge wpconsent-inspector-cookie-badge-admin-context">${l(e.i18n.adminOnlyBadge)}</span>`:"";return`\n\t\t\t<div class="wpconsent-inspector-cookie" data-cookie-name="${l(n.name)}">\n\t\t\t\t<div class="wpconsent-inspector-cookie-name">${l(n.name)}${c}</div>\n\t\t\t\t<div class="wpconsent-inspector-cookie-meta">${s.join(" &middot; ")}</div>\n\t\t\t\t${i}\n\t\t\t</div>\n\t\t`}let u=null;function m(){if(!u){try{if(sessionStorage.getItem(k))return;sessionStorage.setItem(k,"1")}catch(n){}u=document.createElement("div"),u.className="wpconsent-inspector-hint",u.textContent=e.i18n.minimizeHint,document.body.appendChild(u),u.addEventListener("click",n,{once:!0}),setTimeout(n,6e3),g()}function n(){u&&u.parentNode&&(u.remove(),u=null)}}function g(){if(!u||!c)return;const n=c.querySelector(".wpconsent-inspector-btn-minimize");if(!n)return;const t=n.getBoundingClientRect();u.style.bottom=window.innerHeight-t.top+8+"px",u.style.right=window.innerWidth-t.right+"px"}function w(){if(!c)return;const m=n.getAll(),w=t.classifyCookies(m,e.documented_cookies,e.inspectorMode,e.adminContextPrefixes),f=w.needsAttention.length+w.unknown.length+w.adminContext.length+w.ok.length,h=w.needsAttention.length+w.unknown.length;a&&(a.textContent=h,a.style.display=h>0?"block":"none");let v="";w.needsAttention.length>0&&(v+=`<div class="wpconsent-inspector-section-title wpconsent-inspector-section-title-attention">${l(e.i18n.sectionAttention)} (${w.needsAttention.length})</div>`,v+=w.needsAttention.map(n=>d(n,"needsAttention")).join("")),w.unknown.length>0&&(v+=`<div class="wpconsent-inspector-section-title wpconsent-inspector-section-title-unknown">${l(e.i18n.sectionUndocumented)} (${w.unknown.length})</div>`,v+=w.unknown.map(n=>d(n,"unknown")).join("")),w.ok.length>0&&(v+=`<div class="wpconsent-inspector-section-title wpconsent-inspector-section-title-ok">${l(e.i18n.sectionOk)} (${w.ok.length})</div>`,v+=w.ok.map(n=>d(n,"ok")).join("")),w.adminContext.length>0&&(v+=`<div class="wpconsent-inspector-section-admin-context${p?" wpconsent-inspector-section-admin-context-collapsed":""}">`,v+=`<button type="button" class="wpconsent-inspector-section-title wpconsent-inspector-section-title-admin-context" aria-expanded="${!p}" aria-controls="wpconsent-inspector-admin-context-body">`,v+=`<span>${l(e.i18n.sectionAdminOnly)} (${w.adminContext.length})</span>`,v+='<span class="wpconsent-inspector-section-admin-context-caret" aria-hidden="true">&#9656;</span>',v+="</button>",v+='<div id="wpconsent-inspector-admin-context-body" class="wpconsent-inspector-admin-context-body">',v+=`<div class="wpconsent-inspector-admin-context-explainer">${l(e.i18n.adminOnlyExplainer)}</div>`,v+=w.adminContext.map(n=>d(n,"adminContext")).join(""),v+="</div>",v+="</div>"),0===f&&(v="");const k=function(n,t){const o=i(),s=n.needsAttention.length+n.unknown.length,c=e.i18n;if(0===t)return'<div class="wpconsent-inspector-guidance">'+l(c.guidanceNoCookies)+"</div>";if(!o){if(s>0){const n=1===s?c.cookieSingular:c.cookiePlural;return'<div class="wpconsent-inspector-guidance '+(e.scriptBlockingEnabled?"wpconsent-inspector-guidance-warning":"")+'">'+s+" "+l(n)+" "+l(c.guidancePreBoundaryIssues)+"</div>"}return'<div class="wpconsent-inspector-guidance">'+l(c.guidancePreBoundaryClean)+"</div>"}if(s>0)return'<div class="wpconsent-inspector-guidance wpconsent-inspector-guidance-action">'+s+" "+l(1===s?c.cookieSingular:c.cookiePlural)+" "+l(c.guidancePostBoundaryIssues)+"</div>";const r=b();return'<div class="wpconsent-inspector-guidance wpconsent-inspector-guidance-success">'+l(1===r?c.thisPageLooksGood:r+" "+c.pagesInspectedGood)+"</div>"}(w,f);let x="";e.i18n.blockingDisabledNotice&&(x='<div class="wpconsent-inspector-blocking-notice">'+e.i18n.blockingDisabledNotice+"</div>");const C=function(){const n=e.suggestedPages;if(!n||0===n.length)return"";const t=y(),o=window.location.pathname,s=n.filter(n=>{try{const e=new URL(n.url).pathname;return e!==o&&!t.includes(e)}catch(n){return!1}});if(0===s.length)return"";const i=s.map(n=>'<a href="'+l(n.url)+'" class="wpconsent-inspector-suggested-link">'+l(n.label)+"</a>").join("");return'<div class="wpconsent-inspector-suggested-pages"><span class="wpconsent-inspector-suggested-label">'+l(e.i18n.suggestedPagesLabel)+"</span>"+i+"</div>"}();let _="";w.unknown.length>0?_='<button class="wpconsent-inspector-btn-review">'+l(e.i18n.reviewCookies)+"</button>":f>0&&(_=`<button class="wpconsent-inspector-btn-finish">${l(e.i18n.finish)}</button>`);const P=C||_?`<div class="wpconsent-inspector-actions">${C}${_}</div>`:"";c.innerHTML=`\n\t\t\t<div class="wpconsent-inspector-header">\n\t\t\t\t<h3><span class="wpconsent-inspector-header-logo">${S}</span> WPConsent Cookie Inspector</h3>\n\t\t\t\t<div class="wpconsent-inspector-header-actions">\n\t\t\t\t\t<button type="button" class="wpconsent-inspector-btn-restart" title="${l(e.i18n.restartTitle)}" aria-label="${l(e.i18n.restartTitle)}">&#x21bb;</button>\n\t\t\t\t\t<button type="button" class="wpconsent-inspector-btn-minimize" title="${l(e.i18n.minimizeTitle)}" aria-label="${l(e.i18n.minimizeTitle)}">&minus;</button>\n\t\t\t\t\t<button type="button" class="wpconsent-inspector-btn-stop">Stop</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="wpconsent-inspector-mode-label">${l(function(){const n=e.i18n,t={optin:n.modeOptin,optout:n.modeOptout,discovery:n.modeDiscovery};return t[e.inspectorMode]||t.optin}())}</div>\n\t\t\t${x}\n\t\t\t${k}\n\t\t\t${P}\n\t\t\t<div class="wpconsent-inspector-body">\n\t\t\t\t${v}\n\t\t\t</div>\n\t\t`,function(t){if(!c)return;const e=c.querySelector(".wpconsent-inspector-btn-stop");e&&e.addEventListener("click",o);const i=c.querySelector(".wpconsent-inspector-btn-restart");i&&i.addEventListener("click",()=>{n.clear(),sessionStorage.removeItem("wpconsent_inspector_initialized");for(var t=Object.getOwnPropertyDescriptor(Document.prototype,"cookie").set,e=Object.getOwnPropertyDescriptor(Document.prototype,"cookie").get.call(document).split("; "),o=0;o<e.length;o++)for(var s=window.location.hostname.split(".");s.length>0;){var i=encodeURIComponent(e[o].split(";")[0].split("=")[0])+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain="+s.join(".")+" ;path=",c=location.pathname.split("/");for(t.call(document,i+"/");c.length>0;)t.call(document,i+c.join("/")),c.pop();s.shift()}Object.defineProperty(document,"cookie",{get:function(){return""},set:function(){}}),window.location.reload()});const a=c.querySelector(".wpconsent-inspector-btn-minimize");a&&a.addEventListener("click",()=>{u&&u.parentNode&&(u.remove(),u=null),c.style.display="none",r.style.display="flex"});const l=c.querySelector(".wpconsent-inspector-btn-review");l&&l.addEventListener("click",()=>{s(t)});const d=c.querySelector(".wpconsent-inspector-btn-finish");d&&d.addEventListener("click",o);const m=c.querySelector(".wpconsent-inspector-section-title-admin-context");m&&m.addEventListener("click",()=>{p=!p;const n=c.querySelector(".wpconsent-inspector-section-admin-context");n&&n.classList.toggle("wpconsent-inspector-section-admin-context-collapsed",p),m.setAttribute("aria-expanded",String(!p))})}(w.unknown),g()}return{mount:function(){const n=function(){const n=e.bannerLayout||"long",t=e.bannerPosition||"top",o=[];return"floating"===n&&"right-bottom"===t&&o.push("wpconsent-inspector-left"),"long"===n&&"bottom"===t&&o.push("wpconsent-inspector-above-banner"),"bottom"!==t&&"right-bottom"!==t&&"left-bottom"!==t||o.push("wpconsent-inspector-banner-bottom"),o.join(" ")}();r=document.createElement("button"),r.className="wpconsent-inspector-toggle"+(n?" "+n:""),r.innerHTML=S,r.title=e.i18n.panelTitle,r.style.display="none",r.addEventListener("click",()=>{c.style.display="flex",r.style.display="none",w()}),a=document.createElement("span"),a.className="wpconsent-inspector-badge",r.appendChild(a),document.body.appendChild(r),c=document.createElement("div"),c.className="wpconsent-inspector-panel"+(n?" "+n:""),document.body.appendChild(c),function(){if("long"!==(e.bannerLayout||"long")||"bottom"!==(e.bannerPosition||"top"))return;const n=document.querySelector(".wpconsent-banner-holder .wpconsent-banner");if(!n)return;const t=n.offsetHeight+20;c&&c.style.setProperty("--wpconsent-banner-offset",t+"px"),r&&r.style.setProperty("--wpconsent-banner-offset",t+"px")}(),w(),setTimeout(m,500)},render:w,destroy:function(){c&&(c.remove(),c=null),r&&(r.remove(),r=null),a=null,u&&(u.remove(),u=null)}}}({storage:t,matcher:e,config:n,onStop:function(){const t=new FormData;t.append("action","wpconsent_inspector_deactivate"),t.append("nonce",n.nonce),t.append("pages_count",b()),fetch(n.ajaxurl,{method:"POST",credentials:"same-origin",body:t}).finally(()=>{m(),u.destroy(),g(),sessionStorage.removeItem(o),sessionStorage.removeItem(v),sessionStorage.removeItem(k),window.WPConsentInspector=null,window.location.href=n.review_url})},onReview:function(t){const e=t.map(n=>{const t={name:n.name,value:n.value||"",pages:n.pages||[],consentState:n.consentState||"pre-consent",duration:n.duration||null};if(n.traces&&Object.keys(n.traces).length>0)for(const e of Object.keys(n.traces)){const o=n.traces[e];if(o.suggestedPattern){t.scriptUrl=o.scriptUrl||"",t.suggestedPattern=o.suggestedPattern,o.inlineScript&&(t.inlineScript=o.inlineScript);break}}return t}),s=new FormData;s.append("action","wpconsent_inspector_save_for_review"),s.append("nonce",n.nonce),s.append("cookies",JSON.stringify(e)),s.append("pages_count",b()),fetch(n.ajaxurl,{method:"POST",credentials:"same-origin",body:s}).then(n=>n.json()).then(n=>{n.success&&(m(),u.destroy(),g(),sessionStorage.removeItem(o),sessionStorage.removeItem(v),sessionStorage.removeItem(k),window.WPConsentInspector=null,window.location.href=n.data.review_url)})},isConsentGiven:()=>r});u.mount(),function(n){const t=window.__wpconsentEarlyCookies;t&&Array.isArray(t)&&"function"==typeof n&&(window.__wpconsentEarlyCookies=null,t.forEach(t=>{const e=i(t.value.split(";")[0]);e.name&&n({name:e.name,value:e.value,page:t.page,timestamp:t.timestamp,preExisting:!1,stack:t.stack,duration:s(t.value)})}))}(l),function(){const n=document.cookie;return n?n.split(";").map(n=>{const{name:t,value:e}=i(n);return t?{name:t,value:e,page:window.location.href,timestamp:Date.now(),preExisting:!0,stack:"",duration:null}:null}).filter(Boolean):[]}().forEach(l);const m=function(n){const t=Object.getOwnPropertyDescriptor(Document.prototype,"cookie");if(!t||!t.set)return()=>{};const e=t.get,o=t.set;return Object.defineProperty(document,"cookie",{get:()=>e.call(document),set(t){const e=i(t.split(";")[0]);return e.name&&"function"==typeof n&&n({name:e.name,value:e.value,page:window.location.href,timestamp:Date.now(),preExisting:!1,stack:(new Error).stack||"",duration:s(t)}),o.call(document,t)},configurable:!0}),()=>{Object.defineProperty(document,"cookie",t)}}(l);window.WPConsentInspector={hooks:a,storage:t,matcher:e,panel:u,config:n}}()})();