@duckduckgo/autoconsent 5.3.0 → 6.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.
Files changed (95) hide show
  1. package/.eslintrc +1 -1
  2. package/CHANGELOG.md +17 -0
  3. package/data/coverage.json +958 -1010
  4. package/dist/addon-firefox/background.bundle.js +13 -12
  5. package/dist/addon-firefox/content.bundle.js +1074 -930
  6. package/dist/addon-firefox/manifest.json +1 -1
  7. package/dist/addon-firefox/rules.json +83 -83
  8. package/dist/addon-mv3/background.bundle.js +13 -12
  9. package/dist/addon-mv3/content.bundle.js +1074 -930
  10. package/dist/addon-mv3/manifest.json +1 -1
  11. package/dist/addon-mv3/popup.bundle.js +38 -0
  12. package/dist/addon-mv3/popup.html +2 -1
  13. package/dist/addon-mv3/rules.json +83 -83
  14. package/dist/autoconsent.cjs.js +1074 -937
  15. package/dist/autoconsent.esm.js +1074 -932
  16. package/dist/autoconsent.playwright.js +1 -1
  17. package/lib/cmps/airbnb.ts +1 -3
  18. package/lib/cmps/all.ts +13 -22
  19. package/lib/cmps/base.ts +123 -92
  20. package/lib/cmps/consentmanager.ts +7 -10
  21. package/lib/cmps/conversant.ts +1 -4
  22. package/lib/cmps/cookiebot.ts +6 -10
  23. package/lib/cmps/evidon.ts +1 -3
  24. package/lib/cmps/klaro.ts +3 -7
  25. package/lib/cmps/onetrust.ts +3 -7
  26. package/lib/cmps/sourcepoint-frame.ts +1 -4
  27. package/lib/cmps/tiktok.ts +1 -3
  28. package/lib/cmps/trustarc-frame.ts +1 -3
  29. package/lib/cmps/trustarc-top.ts +6 -5
  30. package/lib/cmps/uniconsent.ts +1 -3
  31. package/lib/eval-snippets.ts +105 -0
  32. package/lib/rule-executors.ts +0 -8
  33. package/lib/rules.ts +3 -1
  34. package/lib/types.ts +1 -1
  35. package/lib/web.ts +26 -13
  36. package/package.json +1 -1
  37. package/readme.md +3 -3
  38. package/rules/autoconsent/192.json +1 -1
  39. package/rules/autoconsent/adroll.json +1 -1
  40. package/rules/autoconsent/affinity-serif-com.json +1 -1
  41. package/rules/autoconsent/axeptio.json +1 -1
  42. package/rules/autoconsent/bing.json +1 -1
  43. package/rules/autoconsent/borlabs.json +1 -1
  44. package/rules/autoconsent/bundesregierung-de.json +1 -1
  45. package/rules/autoconsent/canva.json +1 -1
  46. package/rules/autoconsent/clickio.json +1 -1
  47. package/rules/autoconsent/clinch.json +1 -1
  48. package/rules/autoconsent/coinbase.json +1 -1
  49. package/rules/autoconsent/complianz-banner.json +1 -1
  50. package/rules/autoconsent/complianz-categories.json +1 -1
  51. package/rules/autoconsent/complianz-optin.json +1 -1
  52. package/rules/autoconsent/cookie-law-info.json +2 -2
  53. package/rules/autoconsent/cookie-manager-popup.json +1 -1
  54. package/rules/autoconsent/cookiealert.json +3 -3
  55. package/rules/autoconsent/cookiefirst.json +7 -8
  56. package/rules/autoconsent/cookieinformation.json +3 -3
  57. package/rules/autoconsent/dailymotion.json +1 -1
  58. package/rules/autoconsent/dsgvo.json +1 -1
  59. package/rules/autoconsent/dunelm.json +1 -1
  60. package/rules/autoconsent/etsy.json +2 -2
  61. package/rules/autoconsent/eu-cookie-compliance.json +1 -1
  62. package/rules/autoconsent/eu-cookie-law.json +1 -1
  63. package/rules/autoconsent/ezoic.json +2 -2
  64. package/rules/autoconsent/google.json +1 -1
  65. package/rules/autoconsent/iubenda.json +2 -2
  66. package/rules/autoconsent/jquery-cookiebar.json +1 -1
  67. package/rules/autoconsent/mediavine.json +1 -1
  68. package/rules/autoconsent/microsoft.json +3 -3
  69. package/rules/autoconsent/moove.json +1 -1
  70. package/rules/autoconsent/paypal.json +1 -1
  71. package/rules/autoconsent/primebox.json +1 -1
  72. package/rules/autoconsent/pubtech.json +1 -1
  73. package/rules/autoconsent/reddit.json +1 -1
  74. package/rules/autoconsent/sibbo.json +1 -1
  75. package/rules/autoconsent/sirdata.json +1 -1
  76. package/rules/autoconsent/snigel.json +1 -1
  77. package/rules/autoconsent/steampowered.json +1 -1
  78. package/rules/autoconsent/tarteaucitron.json +3 -3
  79. package/rules/autoconsent/tealium.json +4 -4
  80. package/rules/autoconsent/testcmp-cosmetic.json +1 -1
  81. package/rules/autoconsent/testcmp.json +1 -1
  82. package/rules/autoconsent/thefreedictionary.json +2 -2
  83. package/rules/autoconsent/theverge.json +1 -1
  84. package/rules/autoconsent/twitter.json +1 -1
  85. package/rules/autoconsent/ubuntu.com.json +1 -1
  86. package/rules/autoconsent/uk-cookie-consent.json +1 -1
  87. package/rules/autoconsent/usercentrics-api.json +7 -7
  88. package/rules/autoconsent/usercentrics-button.json +1 -1
  89. package/rules/autoconsent/waitrose.json +2 -2
  90. package/rules/autoconsent/wp-cookie-notice.json +1 -1
  91. package/rules/autoconsent/xing.json +1 -1
  92. package/rules/autoconsent/youtube-desktop.json +1 -1
  93. package/rules/autoconsent/youtube-mobile.json +1 -1
  94. package/rules/rules.json +83 -83
  95. package/lib/index.ts +0 -4
@@ -0,0 +1,105 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+
4
+ export const snippets = {
5
+ // code-based rules
6
+ EVAL_0: () => console.log(1),
7
+ EVAL_CONSENTMANAGER_1: () => window.__cmp && typeof __cmp("getCMPData") === "object",
8
+ EVAL_CONSENTMANAGER_2: () => !__cmp('consentStatus').userChoiceExists,
9
+ EVAL_CONSENTMANAGER_3: () => __cmp('setConsent', 0),
10
+ EVAL_CONSENTMANAGER_4: () => __cmp('setConsent', 1),
11
+ EVAL_CONSENTMANAGER_5: () => __cmp('consentStatus').userChoiceExists,
12
+ EVAL_COOKIEBOT_1: () => window.CookieConsent.hasResponse !== true,
13
+ EVAL_COOKIEBOT_2: () => window.Cookiebot.dialog.submitConsent(),
14
+ EVAL_COOKIEBOT_3: () => endCookieProcess(),
15
+ EVAL_COOKIEBOT_4: () => window.CookieConsent.declined === true,
16
+ EVAL_KLARO_1: () => klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name]),
17
+ EVAL_ONETRUST_1: () => window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1,
18
+ EVAL_TRUSTARC_TOP: () => window && window.truste && window.truste.eu.bindMap.prefCookie === '0',
19
+
20
+ // declarative rules
21
+ EVAL_ADROLL_0: () => !document.cookie.includes('__adroll_fpc'),
22
+ EVAL_AFFINITY_SERIF_COM_0: () => document.cookie.includes('serif_manage_cookies_viewed') && !document.cookie.includes('serif_allow_analytics'),
23
+ EVAL_AXEPTIO_0: () => document.cookie.includes('axeptio_authorized_vendors=%2C%2C'),
24
+ EVAL_BING_0: () => document.cookie.includes('AL=0') && document.cookie.includes('AD=0') && document.cookie.includes('SM=0'),
25
+ EVAL_BORLABS_0: () => !JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('borlabs-cookie') !== -1).split('=', 2)[1])).consents.statistics,
26
+ EVAL_BUNDESREGIERUNG_DE_0: () => document.cookie.match('cookie-allow-tracking=0'),
27
+ EVAL_CANVA_0: () => !document.cookie.includes('gtm_fpc_engagement_event'),
28
+ EVAL_CLICKIO_0: () => document.cookie.includes('__lxG__consent__v2_daisybit='),
29
+ EVAL_CLINCH_0: () => document.cookie.includes('ctc_rejected=1'),
30
+ EVAL_COINBASE_0: () => JSON.parse(decodeURIComponent(document.cookie.match(/cm_(eu|default)_preferences=([0-9a-zA-Z\\{\\}\\[\\]%:]*);?/)[2])).consent.length <= 1,
31
+ EVAL_COMPLIANZ_BANNER_0: () => document.cookie.includes('cmplz_banner-status=dismissed'),
32
+ EVAL_COMPLIANZ_CATEGORIES_0: () => !!document.cookie.match(/cmplz_[^=]+=deny/),
33
+ EVAL_COMPLIANZ_OPTIN_0: () => !!document.cookie.match(/cookieconsent_preferences_disabled=[^;]+/),
34
+ EVAL_COOKIE_LAW_INFO_0: () => CLI.disableAllCookies() || CLI.reject_close() || true,
35
+ EVAL_COOKIE_LAW_INFO_1: () => document.cookie.indexOf('cookielawinfo-checkbox-non-necessary=yes') === -1,
36
+ EVAL_COOKIE_MANAGER_POPUP_0: () => JSON.parse(document.cookie.split(';').find(c => c.trim().startsWith('CookieLevel')).split('=')[1]).social === false,
37
+ EVAL_COOKIEALERT_0: () => document.querySelector('body').removeAttribute('style') || true,
38
+ EVAL_COOKIEALERT_1: () => document.querySelector('body').removeAttribute('style') || true,
39
+ EVAL_COOKIEALERT_2: () => window.CookieConsent.declined === true,
40
+ EVAL_COOKIEFIRST_0: () => ((o)=>o.performance === false && o.functional === false && o.advertising === false) (JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('cookiefirst') !== -1).trim()).split('=')[1])),
41
+ EVAL_COOKIEFIRST_1: () => document.querySelectorAll('button[data-cookiefirst-accent-color=true][role=checkbox]:not([disabled])').forEach(i => (i.getAttribute('aria-checked') == 'true' && i.click())) || true,
42
+ EVAL_COOKIEINFORMATION_0: () => CookieInformation.declineAllCategories() || true,
43
+ EVAL_COOKIEINFORMATION_1: () => CookieInformation.submitAllCategories() || true,
44
+ EVAL_COOKIEINFORMATION_2: () => document.cookie.includes('CookieInformationConsent='),
45
+ EVAL_DAILYMOTION_0: () => !!document.cookie.match('dm-euconsent-v2'),
46
+ EVAL_DSGVO_0: () => !document.cookie.includes('sp_dsgvo_cookie_settings'),
47
+ EVAL_DUNELM_0: () => document.cookie.includes('cc_functional=0') && document.cookie.includes('cc_targeting=0'),
48
+ EVAL_ETSY_0: () => document.querySelectorAll(".gdpr-overlay-body input").forEach(toggle => { toggle.checked = false; }) || true,
49
+ EVAL_ETSY_1: () => document.querySelector('.gdpr-overlay-view button[data-wt-overlay-close]').click() || true,
50
+ EVAL_EU_COOKIE_COMPLIANCE_0: () => document.cookie.indexOf('cookie-agreed=2') === -1,
51
+ EVAL_EU_COOKIE_LAW_0: () => !document.cookie.includes('euCookie'),
52
+ EVAL_EZOIC_0: () => ezCMP.handleAcceptAllClick(),
53
+ EVAL_EZOIC_1: () => !!document.cookie.match(/ezCMPCookieConsent=[^;]+\|2=0\|3=0\|4=0/),
54
+ EVAL_GOOGLE_0: () => !!document.cookie.match(/SOCS=CAE/),
55
+ EVAL_IUBENDA_0: () => document.querySelectorAll('.purposes-item input[type=checkbox]:not([disabled])').forEach(x => {if(x.checked) x.click()}) || true,
56
+ EVAL_IUBENDA_1: () => !!document.cookie.match(/_iub_cs-\d+=/),
57
+ EVAL_JQUERY_COOKIEBAR_0: () => !document.cookie.includes('cookies-state=accepted'),
58
+ EVAL_MEDIAVINE_0: () => document.querySelectorAll("[data-name=\"mediavine-gdpr-cmp\"] input[type=checkbox]").forEach(x => x.checked && x.click()) || true,
59
+ EVAL_MICROSOFT_0: () => Array.from(document.querySelectorAll('div > button')).filter(el => el.innerText.match('Reject|Ablehnen'))[0].click() || true,
60
+ EVAL_MICROSOFT_1: () => Array.from(document.querySelectorAll('div > button')).filter(el => el.innerText.match('Accept|Annehmen'))[0].click() || true,
61
+ EVAL_MICROSOFT_2: () => !!document.cookie.match('MSCC'),
62
+ EVAL_MOOVE_0: () => document.querySelectorAll('#moove_gdpr_cookie_modal input').forEach(i => { if (!i.disabled && i.name !== 'moove_gdpr_strict_cookies') i.checked = false }) || true,
63
+ EVAL_ONENINETWO_0: () => document.cookie.includes('CC_ADVERTISING=NO') && document.cookie.includes('CC_ANALYTICS=NO'),
64
+ EVAL_PAYPAL_0: () => document.cookie.includes('cookie_prefs') === true,
65
+ EVAL_PRIMEBOX_0: () => !document.cookie.includes('cb-enabled=accepted'),
66
+ EVAL_PUBTECH_0: () => document.cookie.includes('euconsent-v2') && (document.cookie.match(/.YAAAAAAAAAAA/) || document.cookie.match(/.aAAAAAAAAAAA/) || document.cookie.match(/.YAAACFgAAAAA/)) ,
67
+ EVAL_REDDIT_0: () => document.cookie.includes('eu_cookie={%22opted%22:true%2C%22nonessential%22:false}'),
68
+ EVAL_SIBBO_0: () => !!window.localStorage.getItem('euconsent-v2'),
69
+ EVAL_SIRDATA_0: () => document.cookie.includes('euconsent-v2'),
70
+ EVAL_SNIGEL_0: () => !!document.cookie.match('snconsent'),
71
+ EVAL_STEAMPOWERED_0: () => JSON.parse(decodeURIComponent(document.cookie.split(';').find(s => s.trim().startsWith('cookieSettings')).split('=')[1])).preference_state === 2,
72
+ EVAL_TARTEAUCITRON_0: () => tarteaucitron.userInterface.respondAll(false) || true,
73
+ EVAL_TARTEAUCITRON_1: () => tarteaucitron.userInterface.respondAll(true) || true,
74
+ EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)[0].includes('false'),
75
+ EVAL_TEALIUM_0: () => typeof window.utag !== 'undefined' && typeof utag.gdpr === 'object',
76
+ EVAL_TEALIUM_1: () => utag.gdpr.setConsentValue(false) || true,
77
+ EVAL_TEALIUM_2: () => utag.gdpr.setConsentValue(true) || true,
78
+ EVAL_TEALIUM_3: () => utag.gdpr.getConsentState() !== 1,
79
+ EVAL_TESTCMP_0: () => window.results.results[0] === 'button_clicked',
80
+ EVAL_TESTCMP_COSMETIC_0: () => window.results.results[0] === 'banner_hidden',
81
+ EVAL_THEFREEDICTIONARY_0: () => cmpUi.showPurposes() || cmpUi.rejectAll() || true,
82
+ EVAL_THEFREEDICTIONARY_1: () => cmpUi.allowAll() || true,
83
+ EVAL_THEVERGE_0: () => document.cookie.includes('_duet_gdpr_acknowledged=1'),
84
+ EVAL_UBUNTU_COM_0: () => document.cookie === '_cookies_accepted=essential',
85
+ EVAL_UK_COOKIE_CONSENT_0: () => !document.cookie.includes('catAccCookies'),
86
+ EVAL_USERCENTRICS_API_0: () => typeof UC_UI === 'object',
87
+ EVAL_USERCENTRICS_API_1: () => !!UC_UI.closeCMP(),
88
+ EVAL_USERCENTRICS_API_2: () => !!UC_UI.denyAllConsents(),
89
+ EVAL_USERCENTRICS_API_3: () => !!UC_UI.acceptAllConsents(),
90
+ EVAL_USERCENTRICS_API_4: () => !!UC_UI.closeCMP(),
91
+ EVAL_USERCENTRICS_API_5: () => UC_UI.areAllConsentsAccepted() === true,
92
+ EVAL_USERCENTRICS_API_6: () => UC_UI.areAllConsentsAccepted() === false,
93
+ EVAL_USERCENTRICS_BUTTON_0: () => JSON.parse(localStorage.getItem('usercentrics')).consents.every(c => c.isEssential || !c.consentStatus),
94
+ EVAL_WAITROSE_0: () => Array.from(document.querySelectorAll('label[id$=cookies-deny-label]')).forEach(e => e.click()) || true,
95
+ EVAL_WAITROSE_1: () => document.cookie.includes('wtr_cookies_advertising=0') && document.cookie.includes('wtr_cookies_analytics=0'),
96
+ EVAL_WP_COOKIE_NOTICE_0: () => document.cookie.includes('wpl_viewed_cookie=no'),
97
+ EVAL_XING_0: () => document.cookie.includes('userConsent=%7B%22marketing%22%3Afalse'),
98
+ EVAL_YOUTUBE_DESKTOP_0: () => !!document.cookie.match(/SOCS=CAE/),
99
+ EVAL_YOUTUBE_MOBILE_0: () => !!document.cookie.match(/SOCS=CAE/),
100
+ }
101
+
102
+ export function getFunctionBody(snippetFunc: () => any) {
103
+ const snippetStr = snippetFunc.toString();
104
+ return snippetStr.substring(snippetStr.indexOf("=>") + 2);
105
+ }
@@ -1,15 +1,7 @@
1
1
  import { enableLogs } from "./config";
2
- import { requestEval } from "./eval-handler";
3
2
  import { ElementSelector, HideMethod, VisibilityCheck } from "./rules";
4
3
  import { getStyleElement, hideElements, isElementVisible, waitFor } from "./utils";
5
4
 
6
- export function doEval(expr: string): Promise<boolean> {
7
- return requestEval(expr).catch((e) => {
8
- enableLogs && console.error('error evaluating rule', expr, e);
9
- return false;
10
- });
11
- }
12
-
13
5
  export function click(selector: ElementSelector, all = false): boolean {
14
6
  const elem = elementSelector(selector)
15
7
  enableLogs && console.log("[click]", selector, all, elem);
package/lib/rules.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { snippets } from "./eval-snippets"
2
+
1
3
  export type AutoConsentCMPRule = {
2
4
  name: string
3
5
  prehideSelectors?: string[]
@@ -47,7 +49,7 @@ export type ElementVisibleRule = {
47
49
  };
48
50
 
49
51
  export type EvalRule = {
50
- eval: string;
52
+ eval: keyof typeof snippets;
51
53
  };
52
54
 
53
55
  export type WaitForRule = {
package/lib/types.ts CHANGED
@@ -34,6 +34,7 @@ export type Config = {
34
34
  enablePrehide: boolean;
35
35
  enableCosmeticRules: boolean;
36
36
  detectRetries: number;
37
+ isMainWorld: boolean;
37
38
  prehideTimeout: number;
38
39
  }
39
40
 
@@ -60,4 +61,3 @@ export type ConsentState = {
60
61
  detectedPopups: string[]; // Names of CMP rules where `detectPopup` returned true.
61
62
  selfTest: boolean; // null if no self test was run, otherwise it holds the result of the self test.
62
63
  }
63
-
package/lib/web.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { rules as dynamicRules, createAutoCMP } from './index';
2
1
  import { MessageSender, AutoCMP, RuleBundle, Config, ConsentState } from './types';
3
2
  import { ConsentOMaticCMP, ConsentOMaticConfig } from './cmps/consentomatic';
4
3
  import { AutoConsentCMPRule } from './rules';
@@ -7,8 +6,8 @@ import { BackgroundMessage, InitMessage } from './messages';
7
6
  import { prehide, undoPrehide, wait } from './rule-executors';
8
7
  import { evalState, resolveEval } from './eval-handler';
9
8
  import { getRandomID } from './random';
10
-
11
- export * from './index';
9
+ import { dynamicCMPs } from './cmps/all';
10
+ import { AutoConsentCMP } from './cmps/base';
12
11
 
13
12
  function filterCMPs(rules: AutoCMP[], config: Config) {
14
13
  return rules.filter((cmp) => {
@@ -38,15 +37,17 @@ export default class AutoConsent {
38
37
  constructor(sendContentMessage: MessageSender, config: Config = null, declarativeRules: RuleBundle = null) {
39
38
  evalState.sendContentMessage = sendContentMessage;
40
39
  this.sendContentMessage = sendContentMessage;
41
- this.rules = [...dynamicRules];
40
+ this.rules = [];
42
41
 
43
42
  enableLogs && console.log('autoconsent init', window.location.href);
44
43
  this.updateState({ lifecycle: 'loading' });
44
+
45
+ this.addDynamicRules();
45
46
  if (config) {
46
47
  this.initialize(config, declarativeRules);
47
48
  } else {
48
49
  if (declarativeRules) {
49
- this.parseRules(declarativeRules);
50
+ this.parseDeclarativeRules(declarativeRules);
50
51
  }
51
52
  const initMsg: InitMessage = {
52
53
  type: "init",
@@ -65,7 +66,7 @@ export default class AutoConsent {
65
66
  }
66
67
 
67
68
  if (declarativeRules) {
68
- this.parseRules(declarativeRules);
69
+ this.parseDeclarativeRules(declarativeRules);
69
70
  }
70
71
 
71
72
  this.rules = filterCMPs(this.rules, config);
@@ -96,18 +97,24 @@ export default class AutoConsent {
96
97
  this.updateState({ lifecycle: 'initialized' });
97
98
  }
98
99
 
99
- parseRules(declarativeRules: RuleBundle) {
100
+ addDynamicRules() {
101
+ dynamicCMPs.forEach((cmp) => {
102
+ this.rules.push(new cmp(this));
103
+ });
104
+ }
105
+
106
+ parseDeclarativeRules(declarativeRules: RuleBundle) {
100
107
  Object.keys(declarativeRules.consentomatic).forEach((name) => {
101
108
  this.addConsentomaticCMP(name, declarativeRules.consentomatic[name]);
102
109
  });
103
- declarativeRules.autoconsent.forEach((rule) => {
104
- this.addCMP(rule);
110
+ declarativeRules.autoconsent.forEach((ruleset) => {
111
+ this.addDeclarativeCMP(ruleset);
105
112
  });
106
113
  enableLogs && console.log("added rules", this.rules);
107
114
  }
108
115
 
109
- addCMP(config: AutoConsentCMPRule) {
110
- this.rules.push(createAutoCMP(config));
116
+ addDeclarativeCMP(ruleset: AutoConsentCMPRule) {
117
+ this.rules.push(new AutoConsentCMP(ruleset, this));
111
118
  }
112
119
 
113
120
  addConsentomaticCMP(name: string, config: ConsentOMaticConfig) {
@@ -221,7 +228,10 @@ export default class AutoConsent {
221
228
  }); // notify the browser
222
229
  result.push(cmp);
223
230
  }
224
- }).catch(() => null));
231
+ }).catch((e) => {
232
+ enableLogs && console.warn(`error waiting for a popup for ${cmp.name}`, e);
233
+ return null
234
+ }));
225
235
  await Promise.all(popupLookups);
226
236
  return result;
227
237
  }
@@ -326,7 +336,10 @@ export default class AutoConsent {
326
336
 
327
337
  async waitForPopup(cmp: AutoCMP, retries = 5, interval = 500): Promise<boolean> {
328
338
  enableLogs && console.log('checking if popup is open...', cmp.name);
329
- const isOpen = await cmp.detectPopup();
339
+ const isOpen = await cmp.detectPopup().catch((e) => {
340
+ enableLogs && console.warn(`error detecting popup for ${cmp.name}`, e);
341
+ return false;
342
+ }); // ignore possible errors in one-time popup detection
330
343
  if (!isOpen && retries > 0) {
331
344
  await wait(interval);
332
345
  return this.waitForPopup(cmp, retries - 1, interval);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckduckgo/autoconsent",
3
- "version": "5.3.0",
3
+ "version": "6.0.0",
4
4
  "description": "",
5
5
  "main": "dist/autoconsent.cjs.js",
6
6
  "module": "dist/autoconsent.esm.js",
package/readme.md CHANGED
@@ -165,11 +165,11 @@ Hide the elements matched by the selectors. `method` defines how elements are hi
165
165
 
166
166
  ```json
167
167
  {
168
- "eval": "code"
168
+ "eval": "SNIPPET_ID"
169
169
  }
170
170
  ```
171
- Evaluates `code` in the context of the page. The rule is considered successful if it *evaluates to a truthy value*.
172
- Eval rules are not 100% reliable because they can be blocked by a CSP policy on the page. Therefore, they should only be used as a last resort when none of the other rules are sufficient.
171
+ Evaluates a code snippet in the context of the page. The rule is considered successful if it *evaluates to a truthy value*. Snippets have to be explicitly defined in [snippets.ts](./lib/eval-snippets.ts).
172
+ Eval rules are not 100% reliable because they can be affected by the page scripts, or blocked by a CSP policy on the page. Therefore, they should only be used as a last resort when none of the other rules are sufficient.
173
173
 
174
174
  ### Conditionals
175
175
 
@@ -12,6 +12,6 @@
12
12
  }
13
13
  ],
14
14
  "test": [
15
- {"eval": "document.cookie.includes('CC_ADVERTISING=NO') && document.cookie.includes('CC_ANALYTICS=NO')"}
15
+ {"eval": "EVAL_ONENINETWO_0"}
16
16
  ]
17
17
  }
@@ -6,6 +6,6 @@
6
6
  "optIn": [ { "waitForThenClick": "#adroll_consent_accept" } ],
7
7
  "optOut": [ { "waitForThenClick": "#adroll_consent_reject" } ],
8
8
  "test": [
9
- { "eval": "!document.cookie.includes('__adroll_fpc')" }
9
+ { "eval": "EVAL_ADROLL_0" }
10
10
  ]
11
11
  }
@@ -31,7 +31,7 @@
31
31
  "wait": 500
32
32
  },
33
33
  {
34
- "eval": "document.cookie.includes('serif_manage_cookies_viewed') && !document.cookie.includes('serif_allow_analytics')"
34
+ "eval": "EVAL_AFFINITY_SERIF_COM_0"
35
35
  }
36
36
  ]
37
37
  }
@@ -35,7 +35,7 @@
35
35
  "test":
36
36
  [
37
37
  {
38
- "eval": "document.cookie.includes('axeptio_authorized_vendors=%2C%2C')"
38
+ "eval": "EVAL_AXEPTIO_0"
39
39
  }
40
40
  ]
41
41
  }
@@ -9,6 +9,6 @@
9
9
  { "click": "#mcp_savesettings"}
10
10
  ],
11
11
  "test": [
12
- { "eval": "document.cookie.includes('AL=0') && document.cookie.includes('AD=0') && document.cookie.includes('SM=0')"}
12
+ { "eval": "EVAL_BING_0"}
13
13
  ]
14
14
  }
@@ -38,6 +38,6 @@
38
38
  "#BorlabsCookieBox"
39
39
  ],
40
40
  "test": [{
41
- "eval": "!JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('borlabs-cookie') !== -1).split('=', 2)[1])).consents.statistics"
41
+ "eval": "EVAL_BORLABS_0"
42
42
  }]
43
43
  }
@@ -14,6 +14,6 @@
14
14
  }
15
15
  ],
16
16
  "test": [
17
- {"eval": "document.cookie.match('cookie-allow-tracking=0')"}
17
+ {"eval": "EVAL_BUNDESREGIERUNG_DE_0"}
18
18
  ]
19
19
  }
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "test": [
22
- { "eval": "!document.cookie.includes('gtm_fpc_engagement_event')" }
22
+ { "eval": "EVAL_CANVA_0" }
23
23
  ]
24
24
  }
25
25
 
@@ -13,6 +13,6 @@
13
13
  { "click": "[data-role=\"b_save\"]" }
14
14
  ],
15
15
  "test": [
16
- { "eval": "document.cookie.includes('__lxG__consent__v2_daisybit=')", "comment": "TODO: this only checks if we interacted at all" }
16
+ { "eval": "EVAL_CLICKIO_0", "comment": "TODO: this only checks if we interacted at all" }
17
17
  ]
18
18
  }
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "test": [
40
40
  {
41
- "eval": "document.cookie.includes('ctc_rejected=1')"
41
+ "eval": "EVAL_CLINCH_0"
42
42
  }
43
43
  ]
44
44
  }
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "test": [
39
39
  {
40
- "eval": "JSON.parse(decodeURIComponent(document.cookie.match(/cm_(eu|default)_preferences=([0-9a-zA-Z\\{\\}\\[\\]%:]*);?/)[2])).consent.length <= 1"
40
+ "eval": "EVAL_COINBASE_0"
41
41
  }
42
42
  ]
43
43
  }
@@ -9,5 +9,5 @@
9
9
  "optOut": [
10
10
  { "waitForThenClick": ".cmplz-cookiebanner .cmplz-deny" }
11
11
  ],
12
- "test": [ { "eval": "document.cookie.includes('cmplz_banner-status=dismissed')" } ]
12
+ "test": [ { "eval": "EVAL_COMPLIANZ_BANNER_0" } ]
13
13
  }
@@ -12,6 +12,6 @@
12
12
  { "click": ".cc-dismiss" }
13
13
  ],
14
14
  "test": [
15
- { "eval": "!!document.cookie.match(/cmplz_[^=]+=deny/)" }
15
+ { "eval": "EVAL_COMPLIANZ_CATEGORIES_0" }
16
16
  ]
17
17
  }
@@ -15,6 +15,6 @@
15
15
  { "click": "[aria-label=\"cookies preferences popup\"] [aria-label=\"Accept Selected\"], [aria-label=\"cookies preferences popup\"] [aria-label=\"Save my choice\"], .cc-btn-accept-selected, .cc-deny", "optional": true }
16
16
  ],
17
17
  "test": [
18
- { "eval": "!!document.cookie.match(/cookieconsent_preferences_disabled=[^;]+/)" }
18
+ { "eval": "EVAL_COMPLIANZ_OPTIN_0" }
19
19
  ]
20
20
  }
@@ -7,8 +7,8 @@
7
7
  "optOut": [
8
8
  { "hide": ["#cookie-law-info-bar"] },
9
9
  {
10
- "eval": "CLI.disableAllCookies() || CLI.reject_close() || true"
10
+ "eval": "EVAL_COOKIE_LAW_INFO_0"
11
11
  }
12
12
  ],
13
- "test": [{ "eval": "document.cookie.indexOf('cookielawinfo-checkbox-non-necessary=yes') === -1" }]
13
+ "test": [{ "eval": "EVAL_COOKIE_LAW_INFO_1" }]
14
14
  }
@@ -37,6 +37,6 @@
37
37
  ],
38
38
  "prehideSelectors": ["#btn-cookie-settings"],
39
39
  "test": [{
40
- "eval": "JSON.parse(document.cookie.split(';').find(c => c.trim().startsWith('CookieLevel')).split('=')[1]).social === false"
40
+ "eval": "EVAL_COOKIE_MANAGER_POPUP_0"
41
41
  }]
42
42
  }
@@ -21,7 +21,7 @@
21
21
  "click": "button[data-controller='cookie-alert/extended/button/accept']"
22
22
  },
23
23
  {
24
- "eval": "document.querySelector('body').removeAttribute('style') || true"
24
+ "eval": "EVAL_COOKIEALERT_0"
25
25
  }
26
26
  ],
27
27
  "optOut": [
@@ -37,12 +37,12 @@
37
37
  "click": "button[data-controller='cookie-alert/extended/button/configuration']"
38
38
  },
39
39
  {
40
- "eval": "document.querySelector('body').removeAttribute('style') || true"
40
+ "eval": "EVAL_COOKIEALERT_0"
41
41
  }
42
42
  ],
43
43
  "test": [
44
44
  {
45
- "eval": "window.CookieConsent.declined === true"
45
+ "eval": "EVAL_COOKIEALERT_2"
46
46
  }
47
47
  ]
48
48
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "cookiefirst.com",
3
- "prehideSelectors": ["#cookiefirst-root"],
4
- "detectCmp": [{ "exists": "#cookiefirst-root" }],
5
- "detectPopup": [{ "visible": "#cookiefirst-root" }],
3
+ "prehideSelectors": ["#cookiefirst-root,.cookiefirst-root,[aria-labelledby=cookie-preference-panel-title]"],
4
+ "detectCmp": [{ "exists": "#cookiefirst-root,.cookiefirst-root" }],
5
+ "detectPopup": [{ "visible": "#cookiefirst-root,.cookiefirst-root" }],
6
6
  "optIn": [{ "click": "button[data-cookiefirst-action=accept]" }],
7
7
  "optOut": [
8
8
  {
@@ -13,12 +13,12 @@
13
13
  {
14
14
  "click": "button[data-cookiefirst-action=adjust]"
15
15
  },
16
- {
16
+ {
17
17
  "waitForVisible": "[data-cookiefirst-widget=modal]",
18
18
  "timeout": 1000
19
19
  },
20
20
  {
21
- "eval": "document.querySelectorAll('button[data-cookiefirst-accent-color=true][role=checkbox]:not([disabled])').forEach(i => (i.getAttribute('aria-checked') == 'true' && i.click())) || true"
21
+ "eval": "EVAL_COOKIEFIRST_1"
22
22
  },
23
23
  {
24
24
  "wait": 1000
@@ -34,8 +34,7 @@
34
34
  ],
35
35
  "test": [
36
36
  {
37
- "eval": "let o = JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('cookiefirst') !== -1).trim()).split('=')[1]); (o.performance === false && o.functional === false && o.advertising === false) ? true : false"
37
+ "eval": "EVAL_COOKIEFIRST_0"
38
38
  }
39
39
  ]
40
- }
41
-
40
+ }
@@ -3,12 +3,12 @@
3
3
  "prehideSelectors": ["#cookie-information-template-wrapper"],
4
4
  "detectCmp": [{ "exists": "#cookie-information-template-wrapper" }],
5
5
  "detectPopup": [{ "visible": "#cookie-information-template-wrapper" }],
6
- "optIn": [ { "eval": "CookieInformation.submitAllCategories() || true"} ],
6
+ "optIn": [ { "eval": "EVAL_COOKIEINFORMATION_1"} ],
7
7
  "optOut": [
8
8
  { "hide": ["#cookie-information-template-wrapper"], "comment": "some templates don't hide the banner automatically" },
9
- { "eval": "CookieInformation.declineAllCategories() || true"}
9
+ { "eval": "EVAL_COOKIEINFORMATION_0"}
10
10
  ],
11
11
  "test": [
12
- { "eval": "document.cookie.includes('CookieInformationConsent=')" }
12
+ { "eval": "EVAL_COOKIEINFORMATION_2" }
13
13
  ]
14
14
  }
@@ -17,6 +17,6 @@
17
17
  { "waitForThenClick": "button[class*=\"TCF2ContinueWithoutAcceptingButton\"]" }
18
18
  ],
19
19
  "test": [
20
- { "eval": "!!document.cookie.match('dm-euconsent-v2')" }
20
+ { "eval": "EVAL_DAILYMOTION_0" }
21
21
  ]
22
22
  }
@@ -12,6 +12,6 @@
12
12
  { "hide": [".sp-dsgvo.sp-dsgvo-popup-overlay"] }
13
13
  ],
14
14
  "test": [
15
- { "eval": "!document.cookie.includes('sp_dsgvo_cookie_settings')" }
15
+ { "eval": "EVAL_DSGVO_0" }
16
16
  ]
17
17
  }
@@ -13,6 +13,6 @@
13
13
  }
14
14
  ],
15
15
  "test": [
16
- {"eval": "document.cookie.includes('cc_functional=0') && document.cookie.includes('cc_targeting=0')"}
16
+ {"eval": "EVAL_DUNELM_0"}
17
17
  ]
18
18
  }
@@ -7,8 +7,8 @@
7
7
  {"click": "button[data-gdpr-open-full-settings]"},
8
8
  {"waitForVisible": ".gdpr-overlay-body input", "timeout": 3000},
9
9
  {"wait": 1000},
10
- {"eval": "document.querySelectorAll(\".gdpr-overlay-body input\").forEach(toggle => { toggle.checked = false; }) || true"},
11
- {"eval": "document.querySelector('.gdpr-overlay-view button[data-wt-overlay-close]').click() || true"}
10
+ {"eval": "EVAL_ETSY_0"},
11
+ {"eval": "EVAL_ETSY_1"}
12
12
  ],
13
13
  "optIn": [{"click": "button[data-gdpr-single-choice-accept]"}]
14
14
  }
@@ -8,6 +8,6 @@
8
8
  { "hide": [".eu-cookie-compliance-banner-info", "#sliding-popup"] }
9
9
  ],
10
10
  "test": [
11
- { "eval": "document.cookie.indexOf('cookie-agreed=2') === -1" }
11
+ { "eval": "EVAL_EU_COOKIE_COMPLIANCE_0" }
12
12
  ]
13
13
  }
@@ -16,6 +16,6 @@
16
16
  { "hide": [".pea_cook_wrapper"] }
17
17
  ],
18
18
  "test": [
19
- { "eval": "!document.cookie.includes('euCookie')" }
19
+ { "eval": "EVAL_EU_COOKIE_LAW_0" }
20
20
  ]
21
21
  }
@@ -5,7 +5,7 @@
5
5
  "detectPopup": [{ "visible": "#ez-cookie-dialog-wrapper" }],
6
6
  "optIn": [
7
7
  { "click": "#ez-accept-all", "optional": true },
8
- { "eval": "ezCMP.handleAcceptAllClick()", "optional": true }
8
+ { "eval": "EVAL_EZOIC_0", "optional": true }
9
9
  ],
10
10
  "optOut": [
11
11
  { "wait": 500 },
@@ -15,6 +15,6 @@
15
15
  { "click": "#ez-save-settings" }
16
16
  ],
17
17
  "test": [
18
- { "eval": "!!document.cookie.match(/ezCMPCookieConsent=[^;]+\\|2=0\\|3=0\\|4=0/)" }
18
+ { "eval": "EVAL_EZOIC_1" }
19
19
  ]
20
20
  }
@@ -17,6 +17,6 @@
17
17
  }
18
18
  ],
19
19
  "test": [
20
- { "eval": "!!document.cookie.match(/SOCS=CAE/)" }
20
+ { "eval": "EVAL_GOOGLE_0" }
21
21
  ]
22
22
  }
@@ -11,13 +11,13 @@
11
11
  "click": ".iubenda-cs-customize-btn"
12
12
  },
13
13
  {
14
- "eval": "document.querySelectorAll('.purposes-item input[type=checkbox]:not([disabled])').forEach(x => {if(x.checked) x.click()}) || true"
14
+ "eval": "EVAL_IUBENDA_0"
15
15
  },
16
16
  {
17
17
  "click": "#iubFooterBtn"
18
18
  }
19
19
  ],
20
20
  "test": [
21
- { "eval": "!!document.cookie.match(/_iub_cs-\\d+=/)" }
21
+ { "eval": "EVAL_IUBENDA_1" }
22
22
  ]
23
23
  }
@@ -20,7 +20,7 @@
20
20
  "check": "none"
21
21
  },
22
22
  {
23
- "eval": "!document.cookie.includes('cookies-state=accepted')"
23
+ "eval": "EVAL_JQUERY_COOKIEBAR_0"
24
24
  }
25
25
  ]
26
26
  }
@@ -14,7 +14,7 @@
14
14
  "optOut": [
15
15
  { "waitForThenClick": "[data-name=\"mediavine-gdpr-cmp\"] [data-view=\"manageSettings\"]" },
16
16
  { "waitFor": "[data-name=\"mediavine-gdpr-cmp\"] input[type=checkbox]" },
17
- { "eval": "document.querySelectorAll(\"[data-name=\\\"mediavine-gdpr-cmp\\\"] input[type=checkbox]\").forEach(x => x.checked && x.click()) || true", "optional": true },
17
+ { "eval": "EVAL_MEDIAVINE_0", "optional": true },
18
18
  { "click": "[data-name=\"mediavine-gdpr-cmp\"] [format=\"secondary\"]" }
19
19
  ]
20
20
  }