@duckduckgo/autoconsent 15.1.0 → 16.1.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 (89) hide show
  1. package/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  2. package/.github/dependabot.yml +0 -3
  3. package/.github/labeler.yml +36 -0
  4. package/.github/workflows/release-labels.yml +110 -0
  5. package/.github/workflows/release.yml +0 -4
  6. package/AGENTS.md +3 -3
  7. package/CHANGELOG.md +33 -0
  8. package/build.sh +0 -2
  9. package/dist/addon-firefox/background.bundle.js +8 -24
  10. package/dist/addon-firefox/compact-rules.json +1 -1
  11. package/dist/addon-firefox/content.bundle.js +176 -686
  12. package/dist/addon-firefox/manifest.json +1 -1
  13. package/dist/addon-firefox/popup.bundle.js +31 -27
  14. package/dist/addon-firefox/popup.html +21 -13
  15. package/dist/addon-firefox/rule-index.json +1 -1
  16. package/dist/addon-firefox/rules.json +1 -1
  17. package/dist/addon-mv3/background.bundle.js +8 -24
  18. package/dist/addon-mv3/compact-rules.json +1 -1
  19. package/dist/addon-mv3/content.bundle.js +176 -686
  20. package/dist/addon-mv3/manifest.json +1 -1
  21. package/dist/addon-mv3/popup.bundle.js +31 -27
  22. package/dist/addon-mv3/popup.html +21 -13
  23. package/dist/addon-mv3/rule-index.json +1 -1
  24. package/dist/addon-mv3/rules.json +1 -1
  25. package/dist/autoconsent.cjs.js +176 -685
  26. package/dist/autoconsent.esm.js +176 -685
  27. package/dist/autoconsent.playwright.js +177 -689
  28. package/dist/autoconsent.standalone.js +177 -690
  29. package/dist/types/cmps/base.d.ts +3 -3
  30. package/dist/types/heuristics.d.ts +2 -2
  31. package/dist/types/types.d.ts +10 -23
  32. package/dist/types/web.d.ts +0 -9
  33. package/docs/api.md +1 -8
  34. package/docs/puppeteer.md +1 -3
  35. package/docs/release-notes.md +65 -0
  36. package/docs/rule-syntax.md +0 -17
  37. package/eslint.config.mjs +1 -1
  38. package/lib/cmps/base.ts +5 -6
  39. package/lib/heuristics.ts +15 -15
  40. package/lib/types.ts +9 -21
  41. package/lib/utils.ts +2 -4
  42. package/lib/web.ts +3 -53
  43. package/package.json +112 -18
  44. package/playwright/content.ts +1 -2
  45. package/readme.md +3 -6
  46. package/rules/autoconsent/dreamlab-cmp.json +13 -0
  47. package/rules/build.ts +1 -24
  48. package/rules/compact-rules.json +1 -1
  49. package/rules/rule-index-builder.ts +2 -7
  50. package/rules/rule-index.json +1 -1
  51. package/rules/rules.json +1 -1
  52. package/scripts/check-pr-release-labels.ts +255 -0
  53. package/standalone/content.ts +0 -2
  54. package/tests/dreamlab-cmp.spec.ts +3 -0
  55. package/tests/quantcast.spec.ts +0 -6
  56. package/tests-wtr/heuristics/get-actionable-popups.ts +13 -13
  57. package/tests-wtr/heuristics/heuristic-cmp.ts +32 -33
  58. package/tests-wtr/lifecycle/find-cmp.ts +5 -8
  59. package/tests-wtr/web/do-opt-in.test.ts +0 -1
  60. package/tests-wtr/web/do-opt-out.test.ts +0 -1
  61. package/tests-wtr/web/do-self-test.test.ts +0 -1
  62. package/tests-wtr/web/filter-cmps.test.ts +0 -1
  63. package/tests-wtr/web/receive-message-callback.test.ts +1 -2
  64. package/tests-wtr/web/update-state.test.ts +1 -3
  65. package/tsconfig.build.json +1 -1
  66. package/.github/workflows/update-filterlist.yml +0 -42
  67. package/dist/autoconsent.extra.cjs.js +0 -15717
  68. package/dist/autoconsent.extra.esm.js +0 -15649
  69. package/dist/types/cmps/consentomatic.d.ts +0 -34
  70. package/dist/types/consentomatic/index.d.ts +0 -2
  71. package/dist/types/consentomatic/tools.d.ts +0 -10
  72. package/dist/types/filterlist-engine.d.ts +0 -2
  73. package/dist/types/filterlist-utils.d.ts +0 -4
  74. package/dist/types/web-extra.d.ts +0 -11
  75. package/lib/cmps/consentomatic.ts +0 -97
  76. package/lib/consentomatic/index.ts +0 -252
  77. package/lib/consentomatic/tools.ts +0 -199
  78. package/lib/filterlist-engine.ts +0 -5
  79. package/lib/filterlist-utils.ts +0 -45
  80. package/lib/web-extra.ts +0 -116
  81. package/rules/consentomatic.json +0 -1
  82. package/rules/filterlist.txt +0 -18440
  83. package/rules/filterlists/overrides.txt +0 -4
  84. package/scripts/compile-filterlist.mjs +0 -63
  85. package/scripts/fetch-easylist.sh +0 -25
  86. package/scripts/rebuild-filterlist.mjs +0 -216
  87. package/tests/oil.spec.ts +0 -7
  88. package/tests/springer.spec.ts +0 -7
  89. package/tests/wordpressgdpr.spec.ts +0 -6
@@ -1,412 +1,7 @@
1
1
  "use strict";
2
2
  (() => {
3
- // lib/consentomatic/tools.ts
4
- var Tools = class _Tools {
5
- static {
6
- this.base = null;
7
- }
8
- static setBase(base) {
9
- _Tools.base = base;
10
- }
11
- static findElement(options, parent = null, multiple = false) {
12
- let possibleTargets = null;
13
- if (parent != null) {
14
- possibleTargets = Array.from(parent.querySelectorAll(options.selector));
15
- } else {
16
- if (_Tools.base != null) {
17
- possibleTargets = Array.from(
18
- _Tools.base.querySelectorAll(options.selector)
19
- );
20
- } else {
21
- possibleTargets = Array.from(
22
- document.querySelectorAll(options.selector)
23
- );
24
- }
25
- }
26
- if (options.textFilter != null) {
27
- possibleTargets = possibleTargets.filter((possibleTarget) => {
28
- const textContent = possibleTarget.textContent.toLowerCase();
29
- if (Array.isArray(options.textFilter)) {
30
- let foundText = false;
31
- for (const text of options.textFilter) {
32
- if (textContent.indexOf(text.toLowerCase()) !== -1) {
33
- foundText = true;
34
- break;
35
- }
36
- }
37
- return foundText;
38
- } else if (options.textFilter != null) {
39
- return textContent.indexOf(options.textFilter.toLowerCase()) !== -1;
40
- }
41
- return false;
42
- });
43
- }
44
- if (options.styleFilters != null) {
45
- possibleTargets = possibleTargets.filter((possibleTarget) => {
46
- const styles = window.getComputedStyle(possibleTarget);
47
- let keep = true;
48
- for (const styleFilter of options.styleFilters) {
49
- const option = styles[styleFilter.option];
50
- if (styleFilter.negated) {
51
- keep = keep && option !== styleFilter.value;
52
- } else {
53
- keep = keep && option === styleFilter.value;
54
- }
55
- }
56
- return keep;
57
- });
58
- }
59
- if (options.displayFilter != null) {
60
- possibleTargets = possibleTargets.filter((possibleTarget) => {
61
- if (options.displayFilter) {
62
- return possibleTarget.offsetHeight !== 0;
63
- } else {
64
- return possibleTarget.offsetHeight === 0;
65
- }
66
- });
67
- }
68
- if (options.iframeFilter != null) {
69
- possibleTargets = possibleTargets.filter(() => {
70
- if (options.iframeFilter) {
71
- return window.location !== window.parent.location;
72
- } else {
73
- return window.location === window.parent.location;
74
- }
75
- });
76
- }
77
- if (options.childFilter != null) {
78
- possibleTargets = possibleTargets.filter((possibleTarget) => {
79
- const oldBase = _Tools.base;
80
- _Tools.setBase(possibleTarget);
81
- const childResults = _Tools.find(options.childFilter);
82
- _Tools.setBase(oldBase);
83
- return childResults.target != null;
84
- });
85
- }
86
- if (multiple) {
87
- return possibleTargets;
88
- } else {
89
- if (possibleTargets.length > 1) {
90
- console.warn(
91
- "Multiple possible targets: ",
92
- possibleTargets,
93
- options,
94
- parent
95
- );
96
- }
97
- return possibleTargets[0];
98
- }
99
- }
100
- static find(options, multiple = false) {
101
- const results = [];
102
- if (options.parent != null) {
103
- const parent = _Tools.findElement(options.parent, null, multiple);
104
- if (parent != null) {
105
- if (parent instanceof Array) {
106
- parent.forEach((p) => {
107
- const targets = _Tools.findElement(options.target, p, multiple);
108
- if (targets instanceof Array) {
109
- targets.forEach((target) => {
110
- results.push({
111
- parent: p,
112
- target
113
- });
114
- });
115
- } else {
116
- results.push({
117
- parent: p,
118
- target: targets
119
- });
120
- }
121
- });
122
- return results;
123
- } else {
124
- const targets = _Tools.findElement(options.target, parent, multiple);
125
- if (targets instanceof Array) {
126
- targets.forEach((target) => {
127
- results.push({
128
- parent,
129
- target
130
- });
131
- });
132
- } else {
133
- results.push({
134
- parent,
135
- target: targets
136
- });
137
- }
138
- }
139
- }
140
- } else {
141
- const targets = _Tools.findElement(options.target, null, multiple);
142
- if (targets instanceof Array) {
143
- targets.forEach((target) => {
144
- results.push({
145
- parent: null,
146
- target
147
- });
148
- });
149
- } else {
150
- results.push({
151
- parent: null,
152
- target: targets
153
- });
154
- }
155
- }
156
- if (results.length === 0) {
157
- results.push({
158
- parent: null,
159
- target: null
160
- });
161
- }
162
- if (multiple) {
163
- return results;
164
- } else {
165
- if (results.length !== 1) {
166
- console.warn(
167
- "Multiple results found, even though multiple false",
168
- results
169
- );
170
- }
171
- return results[0];
172
- }
173
- }
174
- };
175
-
176
- // lib/consentomatic/index.ts
177
- function matches(config) {
178
- const result = Tools.find(config);
179
- if (config.type === "css") {
180
- return !!result.target;
181
- } else if (config.type === "checkbox") {
182
- return !!result.target && result.target.checked;
183
- }
184
- }
185
- async function executeAction(config, param) {
186
- switch (config.type) {
187
- case "click":
188
- return clickAction(config);
189
- case "list":
190
- return listAction(config, param);
191
- case "consent":
192
- return consentAction(config, param);
193
- case "ifcss":
194
- return ifCssAction(config, param);
195
- case "waitcss":
196
- return waitCssAction(config);
197
- case "foreach":
198
- return forEachAction(config, param);
199
- case "hide":
200
- return hideAction(config);
201
- case "slide":
202
- return slideAction(config);
203
- case "close":
204
- return closeAction();
205
- case "wait":
206
- return waitAction(config);
207
- case "eval":
208
- return evalAction(config);
209
- default:
210
- throw new Error("Unknown action type: " + config.type);
211
- }
212
- }
213
- var STEP_TIMEOUT = 0;
214
- function waitTimeout(timeout) {
215
- return new Promise((resolve) => {
216
- setTimeout(() => {
217
- resolve();
218
- }, timeout);
219
- });
220
- }
221
- async function clickAction(config) {
222
- const result = Tools.find(config);
223
- if (result.target != null) {
224
- result.target.click();
225
- }
226
- return waitTimeout(STEP_TIMEOUT);
227
- }
228
- async function listAction(config, param) {
229
- for (const action of config.actions) {
230
- await executeAction(action, param);
231
- }
232
- }
233
- async function consentAction(config, consentTypes) {
234
- for (const consentConfig of config.consents) {
235
- const shouldEnable = consentTypes.indexOf(consentConfig.type) !== -1;
236
- if (consentConfig.matcher && consentConfig.toggleAction) {
237
- const isEnabled = matches(consentConfig.matcher);
238
- if (isEnabled !== shouldEnable) {
239
- await executeAction(consentConfig.toggleAction);
240
- }
241
- } else {
242
- if (shouldEnable) {
243
- await executeAction(consentConfig.trueAction);
244
- } else {
245
- await executeAction(consentConfig.falseAction);
246
- }
247
- }
248
- }
249
- }
250
- async function ifCssAction(config, param) {
251
- const result = Tools.find(config);
252
- if (!result.target) {
253
- if (config.trueAction) {
254
- await executeAction(config.trueAction, param);
255
- }
256
- } else {
257
- if (config.falseAction) {
258
- await executeAction(config.falseAction, param);
259
- }
260
- }
261
- }
262
- async function waitCssAction(config) {
263
- await new Promise((resolve) => {
264
- let numRetries = config.retries || 10;
265
- const waitTime = config.waitTime || 250;
266
- const checkCss = () => {
267
- const result = Tools.find(config);
268
- if (config.negated && result.target || !config.negated && !result.target) {
269
- if (numRetries > 0) {
270
- numRetries -= 1;
271
- setTimeout(checkCss, waitTime);
272
- } else {
273
- resolve();
274
- }
275
- } else {
276
- resolve();
277
- }
278
- };
279
- checkCss();
280
- });
281
- }
282
- async function forEachAction(config, param) {
283
- const results = Tools.find(config, true);
284
- const oldBase = Tools.base;
285
- for (const result of results) {
286
- if (result.target) {
287
- Tools.setBase(result.target);
288
- await executeAction(config.action, param);
289
- }
290
- }
291
- Tools.setBase(oldBase);
292
- }
293
- async function hideAction(config) {
294
- const result = Tools.find(config);
295
- if (result.target) {
296
- result.target.classList.add("Autoconsent-Hidden");
297
- }
298
- }
299
- async function slideAction(config) {
300
- const result = Tools.find(config);
301
- const dragResult = Tools.find(config.dragTarget);
302
- if (result.target) {
303
- const targetBounds = result.target.getBoundingClientRect();
304
- const dragTargetBounds = dragResult.target.getBoundingClientRect();
305
- let yDiff = dragTargetBounds.top - targetBounds.top;
306
- let xDiff = dragTargetBounds.left - targetBounds.left;
307
- if (this.config.axis.toLowerCase() === "y") {
308
- xDiff = 0;
309
- }
310
- if (this.config.axis.toLowerCase() === "x") {
311
- yDiff = 0;
312
- }
313
- const screenX = window.screenX + targetBounds.left + targetBounds.width / 2;
314
- const screenY = window.screenY + targetBounds.top + targetBounds.height / 2;
315
- const clientX = targetBounds.left + targetBounds.width / 2;
316
- const clientY = targetBounds.top + targetBounds.height / 2;
317
- const mouseDown = document.createEvent("MouseEvents");
318
- mouseDown.initMouseEvent(
319
- "mousedown",
320
- true,
321
- true,
322
- window,
323
- 0,
324
- screenX,
325
- screenY,
326
- clientX,
327
- clientY,
328
- false,
329
- false,
330
- false,
331
- false,
332
- 0,
333
- result.target
334
- );
335
- const mouseMove = document.createEvent("MouseEvents");
336
- mouseMove.initMouseEvent(
337
- "mousemove",
338
- true,
339
- true,
340
- window,
341
- 0,
342
- screenX + xDiff,
343
- screenY + yDiff,
344
- clientX + xDiff,
345
- clientY + yDiff,
346
- false,
347
- false,
348
- false,
349
- false,
350
- 0,
351
- result.target
352
- );
353
- const mouseUp = document.createEvent("MouseEvents");
354
- mouseUp.initMouseEvent(
355
- "mouseup",
356
- true,
357
- true,
358
- window,
359
- 0,
360
- screenX + xDiff,
361
- screenY + yDiff,
362
- clientX + xDiff,
363
- clientY + yDiff,
364
- false,
365
- false,
366
- false,
367
- false,
368
- 0,
369
- result.target
370
- );
371
- result.target.dispatchEvent(mouseDown);
372
- await this.waitTimeout(10);
373
- result.target.dispatchEvent(mouseMove);
374
- await this.waitTimeout(10);
375
- result.target.dispatchEvent(mouseUp);
376
- }
377
- }
378
- async function waitAction(config) {
379
- await waitTimeout(config.waitTime);
380
- }
381
- async function closeAction() {
382
- window.close();
383
- }
384
- async function evalAction(config) {
385
- console.log("eval!", config.code);
386
- return new Promise((resolve) => {
387
- try {
388
- if (config.async) {
389
- window.eval(config.code);
390
- setTimeout(() => {
391
- resolve(window.eval("window.__consentCheckResult"));
392
- }, config.timeout || 250);
393
- } else {
394
- resolve(window.eval(config.code));
395
- }
396
- } catch (e) {
397
- console.warn("eval error", e, config.code);
398
- resolve(false);
399
- }
400
- });
401
- }
402
-
403
- // lib/types.ts
404
- var PopupHandlingModes = {
405
- None: -1,
406
- Reject: 0,
407
- Tier1: 1,
408
- Tier2: 2
409
- };
3
+ // lib/rules.ts
4
+ var SUPPORTED_RULE_STEP_VERSION = 2;
410
5
 
411
6
  // lib/random.ts
412
7
  function getRandomID() {
@@ -459,6 +54,155 @@
459
54
  }
460
55
  }
461
56
 
57
+ // lib/utils.ts
58
+ function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
59
+ const styleSelector = `style#${styleOverrideElementId}`;
60
+ const existingElement = document.querySelector(styleSelector);
61
+ if (existingElement && existingElement instanceof HTMLStyleElement) {
62
+ return existingElement;
63
+ } else {
64
+ const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
65
+ const css = document.createElement("style");
66
+ css.id = styleOverrideElementId;
67
+ parent.appendChild(css);
68
+ return css;
69
+ }
70
+ }
71
+ function getHidingStyle(method) {
72
+ const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
73
+ return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
74
+ }
75
+ function hideElements(styleEl, selector, method = "display") {
76
+ const rule = `${selector} { ${getHidingStyle(method)} } `;
77
+ if (styleEl instanceof HTMLStyleElement) {
78
+ styleEl.innerText += rule;
79
+ return selector.length > 0;
80
+ }
81
+ return false;
82
+ }
83
+ async function waitFor(predicate, maxTimes, interval) {
84
+ const result = await predicate();
85
+ if (!result && maxTimes > 0) {
86
+ return new Promise((resolve) => {
87
+ setTimeout(async () => {
88
+ resolve(waitFor(predicate, maxTimes - 1, interval));
89
+ }, interval);
90
+ });
91
+ }
92
+ return Promise.resolve(result);
93
+ }
94
+ function isElementVisible(elem) {
95
+ if (!elem) {
96
+ return false;
97
+ }
98
+ if (elem.offsetParent !== null) {
99
+ return true;
100
+ } else {
101
+ const css = window.getComputedStyle(elem);
102
+ if (css.position === "fixed" && css.display !== "none") {
103
+ return true;
104
+ }
105
+ }
106
+ return false;
107
+ }
108
+ function copyObject(data) {
109
+ if (globalThis.structuredClone) {
110
+ return structuredClone(data);
111
+ }
112
+ return JSON.parse(JSON.stringify(data));
113
+ }
114
+ function normalizeConfig(providedConfig) {
115
+ const defaultConfig = {
116
+ enabled: true,
117
+ autoAction: "optOut",
118
+ // if falsy, the extension will wait for an explicit user signal before opting in/out
119
+ disabledCmps: [],
120
+ enablePrehide: true,
121
+ enableCosmeticRules: true,
122
+ enableGeneratedRules: true,
123
+ enableHeuristicDetection: false,
124
+ enablePopupMutationObserver: false,
125
+ detectRetries: 20,
126
+ isMainWorld: false,
127
+ prehideTimeout: 2e3,
128
+ visualTest: false,
129
+ logs: {
130
+ lifecycle: false,
131
+ rulesteps: false,
132
+ detectionsteps: false,
133
+ evals: false,
134
+ errors: true,
135
+ messages: false,
136
+ waits: false
137
+ },
138
+ performanceLoggingEnabled: false,
139
+ heuristicPopupSearchTimeout: 100,
140
+ heuristicMode: "off"
141
+ // heuristic disabled by default
142
+ };
143
+ const updatedConfig = copyObject(defaultConfig);
144
+ for (const key of Object.keys(defaultConfig)) {
145
+ if (typeof providedConfig[key] !== "undefined") {
146
+ updatedConfig[key] = providedConfig[key];
147
+ }
148
+ }
149
+ return updatedConfig;
150
+ }
151
+ function scheduleWhenIdle(callback, timeout = 500) {
152
+ if (globalThis.requestIdleCallback) {
153
+ requestIdleCallback(callback, { timeout });
154
+ } else {
155
+ setTimeout(callback, 0);
156
+ }
157
+ }
158
+ function highlightNode(node) {
159
+ const highlightedNode = node;
160
+ if (!node.style) return;
161
+ if (highlightedNode.__oldStyles !== void 0) {
162
+ return;
163
+ }
164
+ if (node.hasAttribute("style")) {
165
+ highlightedNode.__oldStyles = node.style.cssText;
166
+ }
167
+ node.style.animation = "pulsate .5s infinite";
168
+ node.style.outline = "solid red";
169
+ let styleTag = document.querySelector("style#autoconsent-debug-styles");
170
+ if (!styleTag) {
171
+ styleTag = document.createElement("style");
172
+ styleTag.id = "autoconsent-debug-styles";
173
+ }
174
+ styleTag.textContent = `
175
+ @keyframes pulsate {
176
+ 0% {
177
+ outline-width: 8px;
178
+ outline-offset: -4px;
179
+ }
180
+ 50% {
181
+ outline-width: 4px;
182
+ outline-offset: -2px;
183
+ }
184
+ 100% {
185
+ outline-width: 8px;
186
+ outline-offset: -4px;
187
+ }
188
+ }
189
+ `;
190
+ document.head.appendChild(styleTag);
191
+ }
192
+ function unhighlightNode(node) {
193
+ const highlightedNode = node;
194
+ if (!node.style || !node.hasAttribute("style")) return;
195
+ if (highlightedNode.__oldStyles !== void 0) {
196
+ node.style.cssText = highlightedNode.__oldStyles;
197
+ delete highlightedNode.__oldStyles;
198
+ } else {
199
+ node.removeAttribute("style");
200
+ }
201
+ }
202
+ function isTopFrame() {
203
+ return window.top === window && (!globalThis.location.ancestorOrigins || globalThis.location.ancestorOrigins.length === 0);
204
+ }
205
+
462
206
  // lib/eval-snippets.ts
463
207
  var snippets = {
464
208
  // code-based rules
@@ -636,156 +380,6 @@
636
380
  return `(${snippetStr})()`;
637
381
  }
638
382
 
639
- // lib/utils.ts
640
- function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
641
- const styleSelector = `style#${styleOverrideElementId}`;
642
- const existingElement = document.querySelector(styleSelector);
643
- if (existingElement && existingElement instanceof HTMLStyleElement) {
644
- return existingElement;
645
- } else {
646
- const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
647
- const css = document.createElement("style");
648
- css.id = styleOverrideElementId;
649
- parent.appendChild(css);
650
- return css;
651
- }
652
- }
653
- function getHidingStyle(method) {
654
- const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
655
- return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
656
- }
657
- function hideElements(styleEl, selector, method = "display") {
658
- const rule = `${selector} { ${getHidingStyle(method)} } `;
659
- if (styleEl instanceof HTMLStyleElement) {
660
- styleEl.innerText += rule;
661
- return selector.length > 0;
662
- }
663
- return false;
664
- }
665
- async function waitFor(predicate, maxTimes, interval) {
666
- const result = await predicate();
667
- if (!result && maxTimes > 0) {
668
- return new Promise((resolve) => {
669
- setTimeout(async () => {
670
- resolve(waitFor(predicate, maxTimes - 1, interval));
671
- }, interval);
672
- });
673
- }
674
- return Promise.resolve(result);
675
- }
676
- function isElementVisible(elem) {
677
- if (!elem) {
678
- return false;
679
- }
680
- if (elem.offsetParent !== null) {
681
- return true;
682
- } else {
683
- const css = window.getComputedStyle(elem);
684
- if (css.position === "fixed" && css.display !== "none") {
685
- return true;
686
- }
687
- }
688
- return false;
689
- }
690
- function copyObject(data) {
691
- if (globalThis.structuredClone) {
692
- return structuredClone(data);
693
- }
694
- return JSON.parse(JSON.stringify(data));
695
- }
696
- function normalizeConfig(providedConfig) {
697
- const defaultConfig = {
698
- enabled: true,
699
- autoAction: "optOut",
700
- // if falsy, the extension will wait for an explicit user signal before opting in/out
701
- disabledCmps: [],
702
- enablePrehide: true,
703
- enableCosmeticRules: true,
704
- enableGeneratedRules: true,
705
- enableHeuristicDetection: false,
706
- enableHeuristicAction: false,
707
- enablePopupMutationObserver: false,
708
- detectRetries: 20,
709
- isMainWorld: false,
710
- prehideTimeout: 2e3,
711
- enableFilterList: false,
712
- visualTest: false,
713
- logs: {
714
- lifecycle: false,
715
- rulesteps: false,
716
- detectionsteps: false,
717
- evals: false,
718
- errors: true,
719
- messages: false,
720
- waits: false
721
- },
722
- performanceLoggingEnabled: false,
723
- heuristicPopupSearchTimeout: 100,
724
- heuristicMode: PopupHandlingModes.Reject
725
- };
726
- const updatedConfig = copyObject(defaultConfig);
727
- for (const key of Object.keys(defaultConfig)) {
728
- if (typeof providedConfig[key] !== "undefined") {
729
- updatedConfig[key] = providedConfig[key];
730
- }
731
- }
732
- return updatedConfig;
733
- }
734
- function scheduleWhenIdle(callback, timeout = 500) {
735
- if (globalThis.requestIdleCallback) {
736
- requestIdleCallback(callback, { timeout });
737
- } else {
738
- setTimeout(callback, 0);
739
- }
740
- }
741
- function highlightNode(node) {
742
- const highlightedNode = node;
743
- if (!node.style) return;
744
- if (highlightedNode.__oldStyles !== void 0) {
745
- return;
746
- }
747
- if (node.hasAttribute("style")) {
748
- highlightedNode.__oldStyles = node.style.cssText;
749
- }
750
- node.style.animation = "pulsate .5s infinite";
751
- node.style.outline = "solid red";
752
- let styleTag = document.querySelector("style#autoconsent-debug-styles");
753
- if (!styleTag) {
754
- styleTag = document.createElement("style");
755
- styleTag.id = "autoconsent-debug-styles";
756
- }
757
- styleTag.textContent = `
758
- @keyframes pulsate {
759
- 0% {
760
- outline-width: 8px;
761
- outline-offset: -4px;
762
- }
763
- 50% {
764
- outline-width: 4px;
765
- outline-offset: -2px;
766
- }
767
- 100% {
768
- outline-width: 8px;
769
- outline-offset: -4px;
770
- }
771
- }
772
- `;
773
- document.head.appendChild(styleTag);
774
- }
775
- function unhighlightNode(node) {
776
- const highlightedNode = node;
777
- if (!node.style || !node.hasAttribute("style")) return;
778
- if (highlightedNode.__oldStyles !== void 0) {
779
- node.style.cssText = highlightedNode.__oldStyles;
780
- delete highlightedNode.__oldStyles;
781
- } else {
782
- node.removeAttribute("style");
783
- }
784
- }
785
- function isTopFrame() {
786
- return window.top === window && (!globalThis.location.ancestorOrigins || globalThis.location.ancestorOrigins.length === 0);
787
- }
788
-
789
383
  // lib/heuristic-patterns.ts
790
384
  var DETECT_PATTERNS = [
791
385
  /accept cookies/gi,
@@ -1544,15 +1138,19 @@
1544
1138
  const patterns = [];
1545
1139
  const snippets2 = [];
1546
1140
  for (const p of detectPatterns) {
1547
- const matches2 = allText?.match(p);
1548
- if (matches2) {
1141
+ const matches = allText?.match(p);
1142
+ if (matches) {
1549
1143
  patterns.push(p.toString());
1550
- snippets2.push(...matches2.map((m) => m.substring(0, 200)));
1144
+ snippets2.push(...matches.map((m) => m.substring(0, 200)));
1551
1145
  }
1552
1146
  }
1553
1147
  return { patterns, snippets: snippets2 };
1554
1148
  }
1555
- function getActionablePopups(mode = PopupHandlingModes.Reject, timeout = POPUP_SEARCH_MAX_TIME) {
1149
+ function getActionablePopups(mode = "reject", timeout = POPUP_SEARCH_MAX_TIME) {
1150
+ const acceptedLevels = mode === "tier2" ? ["reject", "tier1", "tier2"] : mode === "tier1" ? ["reject", "tier1"] : ["reject"];
1151
+ if (acceptedLevels.length === 0) {
1152
+ return [];
1153
+ }
1556
1154
  const popups = getPotentialPopups(timeout);
1557
1155
  const result = popups.reduce((acc, popup) => {
1558
1156
  const popupText = popup.text?.trim();
@@ -1568,9 +1166,7 @@
1568
1166
  }
1569
1167
  return acc;
1570
1168
  }, []);
1571
- return result.filter(
1572
- (popup) => popup.regexClassification !== void 0 && popup.regexClassification !== PopupHandlingModes.None && popup.regexClassification <= mode
1573
- ).sort((a, b) => (a.regexClassification ?? 0) - (b.regexClassification ?? 0));
1169
+ return result.filter((popup) => popup.regexClassification !== void 0 && acceptedLevels.includes(popup.regexClassification)).sort((a, b) => (a.regexClassification ?? "") > (b.regexClassification ?? "") ? 1 : -1);
1574
1170
  }
1575
1171
  function classifyButtons(buttons) {
1576
1172
  for (const button of buttons) {
@@ -1588,18 +1184,18 @@
1588
1184
  { reject: 0, settings: 0, accept: 0, acknowledge: 0 }
1589
1185
  );
1590
1186
  if (reject > 0) {
1591
- return PopupHandlingModes.Reject;
1187
+ return "reject";
1592
1188
  }
1593
1189
  if (settings > 0) {
1594
- return PopupHandlingModes.None;
1190
+ return "none";
1595
1191
  }
1596
1192
  if (acknowledge > 0) {
1597
- return PopupHandlingModes.Tier1;
1193
+ return "tier1";
1598
1194
  }
1599
1195
  if (accept > 0) {
1600
- return accept === 1 ? PopupHandlingModes.Tier2 : PopupHandlingModes.None;
1196
+ return accept === 1 ? "tier2" : "none";
1601
1197
  }
1602
- return PopupHandlingModes.None;
1198
+ return "none";
1603
1199
  }
1604
1200
  function testButtonMatches(buttonText, matchPatterns, neverMatchPatterns) {
1605
1201
  if (!buttonText) {
@@ -2080,7 +1676,7 @@
2080
1676
  }
2081
1677
  };
2082
1678
  var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2083
- constructor(autoconsentInstance, mode = PopupHandlingModes.Reject) {
1679
+ constructor(autoconsentInstance, mode = "reject") {
2084
1680
  super(autoconsentInstance);
2085
1681
  this.popups = [];
2086
1682
  this.name = "HEURISTIC";
@@ -2107,7 +1703,7 @@
2107
1703
  this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
2108
1704
  this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
2109
1705
  if (this.popups.length > 0) {
2110
- this.name = `HEURISTIC-TIER${this.popups[0].regexClassification}`;
1706
+ this.name = `HEURISTIC-${this.popups[0].regexClassification?.toUpperCase()}`;
2111
1707
  return Promise.resolve(true);
2112
1708
  }
2113
1709
  return Promise.resolve(false);
@@ -2125,7 +1721,7 @@
2125
1721
  const popup = this.popups[0];
2126
1722
  const level = popup.regexClassification;
2127
1723
  const buttons = popup.buttons;
2128
- const targetButtonType = level === PopupHandlingModes.Reject ? "reject" : level === PopupHandlingModes.Tier1 ? "acknowledge" : "accept";
1724
+ const targetButtonType = level === "reject" ? "reject" : level === "tier1" ? "acknowledge" : "accept";
2129
1725
  return buttons.find((button) => button.regexClassification === targetButtonType);
2130
1726
  }
2131
1727
  optOut() {
@@ -2151,76 +1747,6 @@
2151
1747
  }
2152
1748
  };
2153
1749
 
2154
- // lib/cmps/consentomatic.ts
2155
- var ConsentOMaticCMP = class {
2156
- constructor(name, config) {
2157
- this.name = name;
2158
- this.config = config;
2159
- this.methods = /* @__PURE__ */ new Map();
2160
- this.runContext = defaultRunContext;
2161
- this.isCosmetic = false;
2162
- config.methods.forEach((methodConfig) => {
2163
- if (methodConfig.action) {
2164
- this.methods.set(methodConfig.name, methodConfig.action);
2165
- }
2166
- });
2167
- this.hasSelfTest = false;
2168
- }
2169
- get isIntermediate() {
2170
- return false;
2171
- }
2172
- checkRunContext() {
2173
- return true;
2174
- }
2175
- checkFrameContext(isTop) {
2176
- return true;
2177
- }
2178
- hasMatchingUrlPattern() {
2179
- return false;
2180
- }
2181
- async detectCmp() {
2182
- const matchResults = this.config.detectors.map((detectorConfig) => matches(detectorConfig.presentMatcher));
2183
- return matchResults.some((r) => !!r);
2184
- }
2185
- async detectPopup() {
2186
- const matchResults = this.config.detectors.map((detectorConfig) => matches(detectorConfig.showingMatcher));
2187
- return matchResults.some((r) => !!r);
2188
- }
2189
- async executeAction(method, param) {
2190
- if (this.methods.has(method)) {
2191
- return executeAction(this.methods.get(method), param);
2192
- }
2193
- return true;
2194
- }
2195
- async optOut() {
2196
- await this.executeAction("HIDE_CMP");
2197
- await this.executeAction("OPEN_OPTIONS");
2198
- await this.executeAction("HIDE_CMP");
2199
- await this.executeAction("DO_CONSENT", []);
2200
- await this.executeAction("SAVE_CONSENT");
2201
- return true;
2202
- }
2203
- async optIn() {
2204
- await this.executeAction("HIDE_CMP");
2205
- await this.executeAction("OPEN_OPTIONS");
2206
- await this.executeAction("HIDE_CMP");
2207
- await this.executeAction("DO_CONSENT", ["D", "A", "B", "E", "F", "X"]);
2208
- await this.executeAction("SAVE_CONSENT");
2209
- return true;
2210
- }
2211
- async openCmp() {
2212
- await this.executeAction("HIDE_CMP");
2213
- await this.executeAction("OPEN_OPTIONS");
2214
- return true;
2215
- }
2216
- async test() {
2217
- return true;
2218
- }
2219
- };
2220
-
2221
- // lib/rules.ts
2222
- var SUPPORTED_RULE_STEP_VERSION = 2;
2223
-
2224
1750
  // lib/cmps/trustarc-top.ts
2225
1751
  var cookieSettingsButton = "#truste-show-consent";
2226
1752
  var shortcutOptOut = "#truste-consent-required";
@@ -3248,15 +2774,15 @@
3248
2774
  }
3249
2775
  querySelectorChain(selectors) {
3250
2776
  let parent = document;
3251
- let matches2 = [];
2777
+ let matches = [];
3252
2778
  for (const selector of selectors) {
3253
- matches2 = this.querySingleReplySelector(selector, parent);
3254
- if (matches2.length === 0) {
2779
+ matches = this.querySingleReplySelector(selector, parent);
2780
+ if (matches.length === 0) {
3255
2781
  return [];
3256
2782
  }
3257
- parent = matches2[0];
2783
+ parent = matches[0];
3258
2784
  }
3259
- return matches2;
2785
+ return matches;
3260
2786
  }
3261
2787
  elementSelector(selector) {
3262
2788
  if (typeof selector === "string") {
@@ -3401,8 +2927,6 @@
3401
2927
  this.id = getRandomID();
3402
2928
  this.rules = [];
3403
2929
  this.state = {
3404
- cosmeticFiltersOn: false,
3405
- filterListReported: false,
3406
2930
  lifecycle: "loading",
3407
2931
  prehideOn: false,
3408
2932
  findCmpAttempts: 0,
@@ -3453,9 +2977,6 @@
3453
2977
  if (declarativeRules) {
3454
2978
  this.parseDeclarativeRules(declarativeRules);
3455
2979
  }
3456
- if (config.enableFilterList) {
3457
- this.initializeFilterList();
3458
- }
3459
2980
  this.rules = filterCMPs(this.rules, normalizedConfig);
3460
2981
  if (this.shouldPrehide) {
3461
2982
  if (document.documentElement) {
@@ -3479,8 +3000,6 @@
3479
3000
  }
3480
3001
  this.updateState({ lifecycle: "initialized" });
3481
3002
  }
3482
- initializeFilterList() {
3483
- }
3484
3003
  get shouldPrehide() {
3485
3004
  return this.config.enablePrehide && !this.config.visualTest;
3486
3005
  }
@@ -3509,11 +3028,6 @@
3509
3028
  parseDeclarativeRules(declarativeRules) {
3510
3029
  const perfEnabled = this.#config?.performanceLoggingEnabled;
3511
3030
  perfEnabled && performance.mark("parseDeclarativeRulesStart");
3512
- if (declarativeRules.consentomatic) {
3513
- for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
3514
- this.addConsentomaticCMP(name, rule);
3515
- }
3516
- }
3517
3031
  if (declarativeRules.autoconsent) {
3518
3032
  declarativeRules.autoconsent.forEach((ruleset) => {
3519
3033
  this.addDeclarativeCMP(ruleset);
@@ -3535,9 +3049,6 @@
3535
3049
  this.rules.push(new AutoConsentCMP(ruleset, this));
3536
3050
  }
3537
3051
  }
3538
- addConsentomaticCMP(name, config) {
3539
- this.rules.push(new ConsentOMaticCMP(`com_${name}`, config));
3540
- }
3541
3052
  // start the detection process, possibly with a delay
3542
3053
  start() {
3543
3054
  scheduleWhenIdle(() => this._start());
@@ -3556,7 +3067,8 @@
3556
3067
  if (this.shouldPrehide) {
3557
3068
  this.undoPrehide();
3558
3069
  }
3559
- return this.filterListFallback();
3070
+ this.updateState({ lifecycle: "nothingDetected" });
3071
+ return false;
3560
3072
  }
3561
3073
  this.updateState({ lifecycle: "cmpDetected" });
3562
3074
  const staticCmps = [];
@@ -3614,7 +3126,7 @@
3614
3126
  }
3615
3127
  }
3616
3128
  });
3617
- const heuristicRules = isTop && this.config.enableHeuristicAction && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
3129
+ const heuristicRules = isTop && this.config.heuristicMode !== "off" && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
3618
3130
  const rulesPriorityStages = [
3619
3131
  ["site-specific", siteSpecificRules],
3620
3132
  ["generic", genericRules],
@@ -3722,9 +3234,6 @@
3722
3234
  if (this.shouldPrehide && !this.state.prehideOn) {
3723
3235
  this.prehideElements();
3724
3236
  }
3725
- if (this.state.cosmeticFiltersOn) {
3726
- this.undoCosmetics();
3727
- }
3728
3237
  this.foundCmp = cmp;
3729
3238
  if (this.config.autoAction === "optOut") {
3730
3239
  return await this.doOptOut();
@@ -3888,25 +3397,6 @@
3888
3397
  this.updateState({ prehideOn: false });
3889
3398
  this.domActions.undoPrehide();
3890
3399
  }
3891
- undoCosmetics() {
3892
- }
3893
- reportFilterlist() {
3894
- this.sendContentMessage({
3895
- type: "cmpDetected",
3896
- url: location.href,
3897
- cmp: "filterList"
3898
- });
3899
- this.sendContentMessage({
3900
- type: "popupFound",
3901
- cmp: "filterList",
3902
- url: location.href
3903
- });
3904
- this.updateState({ filterListReported: true });
3905
- }
3906
- filterListFallback() {
3907
- this.updateState({ lifecycle: "nothingDetected" });
3908
- return false;
3909
- }
3910
3400
  updateState(change) {
3911
3401
  Object.assign(this.state, change);
3912
3402
  this.sendContentMessage({