@duckduckgo/autoconsent 4.4.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/addon-firefox/background.bundle.js +19 -11
- package/dist/addon-firefox/content.bundle.js +12 -7
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-mv3/background.bundle.js +19 -11
- package/dist/addon-mv3/content.bundle.js +12 -7
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/autoconsent.cjs.js +1 -1
- package/dist/autoconsent.esm.js +1 -1
- package/dist/autoconsent.playwright.js +1 -1
- package/lib/types.ts +1 -0
- package/lib/web.ts +16 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# v5.0.0 (Thu Jul 13 2023)
|
|
2
|
+
|
|
3
|
+
#### 💥 Breaking Change
|
|
4
|
+
|
|
5
|
+
- Bump typescript from 4.9.5 to 5.1.6 [#196](https://github.com/duckduckgo/autoconsent/pull/196) ([@dependabot[bot]](https://github.com/dependabot[bot]))
|
|
6
|
+
|
|
7
|
+
#### 🚀 Enhancement
|
|
8
|
+
|
|
9
|
+
- Cancel prehide rules if the pop-up takes too long to appear [#205](https://github.com/duckduckgo/autoconsent/pull/205) ([@muodov](https://github.com/muodov))
|
|
10
|
+
- Bump @playwright/test from 1.33.0 to 1.35.1 [#191](https://github.com/duckduckgo/autoconsent/pull/191) ([@dependabot[bot]](https://github.com/dependabot[bot]))
|
|
11
|
+
|
|
12
|
+
#### Authors: 2
|
|
13
|
+
|
|
14
|
+
- [@dependabot[bot]](https://github.com/dependabot[bot])
|
|
15
|
+
- Maxim Tsoy ([@muodov](https://github.com/muodov))
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
1
19
|
# v4.4.0 (Tue Jul 11 2023)
|
|
2
20
|
|
|
3
21
|
#### 🚀 Enhancement
|
|
@@ -89,24 +89,32 @@
|
|
|
89
89
|
console.log('init sw');
|
|
90
90
|
const storedConfig = await storageGet('config');
|
|
91
91
|
console.log('storedConfig', storedConfig);
|
|
92
|
+
const defaultConfig = {
|
|
93
|
+
enabled: true,
|
|
94
|
+
autoAction: 'optOut',
|
|
95
|
+
disabledCmps: [],
|
|
96
|
+
enablePrehide: true,
|
|
97
|
+
enableCosmeticRules: true,
|
|
98
|
+
detectRetries: 20,
|
|
99
|
+
prehideTimeout: 2000,
|
|
100
|
+
};
|
|
92
101
|
if (!storedConfig) {
|
|
93
102
|
console.log('init config');
|
|
94
|
-
const defaultConfig = {
|
|
95
|
-
enabled: true,
|
|
96
|
-
autoAction: 'optOut',
|
|
97
|
-
disabledCmps: [],
|
|
98
|
-
enablePrehide: true,
|
|
99
|
-
enableCosmeticRules: true,
|
|
100
|
-
detectRetries: 20,
|
|
101
|
-
};
|
|
102
103
|
await storageSet({
|
|
103
104
|
config: defaultConfig,
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
|
-
else
|
|
107
|
-
|
|
107
|
+
else { // clean up the old stored config in case there are new fields
|
|
108
|
+
const updatedConfig = structuredClone(defaultConfig);
|
|
109
|
+
for (const key of Object.keys(defaultConfig)) {
|
|
110
|
+
if (typeof storedConfig[key] !== 'undefined') {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
112
|
+
// @ts-ignore - TS doesn't know that we've checked for undefined
|
|
113
|
+
updatedConfig[key] = storedConfig[key];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
108
116
|
await storageSet({
|
|
109
|
-
config:
|
|
117
|
+
config: updatedConfig,
|
|
110
118
|
});
|
|
111
119
|
}
|
|
112
120
|
}
|
|
@@ -1789,12 +1789,8 @@
|
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
|
1791
1791
|
if (foundCMPs.length === 0 && retries > 0) {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
const result = this.findCmp(retries - 1);
|
|
1795
|
-
resolve(result);
|
|
1796
|
-
}, 500);
|
|
1797
|
-
});
|
|
1792
|
+
await wait(500);
|
|
1793
|
+
return this.findCmp(retries - 1);
|
|
1798
1794
|
}
|
|
1799
1795
|
return foundCMPs;
|
|
1800
1796
|
}
|
|
@@ -1900,7 +1896,8 @@
|
|
|
1900
1896
|
async waitForPopup(cmp, retries = 5, interval = 500) {
|
|
1901
1897
|
const isOpen = await cmp.detectPopup();
|
|
1902
1898
|
if (!isOpen && retries > 0) {
|
|
1903
|
-
|
|
1899
|
+
await wait(interval);
|
|
1900
|
+
return this.waitForPopup(cmp, retries - 1, interval);
|
|
1904
1901
|
}
|
|
1905
1902
|
return isOpen;
|
|
1906
1903
|
}
|
|
@@ -1916,6 +1913,14 @@
|
|
|
1916
1913
|
return selectorList;
|
|
1917
1914
|
}, globalHidden);
|
|
1918
1915
|
this.updateState({ prehideOn: true });
|
|
1916
|
+
setTimeout(() => {
|
|
1917
|
+
// unhide things if we are still looking for a pop-up
|
|
1918
|
+
if (this.config.enablePrehide &&
|
|
1919
|
+
this.state.prehideOn &&
|
|
1920
|
+
!['runningOptOut', 'runningOptIn'].includes(this.state.lifecycle)) {
|
|
1921
|
+
this.undoPrehide();
|
|
1922
|
+
}
|
|
1923
|
+
}, this.config.prehideTimeout || 2000);
|
|
1919
1924
|
return prehide(selectors);
|
|
1920
1925
|
}
|
|
1921
1926
|
undoPrehide() {
|
|
@@ -89,24 +89,32 @@
|
|
|
89
89
|
console.log('init sw');
|
|
90
90
|
const storedConfig = await storageGet('config');
|
|
91
91
|
console.log('storedConfig', storedConfig);
|
|
92
|
+
const defaultConfig = {
|
|
93
|
+
enabled: true,
|
|
94
|
+
autoAction: 'optOut',
|
|
95
|
+
disabledCmps: [],
|
|
96
|
+
enablePrehide: true,
|
|
97
|
+
enableCosmeticRules: true,
|
|
98
|
+
detectRetries: 20,
|
|
99
|
+
prehideTimeout: 2000,
|
|
100
|
+
};
|
|
92
101
|
if (!storedConfig) {
|
|
93
102
|
console.log('init config');
|
|
94
|
-
const defaultConfig = {
|
|
95
|
-
enabled: true,
|
|
96
|
-
autoAction: 'optOut',
|
|
97
|
-
disabledCmps: [],
|
|
98
|
-
enablePrehide: true,
|
|
99
|
-
enableCosmeticRules: true,
|
|
100
|
-
detectRetries: 20,
|
|
101
|
-
};
|
|
102
103
|
await storageSet({
|
|
103
104
|
config: defaultConfig,
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
|
-
else
|
|
107
|
-
|
|
107
|
+
else { // clean up the old stored config in case there are new fields
|
|
108
|
+
const updatedConfig = structuredClone(defaultConfig);
|
|
109
|
+
for (const key of Object.keys(defaultConfig)) {
|
|
110
|
+
if (typeof storedConfig[key] !== 'undefined') {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
112
|
+
// @ts-ignore - TS doesn't know that we've checked for undefined
|
|
113
|
+
updatedConfig[key] = storedConfig[key];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
108
116
|
await storageSet({
|
|
109
|
-
config:
|
|
117
|
+
config: updatedConfig,
|
|
110
118
|
});
|
|
111
119
|
}
|
|
112
120
|
}
|
|
@@ -1789,12 +1789,8 @@
|
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
|
1791
1791
|
if (foundCMPs.length === 0 && retries > 0) {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
const result = this.findCmp(retries - 1);
|
|
1795
|
-
resolve(result);
|
|
1796
|
-
}, 500);
|
|
1797
|
-
});
|
|
1792
|
+
await wait(500);
|
|
1793
|
+
return this.findCmp(retries - 1);
|
|
1798
1794
|
}
|
|
1799
1795
|
return foundCMPs;
|
|
1800
1796
|
}
|
|
@@ -1900,7 +1896,8 @@
|
|
|
1900
1896
|
async waitForPopup(cmp, retries = 5, interval = 500) {
|
|
1901
1897
|
const isOpen = await cmp.detectPopup();
|
|
1902
1898
|
if (!isOpen && retries > 0) {
|
|
1903
|
-
|
|
1899
|
+
await wait(interval);
|
|
1900
|
+
return this.waitForPopup(cmp, retries - 1, interval);
|
|
1904
1901
|
}
|
|
1905
1902
|
return isOpen;
|
|
1906
1903
|
}
|
|
@@ -1916,6 +1913,14 @@
|
|
|
1916
1913
|
return selectorList;
|
|
1917
1914
|
}, globalHidden);
|
|
1918
1915
|
this.updateState({ prehideOn: true });
|
|
1916
|
+
setTimeout(() => {
|
|
1917
|
+
// unhide things if we are still looking for a pop-up
|
|
1918
|
+
if (this.config.enablePrehide &&
|
|
1919
|
+
this.state.prehideOn &&
|
|
1920
|
+
!['runningOptOut', 'runningOptIn'].includes(this.state.lifecycle)) {
|
|
1921
|
+
this.undoPrehide();
|
|
1922
|
+
}
|
|
1923
|
+
}, this.config.prehideTimeout || 2000);
|
|
1919
1924
|
return prehide(selectors);
|
|
1920
1925
|
}
|
|
1921
1926
|
undoPrehide() {
|
package/dist/autoconsent.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function t(){return crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString()}class e{constructor(t,e=1e3){this.id=t,this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),e)}}const n={pending:new Map,sendContentMessage:null};function o(t="autoconsent-css-rules"){const e=`style#${t}`,n=document.querySelector(e);if(n&&n instanceof HTMLStyleElement)return n;{const e=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=t,e.appendChild(n),n}}function i(t,e,n="display"){const o="opacity"===n?"opacity: 0":"display: none",i=`${e.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return t instanceof HTMLStyleElement&&(t.innerText+=i,e.length>0)}async function s(t,e,n){const o=await t();return!o&&e>0?new Promise((o=>{setTimeout((async()=>{o(s(t,e-1,n))}),n)})):Promise.resolve(o)}function r(t){if(!t)return!1;if(null!==t.offsetParent)return!0;{const e=window.getComputedStyle(t);if("fixed"===e.position&&"none"!==e.display)return!0}return!1}function c(o){return function(o){const i=t();n.sendContentMessage({type:"eval",id:i,code:o});const s=new e(i);return n.pending.set(s.id,s),s.promise}(o).catch((t=>!1))}function a(t,e=!1){const n=f(t);return n.length>0&&(e?n.forEach((t=>t.click())):n[0].click()),n.length>0}function u(t){return f(t).length>0}function l(t,e){const n=f(t),o=new Array(n.length);return n.forEach(((t,e)=>{o[e]=r(t)})),"none"===e?o.every((t=>!t)):0!==o.length&&("any"===e?o.some((t=>t)):o.every((t=>t)))}function p(t,e=1e4){return s((()=>f(t).length>0),Math.ceil(e/200),200)}async function d(t,e=1e4,n=!1){return await p(t,e),a(t,n)}function h(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}function m(t,e=document){if(t.startsWith("aria/"))return[];if(t.startsWith("xpath/")){const n=t.slice(6),o=document.evaluate(n,e,null,XPathResult.ANY_TYPE,null);let i=null;const s=[];for(;i=o.iterateNext();)s.push(i);return s}return t.startsWith("text/")||t.startsWith("pierce/")?[]:e.shadowRoot?Array.from(e.shadowRoot.querySelectorAll(t)):Array.from(e.querySelectorAll(t))}function f(t){return"string"==typeof t?m(t):function(t){let e,n=document;for(const o of t){if(e=m(o,n),0===e.length)return[];n=e[0]}return e}(t)}const y={main:!0,frame:!1,urlPattern:""};class w{constructor(t){this.runContext=y,this.name=t}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}get isCosmetic(){throw new Error("Not Implemented")}checkRunContext(){const t={...y,...this.runContext},e=window.top===window;return!(e&&!t.main)&&(!(!e&&!t.frame)&&!(t.urlPattern&&!window.location.href.match(t.urlPattern)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function g(t){const e=[];if(t.exists&&e.push(u(t.exists)),t.visible&&e.push(l(t.visible,t.check)),t.eval){const n=c(t.eval);e.push(n)}var n,r;if(t.waitFor&&e.push(p(t.waitFor,t.timeout)),t.waitForVisible&&e.push(function(t,e=1e4,n="any"){return s((()=>l(t,n)),Math.ceil(e/200),200)}(t.waitForVisible,t.timeout,t.check)),t.click&&e.push(a(t.click,t.all)),t.waitForThenClick&&e.push(d(t.waitForThenClick,t.timeout,t.all)),t.wait&&e.push(h(t.wait)),t.hide&&e.push((n=t.hide,r=t.method,i(o(),n,r))),t.if){if(!t.if.exists&&!t.if.visible)return console.error("invalid conditional rule",t.if),!1;await g(t.if)?e.push(C(t.then)):t.else&&e.push(C(t.else))}if(t.any){for(const e of t.any)if(await g(e))return!0;return!1}if(0===e.length)return!1;return(await Promise.all(e)).reduce(((t,e)=>t&&e),!0)}async function C(t){for(const e of t){if(!await g(e)&&!e.optional)return!1}return!0}class b extends w{constructor(t){super(t.name),this.config=t,this.runContext=t.runContext||y}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get isCosmetic(){return!!this.config.cosmetic}get prehideSelectors(){return this.config.prehideSelectors}async detectCmp(){return!!this.config.detectCmp&&async function(t){const e=t.map((t=>g(t)));return(await Promise.all(e)).every((t=>!!t))}(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&C(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&C(this.config.optOut)}async optIn(){return!!this.config.optIn&&C(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&C(this.config.openCmp)}async test(){return this.hasSelfTest?C(this.config.test):super.test()}}function k(t){return new b(t)}const v=[new class extends w{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",".truste_popframe,.truste_overlay,.truste_box_overlay,#truste-consent-track"],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}get isCosmetic(){return!1}async detectCmp(){const t=u("#truste-show-consent,#truste-consent-track");return t&&(this._shortcutButton=document.querySelector("#truste-consent-required")),t}async detectPopup(){return l("#truste-consent-content,#trustarc-banner-overlay,#truste-consent-track","all")}openFrame(){a("#truste-show-consent")}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(i(o(),[".truste_popframe",".truste_overlay",".truste_box_overlay","#truste-consent-track"]),a("#truste-show-consent"),setTimeout((()=>{o().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,a("#truste-consent-button")}async openCmp(){return!0}async test(){return await c("window && window.truste && window.truste.eu.bindMap.prefCookie === '0'")}},new class extends w{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,urlPattern:"^https://consent-pref\\.trustarc\\.com/\\?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return!0}async detectPopup(){return l("#defaultpreferencemanager","any")&&l(".mainContent","any")}async navigateToSettings(){return await s((async()=>u(".shp")||l(".advance","any")||u(".switch span:first-child")),10,500),u(".shp")&&a(".shp"),await p(".prefPanel",5e3),l(".advance","any")&&a(".advance"),await s((()=>l(".switch span:first-child","any")),5,1e3)}async optOut(){return await s((()=>"complete"===document.readyState),20,100),await p(".mainContent[aria-hidden=false]",5e3),!!a(".rejectAll")||(u(".prefPanel")&&await p('.prefPanel[style="visibility: visible;"]',3e3),a("#catDetails0")?(a(".submit"),!0):(a(".required")||(await this.navigateToSettings(),a(".switch span:nth-child(1):not(.active)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0))}async optIn(){return a(".call")||(await this.navigateToSettings(),a(".switch span:nth-child(2)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0}},new class extends w{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return u("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return a(".cookie-alert-extended-detail-link")?(await p(".cookie-alert-configuration",2e3),a(".cookie-alert-configuration-input:checked",!0),a(".cookie-alert-extended-button-secondary"),!0):u("#dtcookie-container")?a(".h-dtcookie-decline"):(a(".cookiebot__button--settings")||a("#CybotCookiebotDialogBodyButtonDecline")||(a(".cookiebanner__link--details"),a('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),a("#CybotCookiebotDialogBodyButtonDecline"),a("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),u("#CybotCookiebotDialogBodyButtonAcceptSelected")?a("#CybotCookiebotDialogBodyButtonAcceptSelected"):a("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await c("window.CookieConsent.hasResponse !== true")&&(await c("window.Cookiebot.dialog.submitConsent()"),await h(500)),u("#cb-confirmedSettings")&&await c("endCookieProcess()")),!0)}async optIn(){return u("#dtcookie-container")?a(".h-dtcookie-accept"):(a(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),a("#CybotCookiebotDialogBodyLevelButtonAccept"),a("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return c("window.CookieConsent.declined === true")}},new class extends w{constructor(){super("Sourcepoint-frame"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay","#sp_privacy_manager_container"],this.ccpaNotice=!1,this.ccpaPopup=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){const t=new URL(location.href);return t.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===t.hostname?(this.ccpaNotice=!0,!0):"ccpa-pm.sp-prod.net"===t.hostname?(this.ccpaPopup=!0,!0):("/index.html"===t.pathname||"/privacy-manager/index.html"===t.pathname)&&(t.searchParams.has("message_id")||t.searchParams.has("requestUUID")||t.searchParams.has("consentUUID"))}async detectPopup(){return!!this.ccpaNotice||(this.ccpaPopup?await p(".priv-save-btn",2e3):(await p(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL",2e3),!u(".sp_choice_type_9")))}async optIn(){return await p(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!a(".sp_choice_type_11")||!!a(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===location.pathname}async optOut(){if(this.ccpaPopup){const t=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");for(const e of t)e.click();const e=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.switch-bg.on");for(const t of e)t.click();return a(".priv-save-btn")}if(!this.isManagerOpen()){if(!await p(".sp_choice_type_12,.sp_choice_type_13"))return!1;if(!u(".sp_choice_type_12"))return a(".sp_choice_type_13");a(".sp_choice_type_12"),await s((()=>this.isManagerOpen()),200,100)}await p(".type-modal",2e4);try{const t=".sp_choice_type_REJECT_ALL",e=".reject-toggle",n=await Promise.race([p(t,2e3).then((t=>t?0:-1)),p(e,2e3).then((t=>t?1:-1)),p(".pm-features",2e3).then((t=>t?2:-1))]);if(0===n)return await h(1e3),a(t);1===n?a(e):2===n&&(await p(".pm-features",1e4),a(".checked > span",!0),a(".chevron"))}catch(t){}return a(".sp_choice_type_SAVE_AND_EXIT")}},new class extends w{get hasSelfTest(){return this.apiAvailable}get isIntermediate(){return!1}get isCosmetic(){return!1}constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"],this.apiAvailable=!1}async detectCmp(){return this.apiAvailable=await c('window.__cmp && typeof __cmp("getCMPData") === "object"'),!!this.apiAvailable||u("#cmpbox")}async detectPopup(){return this.apiAvailable?(await h(500),await c("!__cmp('consentStatus').userChoiceExists")):l("#cmpbox .cmpmore","any")}async optOut(){return await h(500),this.apiAvailable?await c("__cmp('setConsent', 0)"):!!a(".cmpboxbtnno")||(u(".cmpwelcomeprpsbtn")?(a(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),a(".cmpboxbtnsave"),!0):(a(".cmpboxbtncustom"),await p(".cmptblbox",2e3),a(".cmptdchoice > a[aria-checked=true]",!0),a(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return this.apiAvailable?await c("__cmp('setConsent', 1)"):a(".cmpboxbtnyes")}async test(){if(this.apiAvailable)return await c("__cmp('consentStatus').userChoiceExists")}},new class extends w{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#_evidon_banner")}async detectPopup(){return l("#_evidon_banner","any")}async optOut(){return a("#_evidon-decline-button")||(i(o(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),a("#_evidon-option-button"),await p("#evidon-prefdiag-overlay",5e3),a("#evidon-prefdiag-decline")),!0}async optIn(){return a("#_evidon-accept-button")}},new class extends w{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.onetrust-pc-dark-filter,.js-consent-banner"],this.runContext={urlPattern:"^(?!.*https://www\\.nba\\.com/)"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#onetrust-banner-sdk")}async detectPopup(){return l("#onetrust-banner-sdk","all")}async optOut(){return u("#onetrust-pc-btn-handler")?a("#onetrust-pc-btn-handler"):a(".ot-sdk-show-settings,button.js-cookie-settings"),await p("#onetrust-consent-sdk",2e3),await h(1e3),a("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await h(1e3),await p(".save-preference-btn-handler,.js-consent-save",2e3),a(".save-preference-btn-handler,.js-consent-save"),await s((()=>l("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return a("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await c("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}},new class extends w{constructor(){super("Klaro"),this.prehideSelectors=[".klaro"],this.settingsOpen=!1}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".klaro > .cookie-modal")?(this.settingsOpen=!0,!0):u(".klaro > .cookie-notice")}async detectPopup(){return l(".klaro > .cookie-notice,.klaro > .cookie-modal","any")}async optOut(){return!!a(".klaro .cn-decline")||(this.settingsOpen||(a(".klaro .cn-learn-more"),await p(".klaro > .cookie-modal",2e3),this.settingsOpen=!0),!!a(".klaro .cn-decline")||(a(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)",!0),a(".cm-btn-accept")))}async optIn(){return!!a(".klaro .cm-btn-accept-all")||(this.settingsOpen?(a(".cm-purpose:not(.cm-toggle-all) > input.half-checked",!0),a(".cm-btn-accept")):a(".klaro .cookie-notice .cm-btn-success"))}async test(){return await c("klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name])")}},new class extends w{constructor(){super("Uniconsent")}get prehideSelectors(){return[".unic",".modal:has(.unic)"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".unic .unic-box,.unic .unic-bar")}async detectPopup(){return l(".unic .unic-box,.unic .unic-bar","any")}async optOut(){if(await p(".unic button",1e3),document.querySelectorAll(".unic button").forEach((t=>{const e=t.textContent;(e.includes("Manage Options")||e.includes("Optionen verwalten"))&&t.click()})),await p(".unic input[type=checkbox]",1e3)){await p(".unic button",1e3),document.querySelectorAll(".unic input[type=checkbox]").forEach((t=>{t.checked&&t.click()}));for(const t of document.querySelectorAll(".unic button")){const e=t.textContent;for(const n of["Confirm Choices","Save Choices","Auswahl speichern"])if(e.includes(n))return t.click(),await h(500),!0}}return!1}async optIn(){return d(".unic #unic-agree")}async test(){await h(1e3);return!u(".unic .unic-box,.unic .unic-bar")}},new class extends w{constructor(){super("Conversant"),this.prehideSelectors=[".cmp-root"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".cmp-root .cmp-receptacle")}async detectPopup(){return l(".cmp-root .cmp-receptacle","any")}async optOut(){if(!await d(".cmp-main-button:not(.cmp-main-button--primary)"))return!1;if(!await p(".cmp-view-tab-tabs"))return!1;await d(".cmp-view-tab-tabs > :first-child"),await d(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");for(const t of Array.from(document.querySelectorAll(".cmp-accordion-item"))){t.querySelector(".cmp-accordion-item-title").click(),await s((()=>!!t.querySelector(".cmp-accordion-item-content.cmp-active")),10,50);const e=t.querySelector(".cmp-accordion-item-content.cmp-active");e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((t=>t.click())),e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((t=>t.click()))}return await a(".cmp-main-button:not(.cmp-main-button--primary)"),!0}async optIn(){return d(".cmp-main-button.cmp-main-button--primary")}async test(){return document.cookie.includes("cmp-data=0")}},new class extends w{constructor(){super("tiktok.com"),this.runContext={urlPattern:"tiktok"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}getShadowRoot(){const t=document.querySelector("tiktok-cookie-banner");return t?t.shadowRoot:null}async detectCmp(){return u("tiktok-cookie-banner")}async detectPopup(){return r(this.getShadowRoot().querySelector(".tiktok-cookie-banner"))}async optOut(){const t=this.getShadowRoot().querySelector(".button-wrapper button:first-child");return!!t&&(t.click(),!0)}async optIn(){const t=this.getShadowRoot().querySelector(".button-wrapper button:last-child");return!!t&&(t.click(),!0)}async test(){const t=document.cookie.match(/cookie-consent=([^;]+)/);if(!t)return!1;const e=JSON.parse(decodeURIComponent(t[1]));return Object.values(e).every((t=>"boolean"!=typeof t||!1===t))}},new class extends w{constructor(){super("airbnb"),this.runContext={urlPattern:"^https://(www\\.)?airbnb\\.[^/]+/"},this.prehideSelectors=["div[data-testid=main-cookies-banner-container]",'div:has(> div:first-child):has(> div:last-child):has(> section [data-testid="strictly-necessary-cookies"])']}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("div[data-testid=main-cookies-banner-container]")}async detectPopup(){return l("div[data-testid=main-cookies-banner-container","any")}async optOut(){let t;for(await d("div[data-testid=main-cookies-banner-container] button._snbhip0");t=document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])");)t.click();return d("button[data-testid=save-btn]")}async optIn(){return d("div[data-testid=main-cookies-banner-container] button._148dgdpk")}async test(){return await s((()=>!!document.cookie.match("OptanonAlertBoxClosed")),20,200)}}];class _{static setBase(t){_.base=t}static findElement(t,e=null,n=!1){let o=null;return o=null!=e?Array.from(e.querySelectorAll(t.selector)):null!=_.base?Array.from(_.base.querySelectorAll(t.selector)):Array.from(document.querySelectorAll(t.selector)),null!=t.textFilter&&(o=o.filter((e=>{const n=e.textContent.toLowerCase();if(Array.isArray(t.textFilter)){let e=!1;for(const o of t.textFilter)if(-1!==n.indexOf(o.toLowerCase())){e=!0;break}return e}if(null!=t.textFilter)return-1!==n.indexOf(t.textFilter.toLowerCase())}))),null!=t.styleFilters&&(o=o.filter((e=>{const n=window.getComputedStyle(e);let o=!0;for(const e of t.styleFilters){const t=n[e.option];o=e.negated?o&&t!==e.value:o&&t===e.value}return o}))),null!=t.displayFilter&&(o=o.filter((e=>t.displayFilter?0!==e.offsetHeight:0===e.offsetHeight))),null!=t.iframeFilter&&(o=o.filter((()=>t.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=t.childFilter&&(o=o.filter((e=>{const n=_.base;_.setBase(e);const o=_.find(t.childFilter);return _.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,t,e),o[0])}static find(t,e=!1){const n=[];if(null!=t.parent){const o=_.findElement(t.parent,null,e);if(null!=o){if(o instanceof Array)return o.forEach((o=>{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})})),n;{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})}}}else{const o=_.findElement(t.target,null,e);o instanceof Array?o.forEach((t=>{n.push({parent:null,target:t})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),e?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function S(t){const e=_.find(t);return"css"===t.type?!!e.target:"checkbox"===t.type?!!e.target&&e.target.checked:void 0}async function P(t,e){switch(t.type){case"click":return async function(t){const e=_.find(t);null!=e.target&&e.target.click();return x(0)}(t);case"list":return async function(t,e){for(const n of t.actions)await P(n,e)}(t,e);case"consent":return async function(t,e){for(const n of t.consents){const t=-1!==e.indexOf(n.type);if(n.matcher&&n.toggleAction){S(n.matcher)!==t&&await P(n.toggleAction)}else t?await P(n.trueAction):await P(n.falseAction)}}(t,e);case"ifcss":return async function(t,e){_.find(t).target?t.falseAction&&await P(t.falseAction,e):t.trueAction&&await P(t.trueAction,e)}(t,e);case"waitcss":return async function(t){await new Promise((e=>{let n=t.retries||10;const o=t.waitTime||250,i=()=>{const s=_.find(t);(t.negated&&s.target||!t.negated&&!s.target)&&n>0?(n-=1,setTimeout(i,o)):e()};i()}))}(t);case"foreach":return async function(t,e){const n=_.find(t,!0),o=_.base;for(const o of n)o.target&&(_.setBase(o.target),await P(t.action,e));_.setBase(o)}(t,e);case"hide":return async function(t){const e=_.find(t);e.target&&e.target.classList.add("Autoconsent-Hidden")}(t);case"slide":return async function(t){const e=_.find(t),n=_.find(t.dragTarget);if(e.target){const t=e.target.getBoundingClientRect(),o=n.target.getBoundingClientRect();let i=o.top-t.top,s=o.left-t.left;"y"===this.config.axis.toLowerCase()&&(s=0),"x"===this.config.axis.toLowerCase()&&(i=0);const r=window.screenX+t.left+t.width/2,c=window.screenY+t.top+t.height/2,a=t.left+t.width/2,u=t.top+t.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,c,a,u,!1,!1,!1,!1,0,e.target);const p=document.createEvent("MouseEvents");p.initMouseEvent("mousemove",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target);const d=document.createEvent("MouseEvents");d.initMouseEvent("mouseup",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target),e.target.dispatchEvent(l),await this.waitTimeout(10),e.target.dispatchEvent(p),await this.waitTimeout(10),e.target.dispatchEvent(d)}}(t);case"close":return async function(){window.close()}();case"wait":return async function(t){await x(t.waitTime)}(t);case"eval":return async function(t){return console.log("eval!",t.code),new Promise((e=>{try{t.async?(window.eval(t.code),setTimeout((()=>{e(window.eval("window.__consentCheckResult"))}),t.timeout||250)):e(window.eval(t.code))}catch(n){console.warn("eval error",n,t.code),e(!1)}}))}(t);default:throw"Unknown action type: "+t.type}}_.base=null;function x(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}class A{constructor(t,e){this.name=t,this.config=e,this.methods=new Map,this.runContext=y,this.isCosmetic=!1,e.methods.forEach((t=>{t.action&&this.methods.set(t.name,t.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((t=>S(t.presentMatcher))).some((t=>!!t))}async detectPopup(){return this.config.detectors.map((t=>S(t.showingMatcher))).some((t=>!!t))}async executeAction(t,e){return!this.methods.has(t)||P(this.methods.get(t),e)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}exports.createAutoCMP=k,exports.default=class{constructor(e,o=null,i=null){if(this.id=t(),this.rules=[],this.foundCmp=null,this.state={lifecycle:"loading",prehideOn:!1,findCmpAttempts:0,detectedCmps:[],detectedPopups:[],selfTest:null},n.sendContentMessage=e,this.sendContentMessage=e,this.rules=[...v],this.updateState({lifecycle:"loading"}),o)this.initialize(o,i);else{i&&this.parseRules(i);e({type:"init",url:window.location.href}),this.updateState({lifecycle:"waitingForInitResponse"})}}initialize(t,e){if(this.config=t,t.enabled){if(e&&this.parseRules(e),this.rules=function(t,e){return t.filter((t=>(!e.disabledCmps||!e.disabledCmps.includes(t.name))&&(e.enableCosmeticRules||!t.isCosmetic)))}(this.rules,t),t.enablePrehide)if(document.documentElement)this.prehideElements();else{const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.prehideElements()};window.addEventListener("DOMContentLoaded",t)}if("loading"===document.readyState){const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.start()};window.addEventListener("DOMContentLoaded",t)}else this.start();this.updateState({lifecycle:"initialized"})}}parseRules(t){Object.keys(t.consentomatic).forEach((e=>{this.addConsentomaticCMP(e,t.consentomatic[e])})),t.autoconsent.forEach((t=>{this.addCMP(t)}))}addCMP(t){this.rules.push(k(t))}addConsentomaticCMP(t,e){this.rules.push(new A(`com_${t}`,e))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){this.updateState({lifecycle:"started"});const t=await this.findCmp(this.config.detectRetries);if(this.updateState({detectedCmps:t.map((t=>t.name))}),0===t.length)return this.config.enablePrehide&&this.undoPrehide(),this.updateState({lifecycle:"nothingDetected"}),!1;this.updateState({lifecycle:"cmpDetected"});let e=await this.detectPopups(t.filter((t=>!t.isCosmetic)));if(0===e.length&&(e=await this.detectPopups(t.filter((t=>t.isCosmetic)))),0===e.length)return this.config.enablePrehide&&this.undoPrehide(),!1;if(this.updateState({lifecycle:"openPopupDetected"}),e.length>1){const t={msg:"Found multiple CMPs, check the detection rules.",cmps:e.map((t=>t.name))};this.sendContentMessage({type:"autoconsentError",details:t})}return this.foundCmp=e[0],"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn()}async findCmp(t){this.updateState({findCmpAttempts:this.state.findCmpAttempts+1});const e=[];for(const t of this.rules)try{if(!t.checkRunContext())continue;await t.detectCmp()&&(this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:t.name}),e.push(t))}catch(t){}return 0===e.length&&t>0?new Promise((e=>{setTimeout((async()=>{const n=this.findCmp(t-1);e(n)}),500)})):e}async detectPopups(t){const e=[],n=t.map((t=>this.waitForPopup(t).then((n=>{n&&(this.updateState({detectedPopups:this.state.detectedPopups.concat([t.name])}),this.sendContentMessage({type:"popupFound",cmp:t.name,url:location.href}),e.push(t))})).catch((()=>null))));return await Promise.all(n),e}async doOptOut(){let t;return this.updateState({lifecycle:"runningOptOut"}),t=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optOutSucceeded":"optOutFailed"}),t}async doOptIn(){let t;return this.updateState({lifecycle:"runningOptIn"}),t=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:!1,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optInSucceeded":"optInFailed"}),t}async doSelfTest(){let t;return t=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,url:location.href}),this.updateState({selfTest:t}),t}async waitForPopup(t,e=5,n=500){const o=await t.detectPopup();return!o&&e>0?new Promise((o=>setTimeout((()=>o(this.waitForPopup(t,e-1,n))),n))):o}prehideElements(){const t=this.rules.reduce(((t,e)=>e.prehideSelectors?[...t,...e.prehideSelectors]:t),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]);return this.updateState({prehideOn:!0}),function(t){return i(o("autoconsent-prehide"),t,"opacity")}(t)}undoPrehide(){return this.updateState({prehideOn:!1}),function(){const t=o("autoconsent-prehide");return t&&t.remove(),!!t}()}updateState(t){Object.assign(this.state,t),this.sendContentMessage({type:"report",instanceId:this.id,url:window.location.href,mainFrame:window.top===window.self,state:this.state})}async receiveMessageCallback(t){switch(t.type){case"initResp":this.initialize(t.config,t.rules);break;case"optIn":await this.doOptIn();break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(t,e){const o=n.pending.get(t);o?(n.pending.delete(t),o.timer&&window.clearTimeout(o.timer),o.resolve(e)):console.warn("no eval #",t)}(t.id,t.result)}}},exports.rules=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function t(){return crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString()}class e{constructor(t,e=1e3){this.id=t,this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),e)}}const n={pending:new Map,sendContentMessage:null};function o(t="autoconsent-css-rules"){const e=`style#${t}`,n=document.querySelector(e);if(n&&n instanceof HTMLStyleElement)return n;{const e=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=t,e.appendChild(n),n}}function i(t,e,n="display"){const o="opacity"===n?"opacity: 0":"display: none",i=`${e.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return t instanceof HTMLStyleElement&&(t.innerText+=i,e.length>0)}async function s(t,e,n){const o=await t();return!o&&e>0?new Promise((o=>{setTimeout((async()=>{o(s(t,e-1,n))}),n)})):Promise.resolve(o)}function r(t){if(!t)return!1;if(null!==t.offsetParent)return!0;{const e=window.getComputedStyle(t);if("fixed"===e.position&&"none"!==e.display)return!0}return!1}function c(o){return function(o){const i=t();n.sendContentMessage({type:"eval",id:i,code:o});const s=new e(i);return n.pending.set(s.id,s),s.promise}(o).catch((t=>!1))}function a(t,e=!1){const n=f(t);return n.length>0&&(e?n.forEach((t=>t.click())):n[0].click()),n.length>0}function u(t){return f(t).length>0}function l(t,e){const n=f(t),o=new Array(n.length);return n.forEach(((t,e)=>{o[e]=r(t)})),"none"===e?o.every((t=>!t)):0!==o.length&&("any"===e?o.some((t=>t)):o.every((t=>t)))}function p(t,e=1e4){return s((()=>f(t).length>0),Math.ceil(e/200),200)}async function d(t,e=1e4,n=!1){return await p(t,e),a(t,n)}function h(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}function m(t,e=document){if(t.startsWith("aria/"))return[];if(t.startsWith("xpath/")){const n=t.slice(6),o=document.evaluate(n,e,null,XPathResult.ANY_TYPE,null);let i=null;const s=[];for(;i=o.iterateNext();)s.push(i);return s}return t.startsWith("text/")||t.startsWith("pierce/")?[]:e.shadowRoot?Array.from(e.shadowRoot.querySelectorAll(t)):Array.from(e.querySelectorAll(t))}function f(t){return"string"==typeof t?m(t):function(t){let e,n=document;for(const o of t){if(e=m(o,n),0===e.length)return[];n=e[0]}return e}(t)}const y={main:!0,frame:!1,urlPattern:""};class w{constructor(t){this.runContext=y,this.name=t}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}get isCosmetic(){throw new Error("Not Implemented")}checkRunContext(){const t={...y,...this.runContext},e=window.top===window;return!(e&&!t.main)&&(!(!e&&!t.frame)&&!(t.urlPattern&&!window.location.href.match(t.urlPattern)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function g(t){const e=[];if(t.exists&&e.push(u(t.exists)),t.visible&&e.push(l(t.visible,t.check)),t.eval){const n=c(t.eval);e.push(n)}var n,r;if(t.waitFor&&e.push(p(t.waitFor,t.timeout)),t.waitForVisible&&e.push(function(t,e=1e4,n="any"){return s((()=>l(t,n)),Math.ceil(e/200),200)}(t.waitForVisible,t.timeout,t.check)),t.click&&e.push(a(t.click,t.all)),t.waitForThenClick&&e.push(d(t.waitForThenClick,t.timeout,t.all)),t.wait&&e.push(h(t.wait)),t.hide&&e.push((n=t.hide,r=t.method,i(o(),n,r))),t.if){if(!t.if.exists&&!t.if.visible)return console.error("invalid conditional rule",t.if),!1;await g(t.if)?e.push(C(t.then)):t.else&&e.push(C(t.else))}if(t.any){for(const e of t.any)if(await g(e))return!0;return!1}if(0===e.length)return!1;return(await Promise.all(e)).reduce(((t,e)=>t&&e),!0)}async function C(t){for(const e of t){if(!await g(e)&&!e.optional)return!1}return!0}class b extends w{constructor(t){super(t.name),this.config=t,this.runContext=t.runContext||y}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get isCosmetic(){return!!this.config.cosmetic}get prehideSelectors(){return this.config.prehideSelectors}async detectCmp(){return!!this.config.detectCmp&&async function(t){const e=t.map((t=>g(t)));return(await Promise.all(e)).every((t=>!!t))}(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&C(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&C(this.config.optOut)}async optIn(){return!!this.config.optIn&&C(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&C(this.config.openCmp)}async test(){return this.hasSelfTest?C(this.config.test):super.test()}}function k(t){return new b(t)}const v=[new class extends w{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",".truste_popframe,.truste_overlay,.truste_box_overlay,#truste-consent-track"],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}get isCosmetic(){return!1}async detectCmp(){const t=u("#truste-show-consent,#truste-consent-track");return t&&(this._shortcutButton=document.querySelector("#truste-consent-required")),t}async detectPopup(){return l("#truste-consent-content,#trustarc-banner-overlay,#truste-consent-track","all")}openFrame(){a("#truste-show-consent")}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(i(o(),[".truste_popframe",".truste_overlay",".truste_box_overlay","#truste-consent-track"]),a("#truste-show-consent"),setTimeout((()=>{o().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,a("#truste-consent-button")}async openCmp(){return!0}async test(){return await c("window && window.truste && window.truste.eu.bindMap.prefCookie === '0'")}},new class extends w{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,urlPattern:"^https://consent-pref\\.trustarc\\.com/\\?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return!0}async detectPopup(){return l("#defaultpreferencemanager","any")&&l(".mainContent","any")}async navigateToSettings(){return await s((async()=>u(".shp")||l(".advance","any")||u(".switch span:first-child")),10,500),u(".shp")&&a(".shp"),await p(".prefPanel",5e3),l(".advance","any")&&a(".advance"),await s((()=>l(".switch span:first-child","any")),5,1e3)}async optOut(){return await s((()=>"complete"===document.readyState),20,100),await p(".mainContent[aria-hidden=false]",5e3),!!a(".rejectAll")||(u(".prefPanel")&&await p('.prefPanel[style="visibility: visible;"]',3e3),a("#catDetails0")?(a(".submit"),!0):(a(".required")||(await this.navigateToSettings(),a(".switch span:nth-child(1):not(.active)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0))}async optIn(){return a(".call")||(await this.navigateToSettings(),a(".switch span:nth-child(2)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0}},new class extends w{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return u("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return a(".cookie-alert-extended-detail-link")?(await p(".cookie-alert-configuration",2e3),a(".cookie-alert-configuration-input:checked",!0),a(".cookie-alert-extended-button-secondary"),!0):u("#dtcookie-container")?a(".h-dtcookie-decline"):(a(".cookiebot__button--settings")||a("#CybotCookiebotDialogBodyButtonDecline")||(a(".cookiebanner__link--details"),a('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),a("#CybotCookiebotDialogBodyButtonDecline"),a("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),u("#CybotCookiebotDialogBodyButtonAcceptSelected")?a("#CybotCookiebotDialogBodyButtonAcceptSelected"):a("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await c("window.CookieConsent.hasResponse !== true")&&(await c("window.Cookiebot.dialog.submitConsent()"),await h(500)),u("#cb-confirmedSettings")&&await c("endCookieProcess()")),!0)}async optIn(){return u("#dtcookie-container")?a(".h-dtcookie-accept"):(a(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),a("#CybotCookiebotDialogBodyLevelButtonAccept"),a("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return c("window.CookieConsent.declined === true")}},new class extends w{constructor(){super("Sourcepoint-frame"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay","#sp_privacy_manager_container"],this.ccpaNotice=!1,this.ccpaPopup=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){const t=new URL(location.href);return t.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===t.hostname?(this.ccpaNotice=!0,!0):"ccpa-pm.sp-prod.net"===t.hostname?(this.ccpaPopup=!0,!0):("/index.html"===t.pathname||"/privacy-manager/index.html"===t.pathname)&&(t.searchParams.has("message_id")||t.searchParams.has("requestUUID")||t.searchParams.has("consentUUID"))}async detectPopup(){return!!this.ccpaNotice||(this.ccpaPopup?await p(".priv-save-btn",2e3):(await p(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL",2e3),!u(".sp_choice_type_9")))}async optIn(){return await p(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!a(".sp_choice_type_11")||!!a(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===location.pathname}async optOut(){if(this.ccpaPopup){const t=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");for(const e of t)e.click();const e=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.switch-bg.on");for(const t of e)t.click();return a(".priv-save-btn")}if(!this.isManagerOpen()){if(!await p(".sp_choice_type_12,.sp_choice_type_13"))return!1;if(!u(".sp_choice_type_12"))return a(".sp_choice_type_13");a(".sp_choice_type_12"),await s((()=>this.isManagerOpen()),200,100)}await p(".type-modal",2e4);try{const t=".sp_choice_type_REJECT_ALL",e=".reject-toggle",n=await Promise.race([p(t,2e3).then((t=>t?0:-1)),p(e,2e3).then((t=>t?1:-1)),p(".pm-features",2e3).then((t=>t?2:-1))]);if(0===n)return await h(1e3),a(t);1===n?a(e):2===n&&(await p(".pm-features",1e4),a(".checked > span",!0),a(".chevron"))}catch(t){}return a(".sp_choice_type_SAVE_AND_EXIT")}},new class extends w{get hasSelfTest(){return this.apiAvailable}get isIntermediate(){return!1}get isCosmetic(){return!1}constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"],this.apiAvailable=!1}async detectCmp(){return this.apiAvailable=await c('window.__cmp && typeof __cmp("getCMPData") === "object"'),!!this.apiAvailable||u("#cmpbox")}async detectPopup(){return this.apiAvailable?(await h(500),await c("!__cmp('consentStatus').userChoiceExists")):l("#cmpbox .cmpmore","any")}async optOut(){return await h(500),this.apiAvailable?await c("__cmp('setConsent', 0)"):!!a(".cmpboxbtnno")||(u(".cmpwelcomeprpsbtn")?(a(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),a(".cmpboxbtnsave"),!0):(a(".cmpboxbtncustom"),await p(".cmptblbox",2e3),a(".cmptdchoice > a[aria-checked=true]",!0),a(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return this.apiAvailable?await c("__cmp('setConsent', 1)"):a(".cmpboxbtnyes")}async test(){if(this.apiAvailable)return await c("__cmp('consentStatus').userChoiceExists")}},new class extends w{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#_evidon_banner")}async detectPopup(){return l("#_evidon_banner","any")}async optOut(){return a("#_evidon-decline-button")||(i(o(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),a("#_evidon-option-button"),await p("#evidon-prefdiag-overlay",5e3),a("#evidon-prefdiag-decline")),!0}async optIn(){return a("#_evidon-accept-button")}},new class extends w{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.onetrust-pc-dark-filter,.js-consent-banner"],this.runContext={urlPattern:"^(?!.*https://www\\.nba\\.com/)"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#onetrust-banner-sdk")}async detectPopup(){return l("#onetrust-banner-sdk","all")}async optOut(){return u("#onetrust-pc-btn-handler")?a("#onetrust-pc-btn-handler"):a(".ot-sdk-show-settings,button.js-cookie-settings"),await p("#onetrust-consent-sdk",2e3),await h(1e3),a("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await h(1e3),await p(".save-preference-btn-handler,.js-consent-save",2e3),a(".save-preference-btn-handler,.js-consent-save"),await s((()=>l("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return a("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await c("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}},new class extends w{constructor(){super("Klaro"),this.prehideSelectors=[".klaro"],this.settingsOpen=!1}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".klaro > .cookie-modal")?(this.settingsOpen=!0,!0):u(".klaro > .cookie-notice")}async detectPopup(){return l(".klaro > .cookie-notice,.klaro > .cookie-modal","any")}async optOut(){return!!a(".klaro .cn-decline")||(this.settingsOpen||(a(".klaro .cn-learn-more"),await p(".klaro > .cookie-modal",2e3),this.settingsOpen=!0),!!a(".klaro .cn-decline")||(a(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)",!0),a(".cm-btn-accept")))}async optIn(){return!!a(".klaro .cm-btn-accept-all")||(this.settingsOpen?(a(".cm-purpose:not(.cm-toggle-all) > input.half-checked",!0),a(".cm-btn-accept")):a(".klaro .cookie-notice .cm-btn-success"))}async test(){return await c("klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name])")}},new class extends w{constructor(){super("Uniconsent")}get prehideSelectors(){return[".unic",".modal:has(.unic)"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".unic .unic-box,.unic .unic-bar")}async detectPopup(){return l(".unic .unic-box,.unic .unic-bar","any")}async optOut(){if(await p(".unic button",1e3),document.querySelectorAll(".unic button").forEach((t=>{const e=t.textContent;(e.includes("Manage Options")||e.includes("Optionen verwalten"))&&t.click()})),await p(".unic input[type=checkbox]",1e3)){await p(".unic button",1e3),document.querySelectorAll(".unic input[type=checkbox]").forEach((t=>{t.checked&&t.click()}));for(const t of document.querySelectorAll(".unic button")){const e=t.textContent;for(const n of["Confirm Choices","Save Choices","Auswahl speichern"])if(e.includes(n))return t.click(),await h(500),!0}}return!1}async optIn(){return d(".unic #unic-agree")}async test(){await h(1e3);return!u(".unic .unic-box,.unic .unic-bar")}},new class extends w{constructor(){super("Conversant"),this.prehideSelectors=[".cmp-root"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".cmp-root .cmp-receptacle")}async detectPopup(){return l(".cmp-root .cmp-receptacle","any")}async optOut(){if(!await d(".cmp-main-button:not(.cmp-main-button--primary)"))return!1;if(!await p(".cmp-view-tab-tabs"))return!1;await d(".cmp-view-tab-tabs > :first-child"),await d(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");for(const t of Array.from(document.querySelectorAll(".cmp-accordion-item"))){t.querySelector(".cmp-accordion-item-title").click(),await s((()=>!!t.querySelector(".cmp-accordion-item-content.cmp-active")),10,50);const e=t.querySelector(".cmp-accordion-item-content.cmp-active");e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((t=>t.click())),e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((t=>t.click()))}return await a(".cmp-main-button:not(.cmp-main-button--primary)"),!0}async optIn(){return d(".cmp-main-button.cmp-main-button--primary")}async test(){return document.cookie.includes("cmp-data=0")}},new class extends w{constructor(){super("tiktok.com"),this.runContext={urlPattern:"tiktok"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}getShadowRoot(){const t=document.querySelector("tiktok-cookie-banner");return t?t.shadowRoot:null}async detectCmp(){return u("tiktok-cookie-banner")}async detectPopup(){return r(this.getShadowRoot().querySelector(".tiktok-cookie-banner"))}async optOut(){const t=this.getShadowRoot().querySelector(".button-wrapper button:first-child");return!!t&&(t.click(),!0)}async optIn(){const t=this.getShadowRoot().querySelector(".button-wrapper button:last-child");return!!t&&(t.click(),!0)}async test(){const t=document.cookie.match(/cookie-consent=([^;]+)/);if(!t)return!1;const e=JSON.parse(decodeURIComponent(t[1]));return Object.values(e).every((t=>"boolean"!=typeof t||!1===t))}},new class extends w{constructor(){super("airbnb"),this.runContext={urlPattern:"^https://(www\\.)?airbnb\\.[^/]+/"},this.prehideSelectors=["div[data-testid=main-cookies-banner-container]",'div:has(> div:first-child):has(> div:last-child):has(> section [data-testid="strictly-necessary-cookies"])']}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("div[data-testid=main-cookies-banner-container]")}async detectPopup(){return l("div[data-testid=main-cookies-banner-container","any")}async optOut(){let t;for(await d("div[data-testid=main-cookies-banner-container] button._snbhip0");t=document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])");)t.click();return d("button[data-testid=save-btn]")}async optIn(){return d("div[data-testid=main-cookies-banner-container] button._148dgdpk")}async test(){return await s((()=>!!document.cookie.match("OptanonAlertBoxClosed")),20,200)}}];class _{static setBase(t){_.base=t}static findElement(t,e=null,n=!1){let o=null;return o=null!=e?Array.from(e.querySelectorAll(t.selector)):null!=_.base?Array.from(_.base.querySelectorAll(t.selector)):Array.from(document.querySelectorAll(t.selector)),null!=t.textFilter&&(o=o.filter((e=>{const n=e.textContent.toLowerCase();if(Array.isArray(t.textFilter)){let e=!1;for(const o of t.textFilter)if(-1!==n.indexOf(o.toLowerCase())){e=!0;break}return e}if(null!=t.textFilter)return-1!==n.indexOf(t.textFilter.toLowerCase())}))),null!=t.styleFilters&&(o=o.filter((e=>{const n=window.getComputedStyle(e);let o=!0;for(const e of t.styleFilters){const t=n[e.option];o=e.negated?o&&t!==e.value:o&&t===e.value}return o}))),null!=t.displayFilter&&(o=o.filter((e=>t.displayFilter?0!==e.offsetHeight:0===e.offsetHeight))),null!=t.iframeFilter&&(o=o.filter((()=>t.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=t.childFilter&&(o=o.filter((e=>{const n=_.base;_.setBase(e);const o=_.find(t.childFilter);return _.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,t,e),o[0])}static find(t,e=!1){const n=[];if(null!=t.parent){const o=_.findElement(t.parent,null,e);if(null!=o){if(o instanceof Array)return o.forEach((o=>{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})})),n;{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})}}}else{const o=_.findElement(t.target,null,e);o instanceof Array?o.forEach((t=>{n.push({parent:null,target:t})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),e?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function S(t){const e=_.find(t);return"css"===t.type?!!e.target:"checkbox"===t.type?!!e.target&&e.target.checked:void 0}async function P(t,e){switch(t.type){case"click":return async function(t){const e=_.find(t);null!=e.target&&e.target.click();return x(0)}(t);case"list":return async function(t,e){for(const n of t.actions)await P(n,e)}(t,e);case"consent":return async function(t,e){for(const n of t.consents){const t=-1!==e.indexOf(n.type);if(n.matcher&&n.toggleAction){S(n.matcher)!==t&&await P(n.toggleAction)}else t?await P(n.trueAction):await P(n.falseAction)}}(t,e);case"ifcss":return async function(t,e){_.find(t).target?t.falseAction&&await P(t.falseAction,e):t.trueAction&&await P(t.trueAction,e)}(t,e);case"waitcss":return async function(t){await new Promise((e=>{let n=t.retries||10;const o=t.waitTime||250,i=()=>{const s=_.find(t);(t.negated&&s.target||!t.negated&&!s.target)&&n>0?(n-=1,setTimeout(i,o)):e()};i()}))}(t);case"foreach":return async function(t,e){const n=_.find(t,!0),o=_.base;for(const o of n)o.target&&(_.setBase(o.target),await P(t.action,e));_.setBase(o)}(t,e);case"hide":return async function(t){const e=_.find(t);e.target&&e.target.classList.add("Autoconsent-Hidden")}(t);case"slide":return async function(t){const e=_.find(t),n=_.find(t.dragTarget);if(e.target){const t=e.target.getBoundingClientRect(),o=n.target.getBoundingClientRect();let i=o.top-t.top,s=o.left-t.left;"y"===this.config.axis.toLowerCase()&&(s=0),"x"===this.config.axis.toLowerCase()&&(i=0);const r=window.screenX+t.left+t.width/2,c=window.screenY+t.top+t.height/2,a=t.left+t.width/2,u=t.top+t.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,c,a,u,!1,!1,!1,!1,0,e.target);const p=document.createEvent("MouseEvents");p.initMouseEvent("mousemove",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target);const d=document.createEvent("MouseEvents");d.initMouseEvent("mouseup",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target),e.target.dispatchEvent(l),await this.waitTimeout(10),e.target.dispatchEvent(p),await this.waitTimeout(10),e.target.dispatchEvent(d)}}(t);case"close":return async function(){window.close()}();case"wait":return async function(t){await x(t.waitTime)}(t);case"eval":return async function(t){return console.log("eval!",t.code),new Promise((e=>{try{t.async?(window.eval(t.code),setTimeout((()=>{e(window.eval("window.__consentCheckResult"))}),t.timeout||250)):e(window.eval(t.code))}catch(n){console.warn("eval error",n,t.code),e(!1)}}))}(t);default:throw"Unknown action type: "+t.type}}_.base=null;function x(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}class A{constructor(t,e){this.name=t,this.config=e,this.methods=new Map,this.runContext=y,this.isCosmetic=!1,e.methods.forEach((t=>{t.action&&this.methods.set(t.name,t.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((t=>S(t.presentMatcher))).some((t=>!!t))}async detectPopup(){return this.config.detectors.map((t=>S(t.showingMatcher))).some((t=>!!t))}async executeAction(t,e){return!this.methods.has(t)||P(this.methods.get(t),e)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}exports.createAutoCMP=k,exports.default=class{constructor(e,o=null,i=null){if(this.id=t(),this.rules=[],this.foundCmp=null,this.state={lifecycle:"loading",prehideOn:!1,findCmpAttempts:0,detectedCmps:[],detectedPopups:[],selfTest:null},n.sendContentMessage=e,this.sendContentMessage=e,this.rules=[...v],this.updateState({lifecycle:"loading"}),o)this.initialize(o,i);else{i&&this.parseRules(i);e({type:"init",url:window.location.href}),this.updateState({lifecycle:"waitingForInitResponse"})}}initialize(t,e){if(this.config=t,t.enabled){if(e&&this.parseRules(e),this.rules=function(t,e){return t.filter((t=>(!e.disabledCmps||!e.disabledCmps.includes(t.name))&&(e.enableCosmeticRules||!t.isCosmetic)))}(this.rules,t),t.enablePrehide)if(document.documentElement)this.prehideElements();else{const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.prehideElements()};window.addEventListener("DOMContentLoaded",t)}if("loading"===document.readyState){const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.start()};window.addEventListener("DOMContentLoaded",t)}else this.start();this.updateState({lifecycle:"initialized"})}}parseRules(t){Object.keys(t.consentomatic).forEach((e=>{this.addConsentomaticCMP(e,t.consentomatic[e])})),t.autoconsent.forEach((t=>{this.addCMP(t)}))}addCMP(t){this.rules.push(k(t))}addConsentomaticCMP(t,e){this.rules.push(new A(`com_${t}`,e))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){this.updateState({lifecycle:"started"});const t=await this.findCmp(this.config.detectRetries);if(this.updateState({detectedCmps:t.map((t=>t.name))}),0===t.length)return this.config.enablePrehide&&this.undoPrehide(),this.updateState({lifecycle:"nothingDetected"}),!1;this.updateState({lifecycle:"cmpDetected"});let e=await this.detectPopups(t.filter((t=>!t.isCosmetic)));if(0===e.length&&(e=await this.detectPopups(t.filter((t=>t.isCosmetic)))),0===e.length)return this.config.enablePrehide&&this.undoPrehide(),!1;if(this.updateState({lifecycle:"openPopupDetected"}),e.length>1){const t={msg:"Found multiple CMPs, check the detection rules.",cmps:e.map((t=>t.name))};this.sendContentMessage({type:"autoconsentError",details:t})}return this.foundCmp=e[0],"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn()}async findCmp(t){this.updateState({findCmpAttempts:this.state.findCmpAttempts+1});const e=[];for(const t of this.rules)try{if(!t.checkRunContext())continue;await t.detectCmp()&&(this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:t.name}),e.push(t))}catch(t){}return 0===e.length&&t>0?(await h(500),this.findCmp(t-1)):e}async detectPopups(t){const e=[],n=t.map((t=>this.waitForPopup(t).then((n=>{n&&(this.updateState({detectedPopups:this.state.detectedPopups.concat([t.name])}),this.sendContentMessage({type:"popupFound",cmp:t.name,url:location.href}),e.push(t))})).catch((()=>null))));return await Promise.all(n),e}async doOptOut(){let t;return this.updateState({lifecycle:"runningOptOut"}),t=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optOutSucceeded":"optOutFailed"}),t}async doOptIn(){let t;return this.updateState({lifecycle:"runningOptIn"}),t=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:!1,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optInSucceeded":"optInFailed"}),t}async doSelfTest(){let t;return t=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,url:location.href}),this.updateState({selfTest:t}),t}async waitForPopup(t,e=5,n=500){const o=await t.detectPopup();return!o&&e>0?(await h(n),this.waitForPopup(t,e-1,n)):o}prehideElements(){const t=this.rules.reduce(((t,e)=>e.prehideSelectors?[...t,...e.prehideSelectors]:t),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]);return this.updateState({prehideOn:!0}),setTimeout((()=>{this.config.enablePrehide&&this.state.prehideOn&&!["runningOptOut","runningOptIn"].includes(this.state.lifecycle)&&this.undoPrehide()}),this.config.prehideTimeout||2e3),function(t){return i(o("autoconsent-prehide"),t,"opacity")}(t)}undoPrehide(){return this.updateState({prehideOn:!1}),function(){const t=o("autoconsent-prehide");return t&&t.remove(),!!t}()}updateState(t){Object.assign(this.state,t),this.sendContentMessage({type:"report",instanceId:this.id,url:window.location.href,mainFrame:window.top===window.self,state:this.state})}async receiveMessageCallback(t){switch(t.type){case"initResp":this.initialize(t.config,t.rules);break;case"optIn":await this.doOptIn();break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(t,e){const o=n.pending.get(t);o?(n.pending.delete(t),o.timer&&window.clearTimeout(o.timer),o.resolve(e)):console.warn("no eval #",t)}(t.id,t.result)}}},exports.rules=v;
|
package/dist/autoconsent.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(){return crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString()}class e{constructor(t,e=1e3){this.id=t,this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),e)}}const n={pending:new Map,sendContentMessage:null};function o(t="autoconsent-css-rules"){const e=`style#${t}`,n=document.querySelector(e);if(n&&n instanceof HTMLStyleElement)return n;{const e=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=t,e.appendChild(n),n}}function i(t,e,n="display"){const o="opacity"===n?"opacity: 0":"display: none",i=`${e.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return t instanceof HTMLStyleElement&&(t.innerText+=i,e.length>0)}async function s(t,e,n){const o=await t();return!o&&e>0?new Promise((o=>{setTimeout((async()=>{o(s(t,e-1,n))}),n)})):Promise.resolve(o)}function r(t){if(!t)return!1;if(null!==t.offsetParent)return!0;{const e=window.getComputedStyle(t);if("fixed"===e.position&&"none"!==e.display)return!0}return!1}function c(o){return function(o){const i=t();n.sendContentMessage({type:"eval",id:i,code:o});const s=new e(i);return n.pending.set(s.id,s),s.promise}(o).catch((t=>!1))}function a(t,e=!1){const n=f(t);return n.length>0&&(e?n.forEach((t=>t.click())):n[0].click()),n.length>0}function u(t){return f(t).length>0}function l(t,e){const n=f(t),o=new Array(n.length);return n.forEach(((t,e)=>{o[e]=r(t)})),"none"===e?o.every((t=>!t)):0!==o.length&&("any"===e?o.some((t=>t)):o.every((t=>t)))}function p(t,e=1e4){return s((()=>f(t).length>0),Math.ceil(e/200),200)}async function d(t,e=1e4,n=!1){return await p(t,e),a(t,n)}function h(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}function m(t,e=document){if(t.startsWith("aria/"))return[];if(t.startsWith("xpath/")){const n=t.slice(6),o=document.evaluate(n,e,null,XPathResult.ANY_TYPE,null);let i=null;const s=[];for(;i=o.iterateNext();)s.push(i);return s}return t.startsWith("text/")||t.startsWith("pierce/")?[]:e.shadowRoot?Array.from(e.shadowRoot.querySelectorAll(t)):Array.from(e.querySelectorAll(t))}function f(t){return"string"==typeof t?m(t):function(t){let e,n=document;for(const o of t){if(e=m(o,n),0===e.length)return[];n=e[0]}return e}(t)}const y={main:!0,frame:!1,urlPattern:""};class w{constructor(t){this.runContext=y,this.name=t}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}get isCosmetic(){throw new Error("Not Implemented")}checkRunContext(){const t={...y,...this.runContext},e=window.top===window;return!(e&&!t.main)&&(!(!e&&!t.frame)&&!(t.urlPattern&&!window.location.href.match(t.urlPattern)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function g(t){const e=[];if(t.exists&&e.push(u(t.exists)),t.visible&&e.push(l(t.visible,t.check)),t.eval){const n=c(t.eval);e.push(n)}var n,r;if(t.waitFor&&e.push(p(t.waitFor,t.timeout)),t.waitForVisible&&e.push(function(t,e=1e4,n="any"){return s((()=>l(t,n)),Math.ceil(e/200),200)}(t.waitForVisible,t.timeout,t.check)),t.click&&e.push(a(t.click,t.all)),t.waitForThenClick&&e.push(d(t.waitForThenClick,t.timeout,t.all)),t.wait&&e.push(h(t.wait)),t.hide&&e.push((n=t.hide,r=t.method,i(o(),n,r))),t.if){if(!t.if.exists&&!t.if.visible)return console.error("invalid conditional rule",t.if),!1;await g(t.if)?e.push(C(t.then)):t.else&&e.push(C(t.else))}if(t.any){for(const e of t.any)if(await g(e))return!0;return!1}if(0===e.length)return!1;return(await Promise.all(e)).reduce(((t,e)=>t&&e),!0)}async function C(t){for(const e of t){if(!await g(e)&&!e.optional)return!1}return!0}class b extends w{constructor(t){super(t.name),this.config=t,this.runContext=t.runContext||y}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get isCosmetic(){return!!this.config.cosmetic}get prehideSelectors(){return this.config.prehideSelectors}async detectCmp(){return!!this.config.detectCmp&&async function(t){const e=t.map((t=>g(t)));return(await Promise.all(e)).every((t=>!!t))}(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&C(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&C(this.config.optOut)}async optIn(){return!!this.config.optIn&&C(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&C(this.config.openCmp)}async test(){return this.hasSelfTest?C(this.config.test):super.test()}}function k(t){return new b(t)}const v=[new class extends w{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",".truste_popframe,.truste_overlay,.truste_box_overlay,#truste-consent-track"],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}get isCosmetic(){return!1}async detectCmp(){const t=u("#truste-show-consent,#truste-consent-track");return t&&(this._shortcutButton=document.querySelector("#truste-consent-required")),t}async detectPopup(){return l("#truste-consent-content,#trustarc-banner-overlay,#truste-consent-track","all")}openFrame(){a("#truste-show-consent")}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(i(o(),[".truste_popframe",".truste_overlay",".truste_box_overlay","#truste-consent-track"]),a("#truste-show-consent"),setTimeout((()=>{o().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,a("#truste-consent-button")}async openCmp(){return!0}async test(){return await c("window && window.truste && window.truste.eu.bindMap.prefCookie === '0'")}},new class extends w{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,urlPattern:"^https://consent-pref\\.trustarc\\.com/\\?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return!0}async detectPopup(){return l("#defaultpreferencemanager","any")&&l(".mainContent","any")}async navigateToSettings(){return await s((async()=>u(".shp")||l(".advance","any")||u(".switch span:first-child")),10,500),u(".shp")&&a(".shp"),await p(".prefPanel",5e3),l(".advance","any")&&a(".advance"),await s((()=>l(".switch span:first-child","any")),5,1e3)}async optOut(){return await s((()=>"complete"===document.readyState),20,100),await p(".mainContent[aria-hidden=false]",5e3),!!a(".rejectAll")||(u(".prefPanel")&&await p('.prefPanel[style="visibility: visible;"]',3e3),a("#catDetails0")?(a(".submit"),!0):(a(".required")||(await this.navigateToSettings(),a(".switch span:nth-child(1):not(.active)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0))}async optIn(){return a(".call")||(await this.navigateToSettings(),a(".switch span:nth-child(2)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0}},new class extends w{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return u("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return a(".cookie-alert-extended-detail-link")?(await p(".cookie-alert-configuration",2e3),a(".cookie-alert-configuration-input:checked",!0),a(".cookie-alert-extended-button-secondary"),!0):u("#dtcookie-container")?a(".h-dtcookie-decline"):(a(".cookiebot__button--settings")||a("#CybotCookiebotDialogBodyButtonDecline")||(a(".cookiebanner__link--details"),a('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),a("#CybotCookiebotDialogBodyButtonDecline"),a("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),u("#CybotCookiebotDialogBodyButtonAcceptSelected")?a("#CybotCookiebotDialogBodyButtonAcceptSelected"):a("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await c("window.CookieConsent.hasResponse !== true")&&(await c("window.Cookiebot.dialog.submitConsent()"),await h(500)),u("#cb-confirmedSettings")&&await c("endCookieProcess()")),!0)}async optIn(){return u("#dtcookie-container")?a(".h-dtcookie-accept"):(a(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),a("#CybotCookiebotDialogBodyLevelButtonAccept"),a("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return c("window.CookieConsent.declined === true")}},new class extends w{constructor(){super("Sourcepoint-frame"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay","#sp_privacy_manager_container"],this.ccpaNotice=!1,this.ccpaPopup=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){const t=new URL(location.href);return t.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===t.hostname?(this.ccpaNotice=!0,!0):"ccpa-pm.sp-prod.net"===t.hostname?(this.ccpaPopup=!0,!0):("/index.html"===t.pathname||"/privacy-manager/index.html"===t.pathname)&&(t.searchParams.has("message_id")||t.searchParams.has("requestUUID")||t.searchParams.has("consentUUID"))}async detectPopup(){return!!this.ccpaNotice||(this.ccpaPopup?await p(".priv-save-btn",2e3):(await p(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL",2e3),!u(".sp_choice_type_9")))}async optIn(){return await p(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!a(".sp_choice_type_11")||!!a(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===location.pathname}async optOut(){if(this.ccpaPopup){const t=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");for(const e of t)e.click();const e=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.switch-bg.on");for(const t of e)t.click();return a(".priv-save-btn")}if(!this.isManagerOpen()){if(!await p(".sp_choice_type_12,.sp_choice_type_13"))return!1;if(!u(".sp_choice_type_12"))return a(".sp_choice_type_13");a(".sp_choice_type_12"),await s((()=>this.isManagerOpen()),200,100)}await p(".type-modal",2e4);try{const t=".sp_choice_type_REJECT_ALL",e=".reject-toggle",n=await Promise.race([p(t,2e3).then((t=>t?0:-1)),p(e,2e3).then((t=>t?1:-1)),p(".pm-features",2e3).then((t=>t?2:-1))]);if(0===n)return await h(1e3),a(t);1===n?a(e):2===n&&(await p(".pm-features",1e4),a(".checked > span",!0),a(".chevron"))}catch(t){}return a(".sp_choice_type_SAVE_AND_EXIT")}},new class extends w{get hasSelfTest(){return this.apiAvailable}get isIntermediate(){return!1}get isCosmetic(){return!1}constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"],this.apiAvailable=!1}async detectCmp(){return this.apiAvailable=await c('window.__cmp && typeof __cmp("getCMPData") === "object"'),!!this.apiAvailable||u("#cmpbox")}async detectPopup(){return this.apiAvailable?(await h(500),await c("!__cmp('consentStatus').userChoiceExists")):l("#cmpbox .cmpmore","any")}async optOut(){return await h(500),this.apiAvailable?await c("__cmp('setConsent', 0)"):!!a(".cmpboxbtnno")||(u(".cmpwelcomeprpsbtn")?(a(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),a(".cmpboxbtnsave"),!0):(a(".cmpboxbtncustom"),await p(".cmptblbox",2e3),a(".cmptdchoice > a[aria-checked=true]",!0),a(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return this.apiAvailable?await c("__cmp('setConsent', 1)"):a(".cmpboxbtnyes")}async test(){if(this.apiAvailable)return await c("__cmp('consentStatus').userChoiceExists")}},new class extends w{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#_evidon_banner")}async detectPopup(){return l("#_evidon_banner","any")}async optOut(){return a("#_evidon-decline-button")||(i(o(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),a("#_evidon-option-button"),await p("#evidon-prefdiag-overlay",5e3),a("#evidon-prefdiag-decline")),!0}async optIn(){return a("#_evidon-accept-button")}},new class extends w{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.onetrust-pc-dark-filter,.js-consent-banner"],this.runContext={urlPattern:"^(?!.*https://www\\.nba\\.com/)"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#onetrust-banner-sdk")}async detectPopup(){return l("#onetrust-banner-sdk","all")}async optOut(){return u("#onetrust-pc-btn-handler")?a("#onetrust-pc-btn-handler"):a(".ot-sdk-show-settings,button.js-cookie-settings"),await p("#onetrust-consent-sdk",2e3),await h(1e3),a("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await h(1e3),await p(".save-preference-btn-handler,.js-consent-save",2e3),a(".save-preference-btn-handler,.js-consent-save"),await s((()=>l("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return a("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await c("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}},new class extends w{constructor(){super("Klaro"),this.prehideSelectors=[".klaro"],this.settingsOpen=!1}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".klaro > .cookie-modal")?(this.settingsOpen=!0,!0):u(".klaro > .cookie-notice")}async detectPopup(){return l(".klaro > .cookie-notice,.klaro > .cookie-modal","any")}async optOut(){return!!a(".klaro .cn-decline")||(this.settingsOpen||(a(".klaro .cn-learn-more"),await p(".klaro > .cookie-modal",2e3),this.settingsOpen=!0),!!a(".klaro .cn-decline")||(a(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)",!0),a(".cm-btn-accept")))}async optIn(){return!!a(".klaro .cm-btn-accept-all")||(this.settingsOpen?(a(".cm-purpose:not(.cm-toggle-all) > input.half-checked",!0),a(".cm-btn-accept")):a(".klaro .cookie-notice .cm-btn-success"))}async test(){return await c("klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name])")}},new class extends w{constructor(){super("Uniconsent")}get prehideSelectors(){return[".unic",".modal:has(.unic)"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".unic .unic-box,.unic .unic-bar")}async detectPopup(){return l(".unic .unic-box,.unic .unic-bar","any")}async optOut(){if(await p(".unic button",1e3),document.querySelectorAll(".unic button").forEach((t=>{const e=t.textContent;(e.includes("Manage Options")||e.includes("Optionen verwalten"))&&t.click()})),await p(".unic input[type=checkbox]",1e3)){await p(".unic button",1e3),document.querySelectorAll(".unic input[type=checkbox]").forEach((t=>{t.checked&&t.click()}));for(const t of document.querySelectorAll(".unic button")){const e=t.textContent;for(const n of["Confirm Choices","Save Choices","Auswahl speichern"])if(e.includes(n))return t.click(),await h(500),!0}}return!1}async optIn(){return d(".unic #unic-agree")}async test(){await h(1e3);return!u(".unic .unic-box,.unic .unic-bar")}},new class extends w{constructor(){super("Conversant"),this.prehideSelectors=[".cmp-root"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".cmp-root .cmp-receptacle")}async detectPopup(){return l(".cmp-root .cmp-receptacle","any")}async optOut(){if(!await d(".cmp-main-button:not(.cmp-main-button--primary)"))return!1;if(!await p(".cmp-view-tab-tabs"))return!1;await d(".cmp-view-tab-tabs > :first-child"),await d(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");for(const t of Array.from(document.querySelectorAll(".cmp-accordion-item"))){t.querySelector(".cmp-accordion-item-title").click(),await s((()=>!!t.querySelector(".cmp-accordion-item-content.cmp-active")),10,50);const e=t.querySelector(".cmp-accordion-item-content.cmp-active");e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((t=>t.click())),e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((t=>t.click()))}return await a(".cmp-main-button:not(.cmp-main-button--primary)"),!0}async optIn(){return d(".cmp-main-button.cmp-main-button--primary")}async test(){return document.cookie.includes("cmp-data=0")}},new class extends w{constructor(){super("tiktok.com"),this.runContext={urlPattern:"tiktok"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}getShadowRoot(){const t=document.querySelector("tiktok-cookie-banner");return t?t.shadowRoot:null}async detectCmp(){return u("tiktok-cookie-banner")}async detectPopup(){return r(this.getShadowRoot().querySelector(".tiktok-cookie-banner"))}async optOut(){const t=this.getShadowRoot().querySelector(".button-wrapper button:first-child");return!!t&&(t.click(),!0)}async optIn(){const t=this.getShadowRoot().querySelector(".button-wrapper button:last-child");return!!t&&(t.click(),!0)}async test(){const t=document.cookie.match(/cookie-consent=([^;]+)/);if(!t)return!1;const e=JSON.parse(decodeURIComponent(t[1]));return Object.values(e).every((t=>"boolean"!=typeof t||!1===t))}},new class extends w{constructor(){super("airbnb"),this.runContext={urlPattern:"^https://(www\\.)?airbnb\\.[^/]+/"},this.prehideSelectors=["div[data-testid=main-cookies-banner-container]",'div:has(> div:first-child):has(> div:last-child):has(> section [data-testid="strictly-necessary-cookies"])']}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("div[data-testid=main-cookies-banner-container]")}async detectPopup(){return l("div[data-testid=main-cookies-banner-container","any")}async optOut(){let t;for(await d("div[data-testid=main-cookies-banner-container] button._snbhip0");t=document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])");)t.click();return d("button[data-testid=save-btn]")}async optIn(){return d("div[data-testid=main-cookies-banner-container] button._148dgdpk")}async test(){return await s((()=>!!document.cookie.match("OptanonAlertBoxClosed")),20,200)}}];class _{static setBase(t){_.base=t}static findElement(t,e=null,n=!1){let o=null;return o=null!=e?Array.from(e.querySelectorAll(t.selector)):null!=_.base?Array.from(_.base.querySelectorAll(t.selector)):Array.from(document.querySelectorAll(t.selector)),null!=t.textFilter&&(o=o.filter((e=>{const n=e.textContent.toLowerCase();if(Array.isArray(t.textFilter)){let e=!1;for(const o of t.textFilter)if(-1!==n.indexOf(o.toLowerCase())){e=!0;break}return e}if(null!=t.textFilter)return-1!==n.indexOf(t.textFilter.toLowerCase())}))),null!=t.styleFilters&&(o=o.filter((e=>{const n=window.getComputedStyle(e);let o=!0;for(const e of t.styleFilters){const t=n[e.option];o=e.negated?o&&t!==e.value:o&&t===e.value}return o}))),null!=t.displayFilter&&(o=o.filter((e=>t.displayFilter?0!==e.offsetHeight:0===e.offsetHeight))),null!=t.iframeFilter&&(o=o.filter((()=>t.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=t.childFilter&&(o=o.filter((e=>{const n=_.base;_.setBase(e);const o=_.find(t.childFilter);return _.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,t,e),o[0])}static find(t,e=!1){const n=[];if(null!=t.parent){const o=_.findElement(t.parent,null,e);if(null!=o){if(o instanceof Array)return o.forEach((o=>{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})})),n;{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})}}}else{const o=_.findElement(t.target,null,e);o instanceof Array?o.forEach((t=>{n.push({parent:null,target:t})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),e?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function S(t){const e=_.find(t);return"css"===t.type?!!e.target:"checkbox"===t.type?!!e.target&&e.target.checked:void 0}async function P(t,e){switch(t.type){case"click":return async function(t){const e=_.find(t);null!=e.target&&e.target.click();return x(0)}(t);case"list":return async function(t,e){for(const n of t.actions)await P(n,e)}(t,e);case"consent":return async function(t,e){for(const n of t.consents){const t=-1!==e.indexOf(n.type);if(n.matcher&&n.toggleAction){S(n.matcher)!==t&&await P(n.toggleAction)}else t?await P(n.trueAction):await P(n.falseAction)}}(t,e);case"ifcss":return async function(t,e){_.find(t).target?t.falseAction&&await P(t.falseAction,e):t.trueAction&&await P(t.trueAction,e)}(t,e);case"waitcss":return async function(t){await new Promise((e=>{let n=t.retries||10;const o=t.waitTime||250,i=()=>{const s=_.find(t);(t.negated&&s.target||!t.negated&&!s.target)&&n>0?(n-=1,setTimeout(i,o)):e()};i()}))}(t);case"foreach":return async function(t,e){const n=_.find(t,!0),o=_.base;for(const o of n)o.target&&(_.setBase(o.target),await P(t.action,e));_.setBase(o)}(t,e);case"hide":return async function(t){const e=_.find(t);e.target&&e.target.classList.add("Autoconsent-Hidden")}(t);case"slide":return async function(t){const e=_.find(t),n=_.find(t.dragTarget);if(e.target){const t=e.target.getBoundingClientRect(),o=n.target.getBoundingClientRect();let i=o.top-t.top,s=o.left-t.left;"y"===this.config.axis.toLowerCase()&&(s=0),"x"===this.config.axis.toLowerCase()&&(i=0);const r=window.screenX+t.left+t.width/2,c=window.screenY+t.top+t.height/2,a=t.left+t.width/2,u=t.top+t.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,c,a,u,!1,!1,!1,!1,0,e.target);const p=document.createEvent("MouseEvents");p.initMouseEvent("mousemove",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target);const d=document.createEvent("MouseEvents");d.initMouseEvent("mouseup",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target),e.target.dispatchEvent(l),await this.waitTimeout(10),e.target.dispatchEvent(p),await this.waitTimeout(10),e.target.dispatchEvent(d)}}(t);case"close":return async function(){window.close()}();case"wait":return async function(t){await x(t.waitTime)}(t);case"eval":return async function(t){return console.log("eval!",t.code),new Promise((e=>{try{t.async?(window.eval(t.code),setTimeout((()=>{e(window.eval("window.__consentCheckResult"))}),t.timeout||250)):e(window.eval(t.code))}catch(n){console.warn("eval error",n,t.code),e(!1)}}))}(t);default:throw"Unknown action type: "+t.type}}_.base=null;function x(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}class A{constructor(t,e){this.name=t,this.config=e,this.methods=new Map,this.runContext=y,this.isCosmetic=!1,e.methods.forEach((t=>{t.action&&this.methods.set(t.name,t.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((t=>S(t.presentMatcher))).some((t=>!!t))}async detectPopup(){return this.config.detectors.map((t=>S(t.showingMatcher))).some((t=>!!t))}async executeAction(t,e){return!this.methods.has(t)||P(this.methods.get(t),e)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}class E{constructor(e,o=null,i=null){if(this.id=t(),this.rules=[],this.foundCmp=null,this.state={lifecycle:"loading",prehideOn:!1,findCmpAttempts:0,detectedCmps:[],detectedPopups:[],selfTest:null},n.sendContentMessage=e,this.sendContentMessage=e,this.rules=[...v],this.updateState({lifecycle:"loading"}),o)this.initialize(o,i);else{i&&this.parseRules(i);e({type:"init",url:window.location.href}),this.updateState({lifecycle:"waitingForInitResponse"})}}initialize(t,e){if(this.config=t,t.enabled){if(e&&this.parseRules(e),this.rules=function(t,e){return t.filter((t=>(!e.disabledCmps||!e.disabledCmps.includes(t.name))&&(e.enableCosmeticRules||!t.isCosmetic)))}(this.rules,t),t.enablePrehide)if(document.documentElement)this.prehideElements();else{const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.prehideElements()};window.addEventListener("DOMContentLoaded",t)}if("loading"===document.readyState){const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.start()};window.addEventListener("DOMContentLoaded",t)}else this.start();this.updateState({lifecycle:"initialized"})}}parseRules(t){Object.keys(t.consentomatic).forEach((e=>{this.addConsentomaticCMP(e,t.consentomatic[e])})),t.autoconsent.forEach((t=>{this.addCMP(t)}))}addCMP(t){this.rules.push(k(t))}addConsentomaticCMP(t,e){this.rules.push(new A(`com_${t}`,e))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){this.updateState({lifecycle:"started"});const t=await this.findCmp(this.config.detectRetries);if(this.updateState({detectedCmps:t.map((t=>t.name))}),0===t.length)return this.config.enablePrehide&&this.undoPrehide(),this.updateState({lifecycle:"nothingDetected"}),!1;this.updateState({lifecycle:"cmpDetected"});let e=await this.detectPopups(t.filter((t=>!t.isCosmetic)));if(0===e.length&&(e=await this.detectPopups(t.filter((t=>t.isCosmetic)))),0===e.length)return this.config.enablePrehide&&this.undoPrehide(),!1;if(this.updateState({lifecycle:"openPopupDetected"}),e.length>1){const t={msg:"Found multiple CMPs, check the detection rules.",cmps:e.map((t=>t.name))};this.sendContentMessage({type:"autoconsentError",details:t})}return this.foundCmp=e[0],"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn()}async findCmp(t){this.updateState({findCmpAttempts:this.state.findCmpAttempts+1});const e=[];for(const t of this.rules)try{if(!t.checkRunContext())continue;await t.detectCmp()&&(this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:t.name}),e.push(t))}catch(t){}return 0===e.length&&t>0?new Promise((e=>{setTimeout((async()=>{const n=this.findCmp(t-1);e(n)}),500)})):e}async detectPopups(t){const e=[],n=t.map((t=>this.waitForPopup(t).then((n=>{n&&(this.updateState({detectedPopups:this.state.detectedPopups.concat([t.name])}),this.sendContentMessage({type:"popupFound",cmp:t.name,url:location.href}),e.push(t))})).catch((()=>null))));return await Promise.all(n),e}async doOptOut(){let t;return this.updateState({lifecycle:"runningOptOut"}),t=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optOutSucceeded":"optOutFailed"}),t}async doOptIn(){let t;return this.updateState({lifecycle:"runningOptIn"}),t=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:!1,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optInSucceeded":"optInFailed"}),t}async doSelfTest(){let t;return t=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,url:location.href}),this.updateState({selfTest:t}),t}async waitForPopup(t,e=5,n=500){const o=await t.detectPopup();return!o&&e>0?new Promise((o=>setTimeout((()=>o(this.waitForPopup(t,e-1,n))),n))):o}prehideElements(){const t=this.rules.reduce(((t,e)=>e.prehideSelectors?[...t,...e.prehideSelectors]:t),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]);return this.updateState({prehideOn:!0}),function(t){return i(o("autoconsent-prehide"),t,"opacity")}(t)}undoPrehide(){return this.updateState({prehideOn:!1}),function(){const t=o("autoconsent-prehide");return t&&t.remove(),!!t}()}updateState(t){Object.assign(this.state,t),this.sendContentMessage({type:"report",instanceId:this.id,url:window.location.href,mainFrame:window.top===window.self,state:this.state})}async receiveMessageCallback(t){switch(t.type){case"initResp":this.initialize(t.config,t.rules);break;case"optIn":await this.doOptIn();break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(t,e){const o=n.pending.get(t);o?(n.pending.delete(t),o.timer&&window.clearTimeout(o.timer),o.resolve(e)):console.warn("no eval #",t)}(t.id,t.result)}}}export{k as createAutoCMP,E as default,v as rules};
|
|
1
|
+
function t(){return crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString()}class e{constructor(t,e=1e3){this.id=t,this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),e)}}const n={pending:new Map,sendContentMessage:null};function o(t="autoconsent-css-rules"){const e=`style#${t}`,n=document.querySelector(e);if(n&&n instanceof HTMLStyleElement)return n;{const e=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=t,e.appendChild(n),n}}function i(t,e,n="display"){const o="opacity"===n?"opacity: 0":"display: none",i=`${e.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return t instanceof HTMLStyleElement&&(t.innerText+=i,e.length>0)}async function s(t,e,n){const o=await t();return!o&&e>0?new Promise((o=>{setTimeout((async()=>{o(s(t,e-1,n))}),n)})):Promise.resolve(o)}function r(t){if(!t)return!1;if(null!==t.offsetParent)return!0;{const e=window.getComputedStyle(t);if("fixed"===e.position&&"none"!==e.display)return!0}return!1}function c(o){return function(o){const i=t();n.sendContentMessage({type:"eval",id:i,code:o});const s=new e(i);return n.pending.set(s.id,s),s.promise}(o).catch((t=>!1))}function a(t,e=!1){const n=f(t);return n.length>0&&(e?n.forEach((t=>t.click())):n[0].click()),n.length>0}function u(t){return f(t).length>0}function l(t,e){const n=f(t),o=new Array(n.length);return n.forEach(((t,e)=>{o[e]=r(t)})),"none"===e?o.every((t=>!t)):0!==o.length&&("any"===e?o.some((t=>t)):o.every((t=>t)))}function p(t,e=1e4){return s((()=>f(t).length>0),Math.ceil(e/200),200)}async function d(t,e=1e4,n=!1){return await p(t,e),a(t,n)}function h(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}function m(t,e=document){if(t.startsWith("aria/"))return[];if(t.startsWith("xpath/")){const n=t.slice(6),o=document.evaluate(n,e,null,XPathResult.ANY_TYPE,null);let i=null;const s=[];for(;i=o.iterateNext();)s.push(i);return s}return t.startsWith("text/")||t.startsWith("pierce/")?[]:e.shadowRoot?Array.from(e.shadowRoot.querySelectorAll(t)):Array.from(e.querySelectorAll(t))}function f(t){return"string"==typeof t?m(t):function(t){let e,n=document;for(const o of t){if(e=m(o,n),0===e.length)return[];n=e[0]}return e}(t)}const y={main:!0,frame:!1,urlPattern:""};class w{constructor(t){this.runContext=y,this.name=t}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}get isCosmetic(){throw new Error("Not Implemented")}checkRunContext(){const t={...y,...this.runContext},e=window.top===window;return!(e&&!t.main)&&(!(!e&&!t.frame)&&!(t.urlPattern&&!window.location.href.match(t.urlPattern)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function g(t){const e=[];if(t.exists&&e.push(u(t.exists)),t.visible&&e.push(l(t.visible,t.check)),t.eval){const n=c(t.eval);e.push(n)}var n,r;if(t.waitFor&&e.push(p(t.waitFor,t.timeout)),t.waitForVisible&&e.push(function(t,e=1e4,n="any"){return s((()=>l(t,n)),Math.ceil(e/200),200)}(t.waitForVisible,t.timeout,t.check)),t.click&&e.push(a(t.click,t.all)),t.waitForThenClick&&e.push(d(t.waitForThenClick,t.timeout,t.all)),t.wait&&e.push(h(t.wait)),t.hide&&e.push((n=t.hide,r=t.method,i(o(),n,r))),t.if){if(!t.if.exists&&!t.if.visible)return console.error("invalid conditional rule",t.if),!1;await g(t.if)?e.push(C(t.then)):t.else&&e.push(C(t.else))}if(t.any){for(const e of t.any)if(await g(e))return!0;return!1}if(0===e.length)return!1;return(await Promise.all(e)).reduce(((t,e)=>t&&e),!0)}async function C(t){for(const e of t){if(!await g(e)&&!e.optional)return!1}return!0}class b extends w{constructor(t){super(t.name),this.config=t,this.runContext=t.runContext||y}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get isCosmetic(){return!!this.config.cosmetic}get prehideSelectors(){return this.config.prehideSelectors}async detectCmp(){return!!this.config.detectCmp&&async function(t){const e=t.map((t=>g(t)));return(await Promise.all(e)).every((t=>!!t))}(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&C(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&C(this.config.optOut)}async optIn(){return!!this.config.optIn&&C(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&C(this.config.openCmp)}async test(){return this.hasSelfTest?C(this.config.test):super.test()}}function k(t){return new b(t)}const v=[new class extends w{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",".truste_popframe,.truste_overlay,.truste_box_overlay,#truste-consent-track"],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}get isCosmetic(){return!1}async detectCmp(){const t=u("#truste-show-consent,#truste-consent-track");return t&&(this._shortcutButton=document.querySelector("#truste-consent-required")),t}async detectPopup(){return l("#truste-consent-content,#trustarc-banner-overlay,#truste-consent-track","all")}openFrame(){a("#truste-show-consent")}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(i(o(),[".truste_popframe",".truste_overlay",".truste_box_overlay","#truste-consent-track"]),a("#truste-show-consent"),setTimeout((()=>{o().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,a("#truste-consent-button")}async openCmp(){return!0}async test(){return await c("window && window.truste && window.truste.eu.bindMap.prefCookie === '0'")}},new class extends w{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,urlPattern:"^https://consent-pref\\.trustarc\\.com/\\?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return!0}async detectPopup(){return l("#defaultpreferencemanager","any")&&l(".mainContent","any")}async navigateToSettings(){return await s((async()=>u(".shp")||l(".advance","any")||u(".switch span:first-child")),10,500),u(".shp")&&a(".shp"),await p(".prefPanel",5e3),l(".advance","any")&&a(".advance"),await s((()=>l(".switch span:first-child","any")),5,1e3)}async optOut(){return await s((()=>"complete"===document.readyState),20,100),await p(".mainContent[aria-hidden=false]",5e3),!!a(".rejectAll")||(u(".prefPanel")&&await p('.prefPanel[style="visibility: visible;"]',3e3),a("#catDetails0")?(a(".submit"),!0):(a(".required")||(await this.navigateToSettings(),a(".switch span:nth-child(1):not(.active)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0))}async optIn(){return a(".call")||(await this.navigateToSettings(),a(".switch span:nth-child(2)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0}},new class extends w{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return u("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return a(".cookie-alert-extended-detail-link")?(await p(".cookie-alert-configuration",2e3),a(".cookie-alert-configuration-input:checked",!0),a(".cookie-alert-extended-button-secondary"),!0):u("#dtcookie-container")?a(".h-dtcookie-decline"):(a(".cookiebot__button--settings")||a("#CybotCookiebotDialogBodyButtonDecline")||(a(".cookiebanner__link--details"),a('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),a("#CybotCookiebotDialogBodyButtonDecline"),a("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),u("#CybotCookiebotDialogBodyButtonAcceptSelected")?a("#CybotCookiebotDialogBodyButtonAcceptSelected"):a("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await c("window.CookieConsent.hasResponse !== true")&&(await c("window.Cookiebot.dialog.submitConsent()"),await h(500)),u("#cb-confirmedSettings")&&await c("endCookieProcess()")),!0)}async optIn(){return u("#dtcookie-container")?a(".h-dtcookie-accept"):(a(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),a("#CybotCookiebotDialogBodyLevelButtonAccept"),a("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return c("window.CookieConsent.declined === true")}},new class extends w{constructor(){super("Sourcepoint-frame"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay","#sp_privacy_manager_container"],this.ccpaNotice=!1,this.ccpaPopup=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){const t=new URL(location.href);return t.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===t.hostname?(this.ccpaNotice=!0,!0):"ccpa-pm.sp-prod.net"===t.hostname?(this.ccpaPopup=!0,!0):("/index.html"===t.pathname||"/privacy-manager/index.html"===t.pathname)&&(t.searchParams.has("message_id")||t.searchParams.has("requestUUID")||t.searchParams.has("consentUUID"))}async detectPopup(){return!!this.ccpaNotice||(this.ccpaPopup?await p(".priv-save-btn",2e3):(await p(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL",2e3),!u(".sp_choice_type_9")))}async optIn(){return await p(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!a(".sp_choice_type_11")||!!a(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===location.pathname}async optOut(){if(this.ccpaPopup){const t=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");for(const e of t)e.click();const e=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.switch-bg.on");for(const t of e)t.click();return a(".priv-save-btn")}if(!this.isManagerOpen()){if(!await p(".sp_choice_type_12,.sp_choice_type_13"))return!1;if(!u(".sp_choice_type_12"))return a(".sp_choice_type_13");a(".sp_choice_type_12"),await s((()=>this.isManagerOpen()),200,100)}await p(".type-modal",2e4);try{const t=".sp_choice_type_REJECT_ALL",e=".reject-toggle",n=await Promise.race([p(t,2e3).then((t=>t?0:-1)),p(e,2e3).then((t=>t?1:-1)),p(".pm-features",2e3).then((t=>t?2:-1))]);if(0===n)return await h(1e3),a(t);1===n?a(e):2===n&&(await p(".pm-features",1e4),a(".checked > span",!0),a(".chevron"))}catch(t){}return a(".sp_choice_type_SAVE_AND_EXIT")}},new class extends w{get hasSelfTest(){return this.apiAvailable}get isIntermediate(){return!1}get isCosmetic(){return!1}constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"],this.apiAvailable=!1}async detectCmp(){return this.apiAvailable=await c('window.__cmp && typeof __cmp("getCMPData") === "object"'),!!this.apiAvailable||u("#cmpbox")}async detectPopup(){return this.apiAvailable?(await h(500),await c("!__cmp('consentStatus').userChoiceExists")):l("#cmpbox .cmpmore","any")}async optOut(){return await h(500),this.apiAvailable?await c("__cmp('setConsent', 0)"):!!a(".cmpboxbtnno")||(u(".cmpwelcomeprpsbtn")?(a(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),a(".cmpboxbtnsave"),!0):(a(".cmpboxbtncustom"),await p(".cmptblbox",2e3),a(".cmptdchoice > a[aria-checked=true]",!0),a(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return this.apiAvailable?await c("__cmp('setConsent', 1)"):a(".cmpboxbtnyes")}async test(){if(this.apiAvailable)return await c("__cmp('consentStatus').userChoiceExists")}},new class extends w{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#_evidon_banner")}async detectPopup(){return l("#_evidon_banner","any")}async optOut(){return a("#_evidon-decline-button")||(i(o(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),a("#_evidon-option-button"),await p("#evidon-prefdiag-overlay",5e3),a("#evidon-prefdiag-decline")),!0}async optIn(){return a("#_evidon-accept-button")}},new class extends w{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.onetrust-pc-dark-filter,.js-consent-banner"],this.runContext={urlPattern:"^(?!.*https://www\\.nba\\.com/)"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#onetrust-banner-sdk")}async detectPopup(){return l("#onetrust-banner-sdk","all")}async optOut(){return u("#onetrust-pc-btn-handler")?a("#onetrust-pc-btn-handler"):a(".ot-sdk-show-settings,button.js-cookie-settings"),await p("#onetrust-consent-sdk",2e3),await h(1e3),a("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await h(1e3),await p(".save-preference-btn-handler,.js-consent-save",2e3),a(".save-preference-btn-handler,.js-consent-save"),await s((()=>l("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return a("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await c("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}},new class extends w{constructor(){super("Klaro"),this.prehideSelectors=[".klaro"],this.settingsOpen=!1}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".klaro > .cookie-modal")?(this.settingsOpen=!0,!0):u(".klaro > .cookie-notice")}async detectPopup(){return l(".klaro > .cookie-notice,.klaro > .cookie-modal","any")}async optOut(){return!!a(".klaro .cn-decline")||(this.settingsOpen||(a(".klaro .cn-learn-more"),await p(".klaro > .cookie-modal",2e3),this.settingsOpen=!0),!!a(".klaro .cn-decline")||(a(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)",!0),a(".cm-btn-accept")))}async optIn(){return!!a(".klaro .cm-btn-accept-all")||(this.settingsOpen?(a(".cm-purpose:not(.cm-toggle-all) > input.half-checked",!0),a(".cm-btn-accept")):a(".klaro .cookie-notice .cm-btn-success"))}async test(){return await c("klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name])")}},new class extends w{constructor(){super("Uniconsent")}get prehideSelectors(){return[".unic",".modal:has(.unic)"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".unic .unic-box,.unic .unic-bar")}async detectPopup(){return l(".unic .unic-box,.unic .unic-bar","any")}async optOut(){if(await p(".unic button",1e3),document.querySelectorAll(".unic button").forEach((t=>{const e=t.textContent;(e.includes("Manage Options")||e.includes("Optionen verwalten"))&&t.click()})),await p(".unic input[type=checkbox]",1e3)){await p(".unic button",1e3),document.querySelectorAll(".unic input[type=checkbox]").forEach((t=>{t.checked&&t.click()}));for(const t of document.querySelectorAll(".unic button")){const e=t.textContent;for(const n of["Confirm Choices","Save Choices","Auswahl speichern"])if(e.includes(n))return t.click(),await h(500),!0}}return!1}async optIn(){return d(".unic #unic-agree")}async test(){await h(1e3);return!u(".unic .unic-box,.unic .unic-bar")}},new class extends w{constructor(){super("Conversant"),this.prehideSelectors=[".cmp-root"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".cmp-root .cmp-receptacle")}async detectPopup(){return l(".cmp-root .cmp-receptacle","any")}async optOut(){if(!await d(".cmp-main-button:not(.cmp-main-button--primary)"))return!1;if(!await p(".cmp-view-tab-tabs"))return!1;await d(".cmp-view-tab-tabs > :first-child"),await d(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");for(const t of Array.from(document.querySelectorAll(".cmp-accordion-item"))){t.querySelector(".cmp-accordion-item-title").click(),await s((()=>!!t.querySelector(".cmp-accordion-item-content.cmp-active")),10,50);const e=t.querySelector(".cmp-accordion-item-content.cmp-active");e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((t=>t.click())),e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((t=>t.click()))}return await a(".cmp-main-button:not(.cmp-main-button--primary)"),!0}async optIn(){return d(".cmp-main-button.cmp-main-button--primary")}async test(){return document.cookie.includes("cmp-data=0")}},new class extends w{constructor(){super("tiktok.com"),this.runContext={urlPattern:"tiktok"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}getShadowRoot(){const t=document.querySelector("tiktok-cookie-banner");return t?t.shadowRoot:null}async detectCmp(){return u("tiktok-cookie-banner")}async detectPopup(){return r(this.getShadowRoot().querySelector(".tiktok-cookie-banner"))}async optOut(){const t=this.getShadowRoot().querySelector(".button-wrapper button:first-child");return!!t&&(t.click(),!0)}async optIn(){const t=this.getShadowRoot().querySelector(".button-wrapper button:last-child");return!!t&&(t.click(),!0)}async test(){const t=document.cookie.match(/cookie-consent=([^;]+)/);if(!t)return!1;const e=JSON.parse(decodeURIComponent(t[1]));return Object.values(e).every((t=>"boolean"!=typeof t||!1===t))}},new class extends w{constructor(){super("airbnb"),this.runContext={urlPattern:"^https://(www\\.)?airbnb\\.[^/]+/"},this.prehideSelectors=["div[data-testid=main-cookies-banner-container]",'div:has(> div:first-child):has(> div:last-child):has(> section [data-testid="strictly-necessary-cookies"])']}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("div[data-testid=main-cookies-banner-container]")}async detectPopup(){return l("div[data-testid=main-cookies-banner-container","any")}async optOut(){let t;for(await d("div[data-testid=main-cookies-banner-container] button._snbhip0");t=document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])");)t.click();return d("button[data-testid=save-btn]")}async optIn(){return d("div[data-testid=main-cookies-banner-container] button._148dgdpk")}async test(){return await s((()=>!!document.cookie.match("OptanonAlertBoxClosed")),20,200)}}];class _{static setBase(t){_.base=t}static findElement(t,e=null,n=!1){let o=null;return o=null!=e?Array.from(e.querySelectorAll(t.selector)):null!=_.base?Array.from(_.base.querySelectorAll(t.selector)):Array.from(document.querySelectorAll(t.selector)),null!=t.textFilter&&(o=o.filter((e=>{const n=e.textContent.toLowerCase();if(Array.isArray(t.textFilter)){let e=!1;for(const o of t.textFilter)if(-1!==n.indexOf(o.toLowerCase())){e=!0;break}return e}if(null!=t.textFilter)return-1!==n.indexOf(t.textFilter.toLowerCase())}))),null!=t.styleFilters&&(o=o.filter((e=>{const n=window.getComputedStyle(e);let o=!0;for(const e of t.styleFilters){const t=n[e.option];o=e.negated?o&&t!==e.value:o&&t===e.value}return o}))),null!=t.displayFilter&&(o=o.filter((e=>t.displayFilter?0!==e.offsetHeight:0===e.offsetHeight))),null!=t.iframeFilter&&(o=o.filter((()=>t.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=t.childFilter&&(o=o.filter((e=>{const n=_.base;_.setBase(e);const o=_.find(t.childFilter);return _.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,t,e),o[0])}static find(t,e=!1){const n=[];if(null!=t.parent){const o=_.findElement(t.parent,null,e);if(null!=o){if(o instanceof Array)return o.forEach((o=>{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})})),n;{const i=_.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})}}}else{const o=_.findElement(t.target,null,e);o instanceof Array?o.forEach((t=>{n.push({parent:null,target:t})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),e?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function S(t){const e=_.find(t);return"css"===t.type?!!e.target:"checkbox"===t.type?!!e.target&&e.target.checked:void 0}async function P(t,e){switch(t.type){case"click":return async function(t){const e=_.find(t);null!=e.target&&e.target.click();return x(0)}(t);case"list":return async function(t,e){for(const n of t.actions)await P(n,e)}(t,e);case"consent":return async function(t,e){for(const n of t.consents){const t=-1!==e.indexOf(n.type);if(n.matcher&&n.toggleAction){S(n.matcher)!==t&&await P(n.toggleAction)}else t?await P(n.trueAction):await P(n.falseAction)}}(t,e);case"ifcss":return async function(t,e){_.find(t).target?t.falseAction&&await P(t.falseAction,e):t.trueAction&&await P(t.trueAction,e)}(t,e);case"waitcss":return async function(t){await new Promise((e=>{let n=t.retries||10;const o=t.waitTime||250,i=()=>{const s=_.find(t);(t.negated&&s.target||!t.negated&&!s.target)&&n>0?(n-=1,setTimeout(i,o)):e()};i()}))}(t);case"foreach":return async function(t,e){const n=_.find(t,!0),o=_.base;for(const o of n)o.target&&(_.setBase(o.target),await P(t.action,e));_.setBase(o)}(t,e);case"hide":return async function(t){const e=_.find(t);e.target&&e.target.classList.add("Autoconsent-Hidden")}(t);case"slide":return async function(t){const e=_.find(t),n=_.find(t.dragTarget);if(e.target){const t=e.target.getBoundingClientRect(),o=n.target.getBoundingClientRect();let i=o.top-t.top,s=o.left-t.left;"y"===this.config.axis.toLowerCase()&&(s=0),"x"===this.config.axis.toLowerCase()&&(i=0);const r=window.screenX+t.left+t.width/2,c=window.screenY+t.top+t.height/2,a=t.left+t.width/2,u=t.top+t.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,c,a,u,!1,!1,!1,!1,0,e.target);const p=document.createEvent("MouseEvents");p.initMouseEvent("mousemove",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target);const d=document.createEvent("MouseEvents");d.initMouseEvent("mouseup",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target),e.target.dispatchEvent(l),await this.waitTimeout(10),e.target.dispatchEvent(p),await this.waitTimeout(10),e.target.dispatchEvent(d)}}(t);case"close":return async function(){window.close()}();case"wait":return async function(t){await x(t.waitTime)}(t);case"eval":return async function(t){return console.log("eval!",t.code),new Promise((e=>{try{t.async?(window.eval(t.code),setTimeout((()=>{e(window.eval("window.__consentCheckResult"))}),t.timeout||250)):e(window.eval(t.code))}catch(n){console.warn("eval error",n,t.code),e(!1)}}))}(t);default:throw"Unknown action type: "+t.type}}_.base=null;function x(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}class A{constructor(t,e){this.name=t,this.config=e,this.methods=new Map,this.runContext=y,this.isCosmetic=!1,e.methods.forEach((t=>{t.action&&this.methods.set(t.name,t.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((t=>S(t.presentMatcher))).some((t=>!!t))}async detectPopup(){return this.config.detectors.map((t=>S(t.showingMatcher))).some((t=>!!t))}async executeAction(t,e){return!this.methods.has(t)||P(this.methods.get(t),e)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}class O{constructor(e,o=null,i=null){if(this.id=t(),this.rules=[],this.foundCmp=null,this.state={lifecycle:"loading",prehideOn:!1,findCmpAttempts:0,detectedCmps:[],detectedPopups:[],selfTest:null},n.sendContentMessage=e,this.sendContentMessage=e,this.rules=[...v],this.updateState({lifecycle:"loading"}),o)this.initialize(o,i);else{i&&this.parseRules(i);e({type:"init",url:window.location.href}),this.updateState({lifecycle:"waitingForInitResponse"})}}initialize(t,e){if(this.config=t,t.enabled){if(e&&this.parseRules(e),this.rules=function(t,e){return t.filter((t=>(!e.disabledCmps||!e.disabledCmps.includes(t.name))&&(e.enableCosmeticRules||!t.isCosmetic)))}(this.rules,t),t.enablePrehide)if(document.documentElement)this.prehideElements();else{const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.prehideElements()};window.addEventListener("DOMContentLoaded",t)}if("loading"===document.readyState){const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.start()};window.addEventListener("DOMContentLoaded",t)}else this.start();this.updateState({lifecycle:"initialized"})}}parseRules(t){Object.keys(t.consentomatic).forEach((e=>{this.addConsentomaticCMP(e,t.consentomatic[e])})),t.autoconsent.forEach((t=>{this.addCMP(t)}))}addCMP(t){this.rules.push(k(t))}addConsentomaticCMP(t,e){this.rules.push(new A(`com_${t}`,e))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){this.updateState({lifecycle:"started"});const t=await this.findCmp(this.config.detectRetries);if(this.updateState({detectedCmps:t.map((t=>t.name))}),0===t.length)return this.config.enablePrehide&&this.undoPrehide(),this.updateState({lifecycle:"nothingDetected"}),!1;this.updateState({lifecycle:"cmpDetected"});let e=await this.detectPopups(t.filter((t=>!t.isCosmetic)));if(0===e.length&&(e=await this.detectPopups(t.filter((t=>t.isCosmetic)))),0===e.length)return this.config.enablePrehide&&this.undoPrehide(),!1;if(this.updateState({lifecycle:"openPopupDetected"}),e.length>1){const t={msg:"Found multiple CMPs, check the detection rules.",cmps:e.map((t=>t.name))};this.sendContentMessage({type:"autoconsentError",details:t})}return this.foundCmp=e[0],"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn()}async findCmp(t){this.updateState({findCmpAttempts:this.state.findCmpAttempts+1});const e=[];for(const t of this.rules)try{if(!t.checkRunContext())continue;await t.detectCmp()&&(this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:t.name}),e.push(t))}catch(t){}return 0===e.length&&t>0?(await h(500),this.findCmp(t-1)):e}async detectPopups(t){const e=[],n=t.map((t=>this.waitForPopup(t).then((n=>{n&&(this.updateState({detectedPopups:this.state.detectedPopups.concat([t.name])}),this.sendContentMessage({type:"popupFound",cmp:t.name,url:location.href}),e.push(t))})).catch((()=>null))));return await Promise.all(n),e}async doOptOut(){let t;return this.updateState({lifecycle:"runningOptOut"}),t=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optOutSucceeded":"optOutFailed"}),t}async doOptIn(){let t;return this.updateState({lifecycle:"runningOptIn"}),t=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:!1,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optInSucceeded":"optInFailed"}),t}async doSelfTest(){let t;return t=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,url:location.href}),this.updateState({selfTest:t}),t}async waitForPopup(t,e=5,n=500){const o=await t.detectPopup();return!o&&e>0?(await h(n),this.waitForPopup(t,e-1,n)):o}prehideElements(){const t=this.rules.reduce(((t,e)=>e.prehideSelectors?[...t,...e.prehideSelectors]:t),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]);return this.updateState({prehideOn:!0}),setTimeout((()=>{this.config.enablePrehide&&this.state.prehideOn&&!["runningOptOut","runningOptIn"].includes(this.state.lifecycle)&&this.undoPrehide()}),this.config.prehideTimeout||2e3),function(t){return i(o("autoconsent-prehide"),t,"opacity")}(t)}undoPrehide(){return this.updateState({prehideOn:!1}),function(){const t=o("autoconsent-prehide");return t&&t.remove(),!!t}()}updateState(t){Object.assign(this.state,t),this.sendContentMessage({type:"report",instanceId:this.id,url:window.location.href,mainFrame:window.top===window.self,state:this.state})}async receiveMessageCallback(t){switch(t.type){case"initResp":this.initialize(t.config,t.rules);break;case"optIn":await this.doOptIn();break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(t,e){const o=n.pending.get(t);o?(n.pending.delete(t),o.timer&&window.clearTimeout(o.timer),o.resolve(e)):console.warn("no eval #",t)}(t.id,t.result)}}}export{k as createAutoCMP,O as default,v as rules};
|