@duckduckgo/autoconsent 15.1.0 → 16.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 (84) hide show
  1. package/.github/dependabot.yml +0 -3
  2. package/.github/workflows/release.yml +0 -4
  3. package/AGENTS.md +3 -3
  4. package/CHANGELOG.md +20 -0
  5. package/build.sh +0 -2
  6. package/dist/addon-firefox/background.bundle.js +8 -24
  7. package/dist/addon-firefox/compact-rules.json +1 -1
  8. package/dist/addon-firefox/content.bundle.js +176 -686
  9. package/dist/addon-firefox/manifest.json +1 -1
  10. package/dist/addon-firefox/popup.bundle.js +31 -27
  11. package/dist/addon-firefox/popup.html +21 -13
  12. package/dist/addon-firefox/rule-index.json +1 -1
  13. package/dist/addon-firefox/rules.json +1 -1
  14. package/dist/addon-mv3/background.bundle.js +8 -24
  15. package/dist/addon-mv3/compact-rules.json +1 -1
  16. package/dist/addon-mv3/content.bundle.js +176 -686
  17. package/dist/addon-mv3/manifest.json +1 -1
  18. package/dist/addon-mv3/popup.bundle.js +31 -27
  19. package/dist/addon-mv3/popup.html +21 -13
  20. package/dist/addon-mv3/rule-index.json +1 -1
  21. package/dist/addon-mv3/rules.json +1 -1
  22. package/dist/autoconsent.cjs.js +176 -685
  23. package/dist/autoconsent.esm.js +176 -685
  24. package/dist/autoconsent.playwright.js +177 -689
  25. package/dist/autoconsent.standalone.js +177 -690
  26. package/dist/types/cmps/base.d.ts +3 -3
  27. package/dist/types/heuristics.d.ts +2 -2
  28. package/dist/types/types.d.ts +10 -23
  29. package/dist/types/web.d.ts +0 -9
  30. package/docs/api.md +1 -8
  31. package/docs/puppeteer.md +1 -3
  32. package/docs/rule-syntax.md +0 -17
  33. package/eslint.config.mjs +1 -1
  34. package/lib/cmps/base.ts +5 -6
  35. package/lib/heuristics.ts +15 -15
  36. package/lib/types.ts +9 -21
  37. package/lib/utils.ts +2 -4
  38. package/lib/web.ts +3 -53
  39. package/package.json +4 -17
  40. package/playwright/content.ts +1 -2
  41. package/readme.md +3 -6
  42. package/rules/autoconsent/dreamlab-cmp.json +13 -0
  43. package/rules/build.ts +1 -24
  44. package/rules/compact-rules.json +1 -1
  45. package/rules/rule-index-builder.ts +2 -7
  46. package/rules/rule-index.json +1 -1
  47. package/rules/rules.json +1 -1
  48. package/standalone/content.ts +0 -2
  49. package/tests/dreamlab-cmp.spec.ts +3 -0
  50. package/tests/quantcast.spec.ts +0 -6
  51. package/tests-wtr/heuristics/get-actionable-popups.ts +13 -13
  52. package/tests-wtr/heuristics/heuristic-cmp.ts +32 -33
  53. package/tests-wtr/lifecycle/find-cmp.ts +5 -8
  54. package/tests-wtr/web/do-opt-in.test.ts +0 -1
  55. package/tests-wtr/web/do-opt-out.test.ts +0 -1
  56. package/tests-wtr/web/do-self-test.test.ts +0 -1
  57. package/tests-wtr/web/filter-cmps.test.ts +0 -1
  58. package/tests-wtr/web/receive-message-callback.test.ts +1 -2
  59. package/tests-wtr/web/update-state.test.ts +1 -3
  60. package/tsconfig.build.json +1 -1
  61. package/.github/workflows/update-filterlist.yml +0 -42
  62. package/dist/autoconsent.extra.cjs.js +0 -15717
  63. package/dist/autoconsent.extra.esm.js +0 -15649
  64. package/dist/types/cmps/consentomatic.d.ts +0 -34
  65. package/dist/types/consentomatic/index.d.ts +0 -2
  66. package/dist/types/consentomatic/tools.d.ts +0 -10
  67. package/dist/types/filterlist-engine.d.ts +0 -2
  68. package/dist/types/filterlist-utils.d.ts +0 -4
  69. package/dist/types/web-extra.d.ts +0 -11
  70. package/lib/cmps/consentomatic.ts +0 -97
  71. package/lib/consentomatic/index.ts +0 -252
  72. package/lib/consentomatic/tools.ts +0 -199
  73. package/lib/filterlist-engine.ts +0 -5
  74. package/lib/filterlist-utils.ts +0 -45
  75. package/lib/web-extra.ts +0 -116
  76. package/rules/consentomatic.json +0 -1
  77. package/rules/filterlist.txt +0 -18440
  78. package/rules/filterlists/overrides.txt +0 -4
  79. package/scripts/compile-filterlist.mjs +0 -63
  80. package/scripts/fetch-easylist.sh +0 -25
  81. package/scripts/rebuild-filterlist.mjs +0 -216
  82. package/tests/oil.spec.ts +0 -7
  83. package/tests/springer.spec.ts +0 -7
  84. package/tests/wordpressgdpr.spec.ts +0 -6
@@ -36,412 +36,8 @@ __export(web_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(web_exports);
38
38
 
39
- // lib/consentomatic/tools.ts
40
- var _Tools = class _Tools {
41
- static setBase(base) {
42
- _Tools.base = base;
43
- }
44
- static findElement(options, parent = null, multiple = false) {
45
- let possibleTargets = null;
46
- if (parent != null) {
47
- possibleTargets = Array.from(parent.querySelectorAll(options.selector));
48
- } else {
49
- if (_Tools.base != null) {
50
- possibleTargets = Array.from(
51
- _Tools.base.querySelectorAll(options.selector)
52
- );
53
- } else {
54
- possibleTargets = Array.from(
55
- document.querySelectorAll(options.selector)
56
- );
57
- }
58
- }
59
- if (options.textFilter != null) {
60
- possibleTargets = possibleTargets.filter((possibleTarget) => {
61
- const textContent = possibleTarget.textContent.toLowerCase();
62
- if (Array.isArray(options.textFilter)) {
63
- let foundText = false;
64
- for (const text of options.textFilter) {
65
- if (textContent.indexOf(text.toLowerCase()) !== -1) {
66
- foundText = true;
67
- break;
68
- }
69
- }
70
- return foundText;
71
- } else if (options.textFilter != null) {
72
- return textContent.indexOf(options.textFilter.toLowerCase()) !== -1;
73
- }
74
- return false;
75
- });
76
- }
77
- if (options.styleFilters != null) {
78
- possibleTargets = possibleTargets.filter((possibleTarget) => {
79
- const styles = window.getComputedStyle(possibleTarget);
80
- let keep = true;
81
- for (const styleFilter of options.styleFilters) {
82
- const option = styles[styleFilter.option];
83
- if (styleFilter.negated) {
84
- keep = keep && option !== styleFilter.value;
85
- } else {
86
- keep = keep && option === styleFilter.value;
87
- }
88
- }
89
- return keep;
90
- });
91
- }
92
- if (options.displayFilter != null) {
93
- possibleTargets = possibleTargets.filter((possibleTarget) => {
94
- if (options.displayFilter) {
95
- return possibleTarget.offsetHeight !== 0;
96
- } else {
97
- return possibleTarget.offsetHeight === 0;
98
- }
99
- });
100
- }
101
- if (options.iframeFilter != null) {
102
- possibleTargets = possibleTargets.filter(() => {
103
- if (options.iframeFilter) {
104
- return window.location !== window.parent.location;
105
- } else {
106
- return window.location === window.parent.location;
107
- }
108
- });
109
- }
110
- if (options.childFilter != null) {
111
- possibleTargets = possibleTargets.filter((possibleTarget) => {
112
- const oldBase = _Tools.base;
113
- _Tools.setBase(possibleTarget);
114
- const childResults = _Tools.find(options.childFilter);
115
- _Tools.setBase(oldBase);
116
- return childResults.target != null;
117
- });
118
- }
119
- if (multiple) {
120
- return possibleTargets;
121
- } else {
122
- if (possibleTargets.length > 1) {
123
- console.warn(
124
- "Multiple possible targets: ",
125
- possibleTargets,
126
- options,
127
- parent
128
- );
129
- }
130
- return possibleTargets[0];
131
- }
132
- }
133
- static find(options, multiple = false) {
134
- const results = [];
135
- if (options.parent != null) {
136
- const parent = _Tools.findElement(options.parent, null, multiple);
137
- if (parent != null) {
138
- if (parent instanceof Array) {
139
- parent.forEach((p) => {
140
- const targets = _Tools.findElement(options.target, p, multiple);
141
- if (targets instanceof Array) {
142
- targets.forEach((target) => {
143
- results.push({
144
- parent: p,
145
- target
146
- });
147
- });
148
- } else {
149
- results.push({
150
- parent: p,
151
- target: targets
152
- });
153
- }
154
- });
155
- return results;
156
- } else {
157
- const targets = _Tools.findElement(options.target, parent, multiple);
158
- if (targets instanceof Array) {
159
- targets.forEach((target) => {
160
- results.push({
161
- parent,
162
- target
163
- });
164
- });
165
- } else {
166
- results.push({
167
- parent,
168
- target: targets
169
- });
170
- }
171
- }
172
- }
173
- } else {
174
- const targets = _Tools.findElement(options.target, null, multiple);
175
- if (targets instanceof Array) {
176
- targets.forEach((target) => {
177
- results.push({
178
- parent: null,
179
- target
180
- });
181
- });
182
- } else {
183
- results.push({
184
- parent: null,
185
- target: targets
186
- });
187
- }
188
- }
189
- if (results.length === 0) {
190
- results.push({
191
- parent: null,
192
- target: null
193
- });
194
- }
195
- if (multiple) {
196
- return results;
197
- } else {
198
- if (results.length !== 1) {
199
- console.warn(
200
- "Multiple results found, even though multiple false",
201
- results
202
- );
203
- }
204
- return results[0];
205
- }
206
- }
207
- };
208
- _Tools.base = null;
209
- var Tools = _Tools;
210
-
211
- // lib/consentomatic/index.ts
212
- function matches(config) {
213
- const result = Tools.find(config);
214
- if (config.type === "css") {
215
- return !!result.target;
216
- } else if (config.type === "checkbox") {
217
- return !!result.target && result.target.checked;
218
- }
219
- }
220
- async function executeAction(config, param) {
221
- switch (config.type) {
222
- case "click":
223
- return clickAction(config);
224
- case "list":
225
- return listAction(config, param);
226
- case "consent":
227
- return consentAction(config, param);
228
- case "ifcss":
229
- return ifCssAction(config, param);
230
- case "waitcss":
231
- return waitCssAction(config);
232
- case "foreach":
233
- return forEachAction(config, param);
234
- case "hide":
235
- return hideAction(config);
236
- case "slide":
237
- return slideAction(config);
238
- case "close":
239
- return closeAction();
240
- case "wait":
241
- return waitAction(config);
242
- case "eval":
243
- return evalAction(config);
244
- default:
245
- throw new Error("Unknown action type: " + config.type);
246
- }
247
- }
248
- var STEP_TIMEOUT = 0;
249
- function waitTimeout(timeout) {
250
- return new Promise((resolve) => {
251
- setTimeout(() => {
252
- resolve();
253
- }, timeout);
254
- });
255
- }
256
- async function clickAction(config) {
257
- const result = Tools.find(config);
258
- if (result.target != null) {
259
- result.target.click();
260
- }
261
- return waitTimeout(STEP_TIMEOUT);
262
- }
263
- async function listAction(config, param) {
264
- for (const action of config.actions) {
265
- await executeAction(action, param);
266
- }
267
- }
268
- async function consentAction(config, consentTypes) {
269
- for (const consentConfig of config.consents) {
270
- const shouldEnable = consentTypes.indexOf(consentConfig.type) !== -1;
271
- if (consentConfig.matcher && consentConfig.toggleAction) {
272
- const isEnabled = matches(consentConfig.matcher);
273
- if (isEnabled !== shouldEnable) {
274
- await executeAction(consentConfig.toggleAction);
275
- }
276
- } else {
277
- if (shouldEnable) {
278
- await executeAction(consentConfig.trueAction);
279
- } else {
280
- await executeAction(consentConfig.falseAction);
281
- }
282
- }
283
- }
284
- }
285
- async function ifCssAction(config, param) {
286
- const result = Tools.find(config);
287
- if (!result.target) {
288
- if (config.trueAction) {
289
- await executeAction(config.trueAction, param);
290
- }
291
- } else {
292
- if (config.falseAction) {
293
- await executeAction(config.falseAction, param);
294
- }
295
- }
296
- }
297
- async function waitCssAction(config) {
298
- await new Promise((resolve) => {
299
- let numRetries = config.retries || 10;
300
- const waitTime = config.waitTime || 250;
301
- const checkCss = () => {
302
- const result = Tools.find(config);
303
- if (config.negated && result.target || !config.negated && !result.target) {
304
- if (numRetries > 0) {
305
- numRetries -= 1;
306
- setTimeout(checkCss, waitTime);
307
- } else {
308
- resolve();
309
- }
310
- } else {
311
- resolve();
312
- }
313
- };
314
- checkCss();
315
- });
316
- }
317
- async function forEachAction(config, param) {
318
- const results = Tools.find(config, true);
319
- const oldBase = Tools.base;
320
- for (const result of results) {
321
- if (result.target) {
322
- Tools.setBase(result.target);
323
- await executeAction(config.action, param);
324
- }
325
- }
326
- Tools.setBase(oldBase);
327
- }
328
- async function hideAction(config) {
329
- const result = Tools.find(config);
330
- if (result.target) {
331
- result.target.classList.add("Autoconsent-Hidden");
332
- }
333
- }
334
- async function slideAction(config) {
335
- const result = Tools.find(config);
336
- const dragResult = Tools.find(config.dragTarget);
337
- if (result.target) {
338
- const targetBounds = result.target.getBoundingClientRect();
339
- const dragTargetBounds = dragResult.target.getBoundingClientRect();
340
- let yDiff = dragTargetBounds.top - targetBounds.top;
341
- let xDiff = dragTargetBounds.left - targetBounds.left;
342
- if (this.config.axis.toLowerCase() === "y") {
343
- xDiff = 0;
344
- }
345
- if (this.config.axis.toLowerCase() === "x") {
346
- yDiff = 0;
347
- }
348
- const screenX = window.screenX + targetBounds.left + targetBounds.width / 2;
349
- const screenY = window.screenY + targetBounds.top + targetBounds.height / 2;
350
- const clientX = targetBounds.left + targetBounds.width / 2;
351
- const clientY = targetBounds.top + targetBounds.height / 2;
352
- const mouseDown = document.createEvent("MouseEvents");
353
- mouseDown.initMouseEvent(
354
- "mousedown",
355
- true,
356
- true,
357
- window,
358
- 0,
359
- screenX,
360
- screenY,
361
- clientX,
362
- clientY,
363
- false,
364
- false,
365
- false,
366
- false,
367
- 0,
368
- result.target
369
- );
370
- const mouseMove = document.createEvent("MouseEvents");
371
- mouseMove.initMouseEvent(
372
- "mousemove",
373
- true,
374
- true,
375
- window,
376
- 0,
377
- screenX + xDiff,
378
- screenY + yDiff,
379
- clientX + xDiff,
380
- clientY + yDiff,
381
- false,
382
- false,
383
- false,
384
- false,
385
- 0,
386
- result.target
387
- );
388
- const mouseUp = document.createEvent("MouseEvents");
389
- mouseUp.initMouseEvent(
390
- "mouseup",
391
- true,
392
- true,
393
- window,
394
- 0,
395
- screenX + xDiff,
396
- screenY + yDiff,
397
- clientX + xDiff,
398
- clientY + yDiff,
399
- false,
400
- false,
401
- false,
402
- false,
403
- 0,
404
- result.target
405
- );
406
- result.target.dispatchEvent(mouseDown);
407
- await this.waitTimeout(10);
408
- result.target.dispatchEvent(mouseMove);
409
- await this.waitTimeout(10);
410
- result.target.dispatchEvent(mouseUp);
411
- }
412
- }
413
- async function waitAction(config) {
414
- await waitTimeout(config.waitTime);
415
- }
416
- async function closeAction() {
417
- window.close();
418
- }
419
- async function evalAction(config) {
420
- console.log("eval!", config.code);
421
- return new Promise((resolve) => {
422
- try {
423
- if (config.async) {
424
- window.eval(config.code);
425
- setTimeout(() => {
426
- resolve(window.eval("window.__consentCheckResult"));
427
- }, config.timeout || 250);
428
- } else {
429
- resolve(window.eval(config.code));
430
- }
431
- } catch (e) {
432
- console.warn("eval error", e, config.code);
433
- resolve(false);
434
- }
435
- });
436
- }
437
-
438
- // lib/types.ts
439
- var PopupHandlingModes = {
440
- None: -1,
441
- Reject: 0,
442
- Tier1: 1,
443
- Tier2: 2
444
- };
39
+ // lib/rules.ts
40
+ var SUPPORTED_RULE_STEP_VERSION = 2;
445
41
 
446
42
  // lib/random.ts
447
43
  function getRandomID() {
@@ -494,6 +90,155 @@ function resolveEval(id, value) {
494
90
  }
495
91
  }
496
92
 
93
+ // lib/utils.ts
94
+ function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
95
+ const styleSelector = `style#${styleOverrideElementId}`;
96
+ const existingElement = document.querySelector(styleSelector);
97
+ if (existingElement && existingElement instanceof HTMLStyleElement) {
98
+ return existingElement;
99
+ } else {
100
+ const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
101
+ const css = document.createElement("style");
102
+ css.id = styleOverrideElementId;
103
+ parent.appendChild(css);
104
+ return css;
105
+ }
106
+ }
107
+ function getHidingStyle(method) {
108
+ const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
109
+ return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
110
+ }
111
+ function hideElements(styleEl, selector, method = "display") {
112
+ const rule = `${selector} { ${getHidingStyle(method)} } `;
113
+ if (styleEl instanceof HTMLStyleElement) {
114
+ styleEl.innerText += rule;
115
+ return selector.length > 0;
116
+ }
117
+ return false;
118
+ }
119
+ async function waitFor(predicate, maxTimes, interval) {
120
+ const result = await predicate();
121
+ if (!result && maxTimes > 0) {
122
+ return new Promise((resolve) => {
123
+ setTimeout(async () => {
124
+ resolve(waitFor(predicate, maxTimes - 1, interval));
125
+ }, interval);
126
+ });
127
+ }
128
+ return Promise.resolve(result);
129
+ }
130
+ function isElementVisible(elem) {
131
+ if (!elem) {
132
+ return false;
133
+ }
134
+ if (elem.offsetParent !== null) {
135
+ return true;
136
+ } else {
137
+ const css = window.getComputedStyle(elem);
138
+ if (css.position === "fixed" && css.display !== "none") {
139
+ return true;
140
+ }
141
+ }
142
+ return false;
143
+ }
144
+ function copyObject(data) {
145
+ if (globalThis.structuredClone) {
146
+ return structuredClone(data);
147
+ }
148
+ return JSON.parse(JSON.stringify(data));
149
+ }
150
+ function normalizeConfig(providedConfig) {
151
+ const defaultConfig = {
152
+ enabled: true,
153
+ autoAction: "optOut",
154
+ // if falsy, the extension will wait for an explicit user signal before opting in/out
155
+ disabledCmps: [],
156
+ enablePrehide: true,
157
+ enableCosmeticRules: true,
158
+ enableGeneratedRules: true,
159
+ enableHeuristicDetection: false,
160
+ enablePopupMutationObserver: false,
161
+ detectRetries: 20,
162
+ isMainWorld: false,
163
+ prehideTimeout: 2e3,
164
+ visualTest: false,
165
+ logs: {
166
+ lifecycle: false,
167
+ rulesteps: false,
168
+ detectionsteps: false,
169
+ evals: false,
170
+ errors: true,
171
+ messages: false,
172
+ waits: false
173
+ },
174
+ performanceLoggingEnabled: false,
175
+ heuristicPopupSearchTimeout: 100,
176
+ heuristicMode: "off"
177
+ // heuristic disabled by default
178
+ };
179
+ const updatedConfig = copyObject(defaultConfig);
180
+ for (const key of Object.keys(defaultConfig)) {
181
+ if (typeof providedConfig[key] !== "undefined") {
182
+ updatedConfig[key] = providedConfig[key];
183
+ }
184
+ }
185
+ return updatedConfig;
186
+ }
187
+ function scheduleWhenIdle(callback, timeout = 500) {
188
+ if (globalThis.requestIdleCallback) {
189
+ requestIdleCallback(callback, { timeout });
190
+ } else {
191
+ setTimeout(callback, 0);
192
+ }
193
+ }
194
+ function highlightNode(node) {
195
+ const highlightedNode = node;
196
+ if (!node.style) return;
197
+ if (highlightedNode.__oldStyles !== void 0) {
198
+ return;
199
+ }
200
+ if (node.hasAttribute("style")) {
201
+ highlightedNode.__oldStyles = node.style.cssText;
202
+ }
203
+ node.style.animation = "pulsate .5s infinite";
204
+ node.style.outline = "solid red";
205
+ let styleTag = document.querySelector("style#autoconsent-debug-styles");
206
+ if (!styleTag) {
207
+ styleTag = document.createElement("style");
208
+ styleTag.id = "autoconsent-debug-styles";
209
+ }
210
+ styleTag.textContent = `
211
+ @keyframes pulsate {
212
+ 0% {
213
+ outline-width: 8px;
214
+ outline-offset: -4px;
215
+ }
216
+ 50% {
217
+ outline-width: 4px;
218
+ outline-offset: -2px;
219
+ }
220
+ 100% {
221
+ outline-width: 8px;
222
+ outline-offset: -4px;
223
+ }
224
+ }
225
+ `;
226
+ document.head.appendChild(styleTag);
227
+ }
228
+ function unhighlightNode(node) {
229
+ const highlightedNode = node;
230
+ if (!node.style || !node.hasAttribute("style")) return;
231
+ if (highlightedNode.__oldStyles !== void 0) {
232
+ node.style.cssText = highlightedNode.__oldStyles;
233
+ delete highlightedNode.__oldStyles;
234
+ } else {
235
+ node.removeAttribute("style");
236
+ }
237
+ }
238
+ function isTopFrame() {
239
+ return window.top === window && (!globalThis.location.ancestorOrigins || globalThis.location.ancestorOrigins.length === 0);
240
+ }
241
+
497
242
  // lib/eval-snippets.ts
498
243
  var snippets = {
499
244
  // code-based rules
@@ -671,156 +416,6 @@ function getFunctionBody(snippetFunc) {
671
416
  return `(${snippetStr})()`;
672
417
  }
673
418
 
674
- // lib/utils.ts
675
- function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
676
- const styleSelector = `style#${styleOverrideElementId}`;
677
- const existingElement = document.querySelector(styleSelector);
678
- if (existingElement && existingElement instanceof HTMLStyleElement) {
679
- return existingElement;
680
- } else {
681
- const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
682
- const css = document.createElement("style");
683
- css.id = styleOverrideElementId;
684
- parent.appendChild(css);
685
- return css;
686
- }
687
- }
688
- function getHidingStyle(method) {
689
- const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
690
- return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
691
- }
692
- function hideElements(styleEl, selector, method = "display") {
693
- const rule = `${selector} { ${getHidingStyle(method)} } `;
694
- if (styleEl instanceof HTMLStyleElement) {
695
- styleEl.innerText += rule;
696
- return selector.length > 0;
697
- }
698
- return false;
699
- }
700
- async function waitFor(predicate, maxTimes, interval) {
701
- const result = await predicate();
702
- if (!result && maxTimes > 0) {
703
- return new Promise((resolve) => {
704
- setTimeout(async () => {
705
- resolve(waitFor(predicate, maxTimes - 1, interval));
706
- }, interval);
707
- });
708
- }
709
- return Promise.resolve(result);
710
- }
711
- function isElementVisible(elem) {
712
- if (!elem) {
713
- return false;
714
- }
715
- if (elem.offsetParent !== null) {
716
- return true;
717
- } else {
718
- const css = window.getComputedStyle(elem);
719
- if (css.position === "fixed" && css.display !== "none") {
720
- return true;
721
- }
722
- }
723
- return false;
724
- }
725
- function copyObject(data) {
726
- if (globalThis.structuredClone) {
727
- return structuredClone(data);
728
- }
729
- return JSON.parse(JSON.stringify(data));
730
- }
731
- function normalizeConfig(providedConfig) {
732
- const defaultConfig = {
733
- enabled: true,
734
- autoAction: "optOut",
735
- // if falsy, the extension will wait for an explicit user signal before opting in/out
736
- disabledCmps: [],
737
- enablePrehide: true,
738
- enableCosmeticRules: true,
739
- enableGeneratedRules: true,
740
- enableHeuristicDetection: false,
741
- enableHeuristicAction: false,
742
- enablePopupMutationObserver: false,
743
- detectRetries: 20,
744
- isMainWorld: false,
745
- prehideTimeout: 2e3,
746
- enableFilterList: false,
747
- visualTest: false,
748
- logs: {
749
- lifecycle: false,
750
- rulesteps: false,
751
- detectionsteps: false,
752
- evals: false,
753
- errors: true,
754
- messages: false,
755
- waits: false
756
- },
757
- performanceLoggingEnabled: false,
758
- heuristicPopupSearchTimeout: 100,
759
- heuristicMode: PopupHandlingModes.Reject
760
- };
761
- const updatedConfig = copyObject(defaultConfig);
762
- for (const key of Object.keys(defaultConfig)) {
763
- if (typeof providedConfig[key] !== "undefined") {
764
- updatedConfig[key] = providedConfig[key];
765
- }
766
- }
767
- return updatedConfig;
768
- }
769
- function scheduleWhenIdle(callback, timeout = 500) {
770
- if (globalThis.requestIdleCallback) {
771
- requestIdleCallback(callback, { timeout });
772
- } else {
773
- setTimeout(callback, 0);
774
- }
775
- }
776
- function highlightNode(node) {
777
- const highlightedNode = node;
778
- if (!node.style) return;
779
- if (highlightedNode.__oldStyles !== void 0) {
780
- return;
781
- }
782
- if (node.hasAttribute("style")) {
783
- highlightedNode.__oldStyles = node.style.cssText;
784
- }
785
- node.style.animation = "pulsate .5s infinite";
786
- node.style.outline = "solid red";
787
- let styleTag = document.querySelector("style#autoconsent-debug-styles");
788
- if (!styleTag) {
789
- styleTag = document.createElement("style");
790
- styleTag.id = "autoconsent-debug-styles";
791
- }
792
- styleTag.textContent = `
793
- @keyframes pulsate {
794
- 0% {
795
- outline-width: 8px;
796
- outline-offset: -4px;
797
- }
798
- 50% {
799
- outline-width: 4px;
800
- outline-offset: -2px;
801
- }
802
- 100% {
803
- outline-width: 8px;
804
- outline-offset: -4px;
805
- }
806
- }
807
- `;
808
- document.head.appendChild(styleTag);
809
- }
810
- function unhighlightNode(node) {
811
- const highlightedNode = node;
812
- if (!node.style || !node.hasAttribute("style")) return;
813
- if (highlightedNode.__oldStyles !== void 0) {
814
- node.style.cssText = highlightedNode.__oldStyles;
815
- delete highlightedNode.__oldStyles;
816
- } else {
817
- node.removeAttribute("style");
818
- }
819
- }
820
- function isTopFrame() {
821
- return window.top === window && (!globalThis.location.ancestorOrigins || globalThis.location.ancestorOrigins.length === 0);
822
- }
823
-
824
419
  // lib/heuristic-patterns.ts
825
420
  var DETECT_PATTERNS = [
826
421
  /accept cookies/gi,
@@ -1579,15 +1174,19 @@ function checkHeuristicPatterns(allText, detectPatterns = DETECT_PATTERNS) {
1579
1174
  const patterns = [];
1580
1175
  const snippets2 = [];
1581
1176
  for (const p of detectPatterns) {
1582
- const matches2 = allText?.match(p);
1583
- if (matches2) {
1177
+ const matches = allText?.match(p);
1178
+ if (matches) {
1584
1179
  patterns.push(p.toString());
1585
- snippets2.push(...matches2.map((m) => m.substring(0, 200)));
1180
+ snippets2.push(...matches.map((m) => m.substring(0, 200)));
1586
1181
  }
1587
1182
  }
1588
1183
  return { patterns, snippets: snippets2 };
1589
1184
  }
1590
- function getActionablePopups(mode = PopupHandlingModes.Reject, timeout = POPUP_SEARCH_MAX_TIME) {
1185
+ function getActionablePopups(mode = "reject", timeout = POPUP_SEARCH_MAX_TIME) {
1186
+ const acceptedLevels = mode === "tier2" ? ["reject", "tier1", "tier2"] : mode === "tier1" ? ["reject", "tier1"] : ["reject"];
1187
+ if (acceptedLevels.length === 0) {
1188
+ return [];
1189
+ }
1591
1190
  const popups = getPotentialPopups(timeout);
1592
1191
  const result = popups.reduce((acc, popup) => {
1593
1192
  const popupText = popup.text?.trim();
@@ -1603,9 +1202,7 @@ function getActionablePopups(mode = PopupHandlingModes.Reject, timeout = POPUP_S
1603
1202
  }
1604
1203
  return acc;
1605
1204
  }, []);
1606
- return result.filter(
1607
- (popup) => popup.regexClassification !== void 0 && popup.regexClassification !== PopupHandlingModes.None && popup.regexClassification <= mode
1608
- ).sort((a, b) => (a.regexClassification ?? 0) - (b.regexClassification ?? 0));
1205
+ return result.filter((popup) => popup.regexClassification !== void 0 && acceptedLevels.includes(popup.regexClassification)).sort((a, b) => (a.regexClassification ?? "") > (b.regexClassification ?? "") ? 1 : -1);
1609
1206
  }
1610
1207
  function classifyButtons(buttons) {
1611
1208
  for (const button of buttons) {
@@ -1623,18 +1220,18 @@ function classifyPopup(buttons) {
1623
1220
  { reject: 0, settings: 0, accept: 0, acknowledge: 0 }
1624
1221
  );
1625
1222
  if (reject > 0) {
1626
- return PopupHandlingModes.Reject;
1223
+ return "reject";
1627
1224
  }
1628
1225
  if (settings > 0) {
1629
- return PopupHandlingModes.None;
1226
+ return "none";
1630
1227
  }
1631
1228
  if (acknowledge > 0) {
1632
- return PopupHandlingModes.Tier1;
1229
+ return "tier1";
1633
1230
  }
1634
1231
  if (accept > 0) {
1635
- return accept === 1 ? PopupHandlingModes.Tier2 : PopupHandlingModes.None;
1232
+ return accept === 1 ? "tier2" : "none";
1636
1233
  }
1637
- return PopupHandlingModes.None;
1234
+ return "none";
1638
1235
  }
1639
1236
  function testButtonMatches(buttonText, matchPatterns, neverMatchPatterns) {
1640
1237
  if (!buttonText) {
@@ -2115,7 +1712,7 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
2115
1712
  }
2116
1713
  };
2117
1714
  var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2118
- constructor(autoconsentInstance, mode = PopupHandlingModes.Reject) {
1715
+ constructor(autoconsentInstance, mode = "reject") {
2119
1716
  super(autoconsentInstance);
2120
1717
  this.popups = [];
2121
1718
  this.name = "HEURISTIC";
@@ -2142,7 +1739,7 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2142
1739
  this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
2143
1740
  this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
2144
1741
  if (this.popups.length > 0) {
2145
- this.name = `HEURISTIC-TIER${this.popups[0].regexClassification}`;
1742
+ this.name = `HEURISTIC-${this.popups[0].regexClassification?.toUpperCase()}`;
2146
1743
  return Promise.resolve(true);
2147
1744
  }
2148
1745
  return Promise.resolve(false);
@@ -2160,7 +1757,7 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2160
1757
  const popup = this.popups[0];
2161
1758
  const level = popup.regexClassification;
2162
1759
  const buttons = popup.buttons;
2163
- const targetButtonType = level === PopupHandlingModes.Reject ? "reject" : level === PopupHandlingModes.Tier1 ? "acknowledge" : "accept";
1760
+ const targetButtonType = level === "reject" ? "reject" : level === "tier1" ? "acknowledge" : "accept";
2164
1761
  return buttons.find((button) => button.regexClassification === targetButtonType);
2165
1762
  }
2166
1763
  optOut() {
@@ -2186,76 +1783,6 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2186
1783
  }
2187
1784
  };
2188
1785
 
2189
- // lib/cmps/consentomatic.ts
2190
- var ConsentOMaticCMP = class {
2191
- constructor(name, config) {
2192
- this.name = name;
2193
- this.config = config;
2194
- this.methods = /* @__PURE__ */ new Map();
2195
- this.runContext = defaultRunContext;
2196
- this.isCosmetic = false;
2197
- config.methods.forEach((methodConfig) => {
2198
- if (methodConfig.action) {
2199
- this.methods.set(methodConfig.name, methodConfig.action);
2200
- }
2201
- });
2202
- this.hasSelfTest = false;
2203
- }
2204
- get isIntermediate() {
2205
- return false;
2206
- }
2207
- checkRunContext() {
2208
- return true;
2209
- }
2210
- checkFrameContext(isTop) {
2211
- return true;
2212
- }
2213
- hasMatchingUrlPattern() {
2214
- return false;
2215
- }
2216
- async detectCmp() {
2217
- const matchResults = this.config.detectors.map((detectorConfig) => matches(detectorConfig.presentMatcher));
2218
- return matchResults.some((r) => !!r);
2219
- }
2220
- async detectPopup() {
2221
- const matchResults = this.config.detectors.map((detectorConfig) => matches(detectorConfig.showingMatcher));
2222
- return matchResults.some((r) => !!r);
2223
- }
2224
- async executeAction(method, param) {
2225
- if (this.methods.has(method)) {
2226
- return executeAction(this.methods.get(method), param);
2227
- }
2228
- return true;
2229
- }
2230
- async optOut() {
2231
- await this.executeAction("HIDE_CMP");
2232
- await this.executeAction("OPEN_OPTIONS");
2233
- await this.executeAction("HIDE_CMP");
2234
- await this.executeAction("DO_CONSENT", []);
2235
- await this.executeAction("SAVE_CONSENT");
2236
- return true;
2237
- }
2238
- async optIn() {
2239
- await this.executeAction("HIDE_CMP");
2240
- await this.executeAction("OPEN_OPTIONS");
2241
- await this.executeAction("HIDE_CMP");
2242
- await this.executeAction("DO_CONSENT", ["D", "A", "B", "E", "F", "X"]);
2243
- await this.executeAction("SAVE_CONSENT");
2244
- return true;
2245
- }
2246
- async openCmp() {
2247
- await this.executeAction("HIDE_CMP");
2248
- await this.executeAction("OPEN_OPTIONS");
2249
- return true;
2250
- }
2251
- async test() {
2252
- return true;
2253
- }
2254
- };
2255
-
2256
- // lib/rules.ts
2257
- var SUPPORTED_RULE_STEP_VERSION = 2;
2258
-
2259
1786
  // lib/cmps/trustarc-top.ts
2260
1787
  var cookieSettingsButton = "#truste-show-consent";
2261
1788
  var shortcutOptOut = "#truste-consent-required";
@@ -3283,15 +2810,15 @@ var DomActions = class {
3283
2810
  }
3284
2811
  querySelectorChain(selectors) {
3285
2812
  let parent = document;
3286
- let matches2 = [];
2813
+ let matches = [];
3287
2814
  for (const selector of selectors) {
3288
- matches2 = this.querySingleReplySelector(selector, parent);
3289
- if (matches2.length === 0) {
2815
+ matches = this.querySingleReplySelector(selector, parent);
2816
+ if (matches.length === 0) {
3290
2817
  return [];
3291
2818
  }
3292
- parent = matches2[0];
2819
+ parent = matches[0];
3293
2820
  }
3294
- return matches2;
2821
+ return matches;
3295
2822
  }
3296
2823
  elementSelector(selector) {
3297
2824
  if (typeof selector === "string") {
@@ -3670,8 +3197,6 @@ var AutoConsent = class {
3670
3197
  this.rules = [];
3671
3198
  __privateAdd(this, _config);
3672
3199
  this.state = {
3673
- cosmeticFiltersOn: false,
3674
- filterListReported: false,
3675
3200
  lifecycle: "loading",
3676
3201
  prehideOn: false,
3677
3202
  findCmpAttempts: 0,
@@ -3721,9 +3246,6 @@ var AutoConsent = class {
3721
3246
  if (declarativeRules) {
3722
3247
  this.parseDeclarativeRules(declarativeRules);
3723
3248
  }
3724
- if (config.enableFilterList) {
3725
- this.initializeFilterList();
3726
- }
3727
3249
  this.rules = filterCMPs(this.rules, normalizedConfig);
3728
3250
  if (this.shouldPrehide) {
3729
3251
  if (document.documentElement) {
@@ -3747,8 +3269,6 @@ var AutoConsent = class {
3747
3269
  }
3748
3270
  this.updateState({ lifecycle: "initialized" });
3749
3271
  }
3750
- initializeFilterList() {
3751
- }
3752
3272
  get shouldPrehide() {
3753
3273
  return this.config.enablePrehide && !this.config.visualTest;
3754
3274
  }
@@ -3777,11 +3297,6 @@ var AutoConsent = class {
3777
3297
  parseDeclarativeRules(declarativeRules) {
3778
3298
  const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
3779
3299
  perfEnabled && performance.mark("parseDeclarativeRulesStart");
3780
- if (declarativeRules.consentomatic) {
3781
- for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
3782
- this.addConsentomaticCMP(name, rule);
3783
- }
3784
- }
3785
3300
  if (declarativeRules.autoconsent) {
3786
3301
  declarativeRules.autoconsent.forEach((ruleset) => {
3787
3302
  this.addDeclarativeCMP(ruleset);
@@ -3803,9 +3318,6 @@ var AutoConsent = class {
3803
3318
  this.rules.push(new AutoConsentCMP(ruleset, this));
3804
3319
  }
3805
3320
  }
3806
- addConsentomaticCMP(name, config) {
3807
- this.rules.push(new ConsentOMaticCMP(`com_${name}`, config));
3808
- }
3809
3321
  // start the detection process, possibly with a delay
3810
3322
  start() {
3811
3323
  scheduleWhenIdle(() => this._start());
@@ -3824,7 +3336,8 @@ var AutoConsent = class {
3824
3336
  if (this.shouldPrehide) {
3825
3337
  this.undoPrehide();
3826
3338
  }
3827
- return this.filterListFallback();
3339
+ this.updateState({ lifecycle: "nothingDetected" });
3340
+ return false;
3828
3341
  }
3829
3342
  this.updateState({ lifecycle: "cmpDetected" });
3830
3343
  const staticCmps = [];
@@ -3882,7 +3395,7 @@ var AutoConsent = class {
3882
3395
  }
3883
3396
  }
3884
3397
  });
3885
- const heuristicRules = isTop && this.config.enableHeuristicAction && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
3398
+ const heuristicRules = isTop && this.config.heuristicMode !== "off" && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
3886
3399
  const rulesPriorityStages = [
3887
3400
  ["site-specific", siteSpecificRules],
3888
3401
  ["generic", genericRules],
@@ -3990,9 +3503,6 @@ var AutoConsent = class {
3990
3503
  if (this.shouldPrehide && !this.state.prehideOn) {
3991
3504
  this.prehideElements();
3992
3505
  }
3993
- if (this.state.cosmeticFiltersOn) {
3994
- this.undoCosmetics();
3995
- }
3996
3506
  this.foundCmp = cmp;
3997
3507
  if (this.config.autoAction === "optOut") {
3998
3508
  return await this.doOptOut();
@@ -4156,25 +3666,6 @@ var AutoConsent = class {
4156
3666
  this.updateState({ prehideOn: false });
4157
3667
  this.domActions.undoPrehide();
4158
3668
  }
4159
- undoCosmetics() {
4160
- }
4161
- reportFilterlist() {
4162
- this.sendContentMessage({
4163
- type: "cmpDetected",
4164
- url: location.href,
4165
- cmp: "filterList"
4166
- });
4167
- this.sendContentMessage({
4168
- type: "popupFound",
4169
- cmp: "filterList",
4170
- url: location.href
4171
- });
4172
- this.updateState({ filterListReported: true });
4173
- }
4174
- filterListFallback() {
4175
- this.updateState({ lifecycle: "nothingDetected" });
4176
- return false;
4177
- }
4178
3669
  updateState(change) {
4179
3670
  Object.assign(this.state, change);
4180
3671
  this.sendContentMessage({