@duckduckgo/autoconsent 15.0.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 (90) 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 +32 -0
  5. package/build.sh +3 -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 +184 -686
  9. package/dist/addon-firefox/manifest.json +1 -1
  10. package/dist/addon-firefox/popup.bundle.js +196 -25
  11. package/dist/addon-firefox/popup.html +98 -5
  12. package/dist/addon-firefox/rule-index.json +1 -0
  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 +184 -686
  17. package/dist/addon-mv3/manifest.json +1 -1
  18. package/dist/addon-mv3/popup.bundle.js +196 -25
  19. package/dist/addon-mv3/popup.html +98 -5
  20. package/dist/addon-mv3/rule-index.json +1 -0
  21. package/dist/addon-mv3/rules.json +1 -1
  22. package/dist/autoconsent.cjs.js +184 -685
  23. package/dist/autoconsent.esm.js +184 -685
  24. package/dist/autoconsent.playwright.js +185 -689
  25. package/dist/autoconsent.standalone.js +3625 -0
  26. package/dist/types/cmps/base.d.ts +3 -3
  27. package/dist/types/cmps/trustarc-top.d.ts +1 -1
  28. package/dist/types/eval-handler.d.ts +3 -3
  29. package/dist/types/heuristics.d.ts +2 -2
  30. package/dist/types/types.d.ts +10 -23
  31. package/dist/types/web.d.ts +0 -9
  32. package/docs/api.md +1 -8
  33. package/docs/puppeteer.md +1 -3
  34. package/docs/rule-syntax.md +0 -17
  35. package/eslint.config.mjs +1 -1
  36. package/lib/cmps/base.ts +5 -6
  37. package/lib/cmps/conversant.ts +7 -4
  38. package/lib/cmps/trustarc-top.ts +1 -1
  39. package/lib/cmps/uniconsent.ts +4 -4
  40. package/lib/eval-handler.ts +6 -3
  41. package/lib/heuristics.ts +15 -15
  42. package/lib/types.ts +9 -21
  43. package/lib/utils.ts +13 -9
  44. package/lib/web.ts +3 -53
  45. package/package.json +4 -17
  46. package/playwright/content.ts +1 -2
  47. package/readme.md +3 -6
  48. package/rules/autoconsent/dreamlab-cmp.json +13 -0
  49. package/rules/build.ts +4 -23
  50. package/rules/compact-rules.json +1 -1
  51. package/rules/rule-index-builder.ts +58 -0
  52. package/rules/rule-index.json +1 -0
  53. package/rules/rules.json +1 -1
  54. package/standalone/content.ts +101 -0
  55. package/tests/dreamlab-cmp.spec.ts +3 -0
  56. package/tests/quantcast.spec.ts +0 -6
  57. package/tests-wtr/heuristics/get-actionable-popups.ts +13 -13
  58. package/tests-wtr/heuristics/heuristic-cmp.ts +32 -33
  59. package/tests-wtr/lifecycle/find-cmp.ts +5 -8
  60. package/tests-wtr/web/do-opt-in.test.ts +0 -1
  61. package/tests-wtr/web/do-opt-out.test.ts +0 -1
  62. package/tests-wtr/web/do-self-test.test.ts +0 -1
  63. package/tests-wtr/web/filter-cmps.test.ts +0 -1
  64. package/tests-wtr/web/receive-message-callback.test.ts +1 -2
  65. package/tests-wtr/web/update-state.test.ts +1 -3
  66. package/tsconfig.build.json +1 -1
  67. package/.github/workflows/update-filterlist.yml +0 -42
  68. package/dist/autoconsent.extra.cjs.js +0 -15709
  69. package/dist/autoconsent.extra.esm.js +0 -15641
  70. package/dist/types/cmps/consentomatic.d.ts +0 -34
  71. package/dist/types/consentomatic/index.d.ts +0 -2
  72. package/dist/types/consentomatic/tools.d.ts +0 -10
  73. package/dist/types/filterlist-engine.d.ts +0 -2
  74. package/dist/types/filterlist-utils.d.ts +0 -4
  75. package/dist/types/web-extra.d.ts +0 -11
  76. package/lib/cmps/consentomatic.ts +0 -97
  77. package/lib/consentomatic/index.ts +0 -252
  78. package/lib/consentomatic/tools.ts +0 -199
  79. package/lib/filterlist-engine.ts +0 -5
  80. package/lib/filterlist-utils.ts +0 -45
  81. package/lib/web-extra.ts +0 -116
  82. package/rules/consentomatic.json +0 -1
  83. package/rules/filterlist.txt +0 -18440
  84. package/rules/filterlists/overrides.txt +0 -4
  85. package/scripts/compile-filterlist.mjs +0 -63
  86. package/scripts/fetch-easylist.sh +0 -25
  87. package/scripts/rebuild-filterlist.mjs +0 -216
  88. package/tests/oil.spec.ts +0 -7
  89. package/tests/springer.spec.ts +0 -7
  90. package/tests/wordpressgdpr.spec.ts +0 -6
@@ -6,412 +6,8 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
7
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
8
 
9
- // lib/consentomatic/tools.ts
10
- var _Tools = class _Tools {
11
- static setBase(base) {
12
- _Tools.base = base;
13
- }
14
- static findElement(options, parent = null, multiple = false) {
15
- let possibleTargets = null;
16
- if (parent != null) {
17
- possibleTargets = Array.from(parent.querySelectorAll(options.selector));
18
- } else {
19
- if (_Tools.base != null) {
20
- possibleTargets = Array.from(
21
- _Tools.base.querySelectorAll(options.selector)
22
- );
23
- } else {
24
- possibleTargets = Array.from(
25
- document.querySelectorAll(options.selector)
26
- );
27
- }
28
- }
29
- if (options.textFilter != null) {
30
- possibleTargets = possibleTargets.filter((possibleTarget) => {
31
- const textContent = possibleTarget.textContent.toLowerCase();
32
- if (Array.isArray(options.textFilter)) {
33
- let foundText = false;
34
- for (const text of options.textFilter) {
35
- if (textContent.indexOf(text.toLowerCase()) !== -1) {
36
- foundText = true;
37
- break;
38
- }
39
- }
40
- return foundText;
41
- } else if (options.textFilter != null) {
42
- return textContent.indexOf(options.textFilter.toLowerCase()) !== -1;
43
- }
44
- return false;
45
- });
46
- }
47
- if (options.styleFilters != null) {
48
- possibleTargets = possibleTargets.filter((possibleTarget) => {
49
- const styles = window.getComputedStyle(possibleTarget);
50
- let keep = true;
51
- for (const styleFilter of options.styleFilters) {
52
- const option = styles[styleFilter.option];
53
- if (styleFilter.negated) {
54
- keep = keep && option !== styleFilter.value;
55
- } else {
56
- keep = keep && option === styleFilter.value;
57
- }
58
- }
59
- return keep;
60
- });
61
- }
62
- if (options.displayFilter != null) {
63
- possibleTargets = possibleTargets.filter((possibleTarget) => {
64
- if (options.displayFilter) {
65
- return possibleTarget.offsetHeight !== 0;
66
- } else {
67
- return possibleTarget.offsetHeight === 0;
68
- }
69
- });
70
- }
71
- if (options.iframeFilter != null) {
72
- possibleTargets = possibleTargets.filter(() => {
73
- if (options.iframeFilter) {
74
- return window.location !== window.parent.location;
75
- } else {
76
- return window.location === window.parent.location;
77
- }
78
- });
79
- }
80
- if (options.childFilter != null) {
81
- possibleTargets = possibleTargets.filter((possibleTarget) => {
82
- const oldBase = _Tools.base;
83
- _Tools.setBase(possibleTarget);
84
- const childResults = _Tools.find(options.childFilter);
85
- _Tools.setBase(oldBase);
86
- return childResults.target != null;
87
- });
88
- }
89
- if (multiple) {
90
- return possibleTargets;
91
- } else {
92
- if (possibleTargets.length > 1) {
93
- console.warn(
94
- "Multiple possible targets: ",
95
- possibleTargets,
96
- options,
97
- parent
98
- );
99
- }
100
- return possibleTargets[0];
101
- }
102
- }
103
- static find(options, multiple = false) {
104
- const results = [];
105
- if (options.parent != null) {
106
- const parent = _Tools.findElement(options.parent, null, multiple);
107
- if (parent != null) {
108
- if (parent instanceof Array) {
109
- parent.forEach((p) => {
110
- const targets = _Tools.findElement(options.target, p, multiple);
111
- if (targets instanceof Array) {
112
- targets.forEach((target) => {
113
- results.push({
114
- parent: p,
115
- target
116
- });
117
- });
118
- } else {
119
- results.push({
120
- parent: p,
121
- target: targets
122
- });
123
- }
124
- });
125
- return results;
126
- } else {
127
- const targets = _Tools.findElement(options.target, parent, multiple);
128
- if (targets instanceof Array) {
129
- targets.forEach((target) => {
130
- results.push({
131
- parent,
132
- target
133
- });
134
- });
135
- } else {
136
- results.push({
137
- parent,
138
- target: targets
139
- });
140
- }
141
- }
142
- }
143
- } else {
144
- const targets = _Tools.findElement(options.target, null, multiple);
145
- if (targets instanceof Array) {
146
- targets.forEach((target) => {
147
- results.push({
148
- parent: null,
149
- target
150
- });
151
- });
152
- } else {
153
- results.push({
154
- parent: null,
155
- target: targets
156
- });
157
- }
158
- }
159
- if (results.length === 0) {
160
- results.push({
161
- parent: null,
162
- target: null
163
- });
164
- }
165
- if (multiple) {
166
- return results;
167
- } else {
168
- if (results.length !== 1) {
169
- console.warn(
170
- "Multiple results found, even though multiple false",
171
- results
172
- );
173
- }
174
- return results[0];
175
- }
176
- }
177
- };
178
- _Tools.base = null;
179
- var Tools = _Tools;
180
-
181
- // lib/consentomatic/index.ts
182
- function matches(config) {
183
- const result = Tools.find(config);
184
- if (config.type === "css") {
185
- return !!result.target;
186
- } else if (config.type === "checkbox") {
187
- return !!result.target && result.target.checked;
188
- }
189
- }
190
- async function executeAction(config, param) {
191
- switch (config.type) {
192
- case "click":
193
- return clickAction(config);
194
- case "list":
195
- return listAction(config, param);
196
- case "consent":
197
- return consentAction(config, param);
198
- case "ifcss":
199
- return ifCssAction(config, param);
200
- case "waitcss":
201
- return waitCssAction(config);
202
- case "foreach":
203
- return forEachAction(config, param);
204
- case "hide":
205
- return hideAction(config);
206
- case "slide":
207
- return slideAction(config);
208
- case "close":
209
- return closeAction();
210
- case "wait":
211
- return waitAction(config);
212
- case "eval":
213
- return evalAction(config);
214
- default:
215
- throw new Error("Unknown action type: " + config.type);
216
- }
217
- }
218
- var STEP_TIMEOUT = 0;
219
- function waitTimeout(timeout) {
220
- return new Promise((resolve) => {
221
- setTimeout(() => {
222
- resolve();
223
- }, timeout);
224
- });
225
- }
226
- async function clickAction(config) {
227
- const result = Tools.find(config);
228
- if (result.target != null) {
229
- result.target.click();
230
- }
231
- return waitTimeout(STEP_TIMEOUT);
232
- }
233
- async function listAction(config, param) {
234
- for (const action of config.actions) {
235
- await executeAction(action, param);
236
- }
237
- }
238
- async function consentAction(config, consentTypes) {
239
- for (const consentConfig of config.consents) {
240
- const shouldEnable = consentTypes.indexOf(consentConfig.type) !== -1;
241
- if (consentConfig.matcher && consentConfig.toggleAction) {
242
- const isEnabled = matches(consentConfig.matcher);
243
- if (isEnabled !== shouldEnable) {
244
- await executeAction(consentConfig.toggleAction);
245
- }
246
- } else {
247
- if (shouldEnable) {
248
- await executeAction(consentConfig.trueAction);
249
- } else {
250
- await executeAction(consentConfig.falseAction);
251
- }
252
- }
253
- }
254
- }
255
- async function ifCssAction(config, param) {
256
- const result = Tools.find(config);
257
- if (!result.target) {
258
- if (config.trueAction) {
259
- await executeAction(config.trueAction, param);
260
- }
261
- } else {
262
- if (config.falseAction) {
263
- await executeAction(config.falseAction, param);
264
- }
265
- }
266
- }
267
- async function waitCssAction(config) {
268
- await new Promise((resolve) => {
269
- let numRetries = config.retries || 10;
270
- const waitTime = config.waitTime || 250;
271
- const checkCss = () => {
272
- const result = Tools.find(config);
273
- if (config.negated && result.target || !config.negated && !result.target) {
274
- if (numRetries > 0) {
275
- numRetries -= 1;
276
- setTimeout(checkCss, waitTime);
277
- } else {
278
- resolve();
279
- }
280
- } else {
281
- resolve();
282
- }
283
- };
284
- checkCss();
285
- });
286
- }
287
- async function forEachAction(config, param) {
288
- const results = Tools.find(config, true);
289
- const oldBase = Tools.base;
290
- for (const result of results) {
291
- if (result.target) {
292
- Tools.setBase(result.target);
293
- await executeAction(config.action, param);
294
- }
295
- }
296
- Tools.setBase(oldBase);
297
- }
298
- async function hideAction(config) {
299
- const result = Tools.find(config);
300
- if (result.target) {
301
- result.target.classList.add("Autoconsent-Hidden");
302
- }
303
- }
304
- async function slideAction(config) {
305
- const result = Tools.find(config);
306
- const dragResult = Tools.find(config.dragTarget);
307
- if (result.target) {
308
- const targetBounds = result.target.getBoundingClientRect();
309
- const dragTargetBounds = dragResult.target.getBoundingClientRect();
310
- let yDiff = dragTargetBounds.top - targetBounds.top;
311
- let xDiff = dragTargetBounds.left - targetBounds.left;
312
- if (this.config.axis.toLowerCase() === "y") {
313
- xDiff = 0;
314
- }
315
- if (this.config.axis.toLowerCase() === "x") {
316
- yDiff = 0;
317
- }
318
- const screenX = window.screenX + targetBounds.left + targetBounds.width / 2;
319
- const screenY = window.screenY + targetBounds.top + targetBounds.height / 2;
320
- const clientX = targetBounds.left + targetBounds.width / 2;
321
- const clientY = targetBounds.top + targetBounds.height / 2;
322
- const mouseDown = document.createEvent("MouseEvents");
323
- mouseDown.initMouseEvent(
324
- "mousedown",
325
- true,
326
- true,
327
- window,
328
- 0,
329
- screenX,
330
- screenY,
331
- clientX,
332
- clientY,
333
- false,
334
- false,
335
- false,
336
- false,
337
- 0,
338
- result.target
339
- );
340
- const mouseMove = document.createEvent("MouseEvents");
341
- mouseMove.initMouseEvent(
342
- "mousemove",
343
- true,
344
- true,
345
- window,
346
- 0,
347
- screenX + xDiff,
348
- screenY + yDiff,
349
- clientX + xDiff,
350
- clientY + yDiff,
351
- false,
352
- false,
353
- false,
354
- false,
355
- 0,
356
- result.target
357
- );
358
- const mouseUp = document.createEvent("MouseEvents");
359
- mouseUp.initMouseEvent(
360
- "mouseup",
361
- true,
362
- true,
363
- window,
364
- 0,
365
- screenX + xDiff,
366
- screenY + yDiff,
367
- clientX + xDiff,
368
- clientY + yDiff,
369
- false,
370
- false,
371
- false,
372
- false,
373
- 0,
374
- result.target
375
- );
376
- result.target.dispatchEvent(mouseDown);
377
- await this.waitTimeout(10);
378
- result.target.dispatchEvent(mouseMove);
379
- await this.waitTimeout(10);
380
- result.target.dispatchEvent(mouseUp);
381
- }
382
- }
383
- async function waitAction(config) {
384
- await waitTimeout(config.waitTime);
385
- }
386
- async function closeAction() {
387
- window.close();
388
- }
389
- async function evalAction(config) {
390
- console.log("eval!", config.code);
391
- return new Promise((resolve) => {
392
- try {
393
- if (config.async) {
394
- window.eval(config.code);
395
- setTimeout(() => {
396
- resolve(window.eval("window.__consentCheckResult"));
397
- }, config.timeout || 250);
398
- } else {
399
- resolve(window.eval(config.code));
400
- }
401
- } catch (e) {
402
- console.warn("eval error", e, config.code);
403
- resolve(false);
404
- }
405
- });
406
- }
407
-
408
- // lib/types.ts
409
- var PopupHandlingModes = {
410
- None: -1,
411
- Reject: 0,
412
- Tier1: 1,
413
- Tier2: 2
414
- };
9
+ // lib/rules.ts
10
+ var SUPPORTED_RULE_STEP_VERSION = 2;
415
11
 
416
12
  // lib/random.ts
417
13
  function getRandomID() {
@@ -439,6 +35,9 @@ var evalState = {
439
35
  sendContentMessage: null
440
36
  };
441
37
  function requestEval(code, snippetId) {
38
+ if (!evalState.sendContentMessage) {
39
+ return Promise.reject(new Error("AutoConsent is not initialized yet"));
40
+ }
442
41
  const id = getRandomID();
443
42
  evalState.sendContentMessage({
444
43
  type: "eval",
@@ -461,6 +60,155 @@ function resolveEval(id, value) {
461
60
  }
462
61
  }
463
62
 
63
+ // lib/utils.ts
64
+ function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
65
+ const styleSelector = `style#${styleOverrideElementId}`;
66
+ const existingElement = document.querySelector(styleSelector);
67
+ if (existingElement && existingElement instanceof HTMLStyleElement) {
68
+ return existingElement;
69
+ } else {
70
+ const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
71
+ const css = document.createElement("style");
72
+ css.id = styleOverrideElementId;
73
+ parent.appendChild(css);
74
+ return css;
75
+ }
76
+ }
77
+ function getHidingStyle(method) {
78
+ const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
79
+ return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
80
+ }
81
+ function hideElements(styleEl, selector, method = "display") {
82
+ const rule = `${selector} { ${getHidingStyle(method)} } `;
83
+ if (styleEl instanceof HTMLStyleElement) {
84
+ styleEl.innerText += rule;
85
+ return selector.length > 0;
86
+ }
87
+ return false;
88
+ }
89
+ async function waitFor(predicate, maxTimes, interval) {
90
+ const result = await predicate();
91
+ if (!result && maxTimes > 0) {
92
+ return new Promise((resolve) => {
93
+ setTimeout(async () => {
94
+ resolve(waitFor(predicate, maxTimes - 1, interval));
95
+ }, interval);
96
+ });
97
+ }
98
+ return Promise.resolve(result);
99
+ }
100
+ function isElementVisible(elem) {
101
+ if (!elem) {
102
+ return false;
103
+ }
104
+ if (elem.offsetParent !== null) {
105
+ return true;
106
+ } else {
107
+ const css = window.getComputedStyle(elem);
108
+ if (css.position === "fixed" && css.display !== "none") {
109
+ return true;
110
+ }
111
+ }
112
+ return false;
113
+ }
114
+ function copyObject(data) {
115
+ if (globalThis.structuredClone) {
116
+ return structuredClone(data);
117
+ }
118
+ return JSON.parse(JSON.stringify(data));
119
+ }
120
+ function normalizeConfig(providedConfig) {
121
+ const defaultConfig = {
122
+ enabled: true,
123
+ autoAction: "optOut",
124
+ // if falsy, the extension will wait for an explicit user signal before opting in/out
125
+ disabledCmps: [],
126
+ enablePrehide: true,
127
+ enableCosmeticRules: true,
128
+ enableGeneratedRules: true,
129
+ enableHeuristicDetection: false,
130
+ enablePopupMutationObserver: false,
131
+ detectRetries: 20,
132
+ isMainWorld: false,
133
+ prehideTimeout: 2e3,
134
+ visualTest: false,
135
+ logs: {
136
+ lifecycle: false,
137
+ rulesteps: false,
138
+ detectionsteps: false,
139
+ evals: false,
140
+ errors: true,
141
+ messages: false,
142
+ waits: false
143
+ },
144
+ performanceLoggingEnabled: false,
145
+ heuristicPopupSearchTimeout: 100,
146
+ heuristicMode: "off"
147
+ // heuristic disabled by default
148
+ };
149
+ const updatedConfig = copyObject(defaultConfig);
150
+ for (const key of Object.keys(defaultConfig)) {
151
+ if (typeof providedConfig[key] !== "undefined") {
152
+ updatedConfig[key] = providedConfig[key];
153
+ }
154
+ }
155
+ return updatedConfig;
156
+ }
157
+ function scheduleWhenIdle(callback, timeout = 500) {
158
+ if (globalThis.requestIdleCallback) {
159
+ requestIdleCallback(callback, { timeout });
160
+ } else {
161
+ setTimeout(callback, 0);
162
+ }
163
+ }
164
+ function highlightNode(node) {
165
+ const highlightedNode = node;
166
+ if (!node.style) return;
167
+ if (highlightedNode.__oldStyles !== void 0) {
168
+ return;
169
+ }
170
+ if (node.hasAttribute("style")) {
171
+ highlightedNode.__oldStyles = node.style.cssText;
172
+ }
173
+ node.style.animation = "pulsate .5s infinite";
174
+ node.style.outline = "solid red";
175
+ let styleTag = document.querySelector("style#autoconsent-debug-styles");
176
+ if (!styleTag) {
177
+ styleTag = document.createElement("style");
178
+ styleTag.id = "autoconsent-debug-styles";
179
+ }
180
+ styleTag.textContent = `
181
+ @keyframes pulsate {
182
+ 0% {
183
+ outline-width: 8px;
184
+ outline-offset: -4px;
185
+ }
186
+ 50% {
187
+ outline-width: 4px;
188
+ outline-offset: -2px;
189
+ }
190
+ 100% {
191
+ outline-width: 8px;
192
+ outline-offset: -4px;
193
+ }
194
+ }
195
+ `;
196
+ document.head.appendChild(styleTag);
197
+ }
198
+ function unhighlightNode(node) {
199
+ const highlightedNode = node;
200
+ if (!node.style || !node.hasAttribute("style")) return;
201
+ if (highlightedNode.__oldStyles !== void 0) {
202
+ node.style.cssText = highlightedNode.__oldStyles;
203
+ delete highlightedNode.__oldStyles;
204
+ } else {
205
+ node.removeAttribute("style");
206
+ }
207
+ }
208
+ function isTopFrame() {
209
+ return window.top === window && (!globalThis.location.ancestorOrigins || globalThis.location.ancestorOrigins.length === 0);
210
+ }
211
+
464
212
  // lib/eval-snippets.ts
465
213
  var snippets = {
466
214
  // code-based rules
@@ -638,154 +386,6 @@ function getFunctionBody(snippetFunc) {
638
386
  return `(${snippetStr})()`;
639
387
  }
640
388
 
641
- // lib/utils.ts
642
- function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
643
- const styleSelector = `style#${styleOverrideElementId}`;
644
- const existingElement = document.querySelector(styleSelector);
645
- if (existingElement && existingElement instanceof HTMLStyleElement) {
646
- return existingElement;
647
- } else {
648
- const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
649
- const css = document.createElement("style");
650
- css.id = styleOverrideElementId;
651
- parent.appendChild(css);
652
- return css;
653
- }
654
- }
655
- function getHidingStyle(method) {
656
- const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
657
- return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
658
- }
659
- function hideElements(styleEl, selector, method = "display") {
660
- const rule = `${selector} { ${getHidingStyle(method)} } `;
661
- if (styleEl instanceof HTMLStyleElement) {
662
- styleEl.innerText += rule;
663
- return selector.length > 0;
664
- }
665
- return false;
666
- }
667
- async function waitFor(predicate, maxTimes, interval) {
668
- const result = await predicate();
669
- if (!result && maxTimes > 0) {
670
- return new Promise((resolve) => {
671
- setTimeout(async () => {
672
- resolve(waitFor(predicate, maxTimes - 1, interval));
673
- }, interval);
674
- });
675
- }
676
- return Promise.resolve(result);
677
- }
678
- function isElementVisible(elem) {
679
- if (!elem) {
680
- return false;
681
- }
682
- if (elem.offsetParent !== null) {
683
- return true;
684
- } else {
685
- const css = window.getComputedStyle(elem);
686
- if (css.position === "fixed" && css.display !== "none") {
687
- return true;
688
- }
689
- }
690
- return false;
691
- }
692
- function copyObject(data) {
693
- if (globalThis.structuredClone) {
694
- return structuredClone(data);
695
- }
696
- return JSON.parse(JSON.stringify(data));
697
- }
698
- function normalizeConfig(providedConfig) {
699
- const defaultConfig = {
700
- enabled: true,
701
- autoAction: "optOut",
702
- // if falsy, the extension will wait for an explicit user signal before opting in/out
703
- disabledCmps: [],
704
- enablePrehide: true,
705
- enableCosmeticRules: true,
706
- enableGeneratedRules: true,
707
- enableHeuristicDetection: false,
708
- enableHeuristicAction: false,
709
- enablePopupMutationObserver: false,
710
- detectRetries: 20,
711
- isMainWorld: false,
712
- prehideTimeout: 2e3,
713
- enableFilterList: false,
714
- visualTest: false,
715
- logs: {
716
- lifecycle: false,
717
- rulesteps: false,
718
- detectionsteps: false,
719
- evals: false,
720
- errors: true,
721
- messages: false,
722
- waits: false
723
- },
724
- performanceLoggingEnabled: false,
725
- heuristicPopupSearchTimeout: 100,
726
- heuristicMode: PopupHandlingModes.Reject
727
- };
728
- const updatedConfig = copyObject(defaultConfig);
729
- for (const key of Object.keys(defaultConfig)) {
730
- if (typeof providedConfig[key] !== "undefined") {
731
- updatedConfig[key] = providedConfig[key];
732
- }
733
- }
734
- return updatedConfig;
735
- }
736
- function scheduleWhenIdle(callback, timeout = 500) {
737
- if (globalThis.requestIdleCallback) {
738
- requestIdleCallback(callback, { timeout });
739
- } else {
740
- setTimeout(callback, 0);
741
- }
742
- }
743
- function highlightNode(node) {
744
- if (!node.style) return;
745
- if (node.__oldStyles !== void 0) {
746
- return;
747
- }
748
- if (node.hasAttribute("style")) {
749
- node.__oldStyles = node.style.cssText;
750
- }
751
- node.style.animation = "pulsate .5s infinite";
752
- node.style.outline = "solid red";
753
- let styleTag = document.querySelector("style#autoconsent-debug-styles");
754
- if (!styleTag) {
755
- styleTag = document.createElement("style");
756
- styleTag.id = "autoconsent-debug-styles";
757
- }
758
- styleTag.textContent = `
759
- @keyframes pulsate {
760
- 0% {
761
- outline-width: 8px;
762
- outline-offset: -4px;
763
- }
764
- 50% {
765
- outline-width: 4px;
766
- outline-offset: -2px;
767
- }
768
- 100% {
769
- outline-width: 8px;
770
- outline-offset: -4px;
771
- }
772
- }
773
- `;
774
- document.head.appendChild(styleTag);
775
- }
776
- function unhighlightNode(node) {
777
- if (!node.style || !node.hasAttribute("style")) return;
778
- if (node.__oldStyles !== void 0) {
779
- node.style.cssText = node.__oldStyles;
780
- delete node.__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
389
  // lib/heuristic-patterns.ts
790
390
  var DETECT_PATTERNS = [
791
391
  /accept cookies/gi,
@@ -1544,15 +1144,19 @@ function checkHeuristicPatterns(allText, detectPatterns = DETECT_PATTERNS) {
1544
1144
  const patterns = [];
1545
1145
  const snippets2 = [];
1546
1146
  for (const p of detectPatterns) {
1547
- const matches2 = allText?.match(p);
1548
- if (matches2) {
1147
+ const matches = allText?.match(p);
1148
+ if (matches) {
1549
1149
  patterns.push(p.toString());
1550
- snippets2.push(...matches2.map((m) => m.substring(0, 200)));
1150
+ snippets2.push(...matches.map((m) => m.substring(0, 200)));
1551
1151
  }
1552
1152
  }
1553
1153
  return { patterns, snippets: snippets2 };
1554
1154
  }
1555
- function getActionablePopups(mode = PopupHandlingModes.Reject, timeout = POPUP_SEARCH_MAX_TIME) {
1155
+ function getActionablePopups(mode = "reject", timeout = POPUP_SEARCH_MAX_TIME) {
1156
+ const acceptedLevels = mode === "tier2" ? ["reject", "tier1", "tier2"] : mode === "tier1" ? ["reject", "tier1"] : ["reject"];
1157
+ if (acceptedLevels.length === 0) {
1158
+ return [];
1159
+ }
1556
1160
  const popups = getPotentialPopups(timeout);
1557
1161
  const result = popups.reduce((acc, popup) => {
1558
1162
  const popupText = popup.text?.trim();
@@ -1568,9 +1172,7 @@ function getActionablePopups(mode = PopupHandlingModes.Reject, timeout = POPUP_S
1568
1172
  }
1569
1173
  return acc;
1570
1174
  }, []);
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));
1175
+ return result.filter((popup) => popup.regexClassification !== void 0 && acceptedLevels.includes(popup.regexClassification)).sort((a, b) => (a.regexClassification ?? "") > (b.regexClassification ?? "") ? 1 : -1);
1574
1176
  }
1575
1177
  function classifyButtons(buttons) {
1576
1178
  for (const button of buttons) {
@@ -1588,18 +1190,18 @@ function classifyPopup(buttons) {
1588
1190
  { reject: 0, settings: 0, accept: 0, acknowledge: 0 }
1589
1191
  );
1590
1192
  if (reject > 0) {
1591
- return PopupHandlingModes.Reject;
1193
+ return "reject";
1592
1194
  }
1593
1195
  if (settings > 0) {
1594
- return PopupHandlingModes.None;
1196
+ return "none";
1595
1197
  }
1596
1198
  if (acknowledge > 0) {
1597
- return PopupHandlingModes.Tier1;
1199
+ return "tier1";
1598
1200
  }
1599
1201
  if (accept > 0) {
1600
- return accept === 1 ? PopupHandlingModes.Tier2 : PopupHandlingModes.None;
1202
+ return accept === 1 ? "tier2" : "none";
1601
1203
  }
1602
- return PopupHandlingModes.None;
1204
+ return "none";
1603
1205
  }
1604
1206
  function testButtonMatches(buttonText, matchPatterns, neverMatchPatterns) {
1605
1207
  if (!buttonText) {
@@ -2080,7 +1682,7 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
2080
1682
  }
2081
1683
  };
2082
1684
  var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2083
- constructor(autoconsentInstance, mode = PopupHandlingModes.Reject) {
1685
+ constructor(autoconsentInstance, mode = "reject") {
2084
1686
  super(autoconsentInstance);
2085
1687
  this.popups = [];
2086
1688
  this.name = "HEURISTIC";
@@ -2107,7 +1709,7 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2107
1709
  this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
2108
1710
  this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
2109
1711
  if (this.popups.length > 0) {
2110
- this.name = `HEURISTIC-TIER${this.popups[0].regexClassification}`;
1712
+ this.name = `HEURISTIC-${this.popups[0].regexClassification?.toUpperCase()}`;
2111
1713
  return Promise.resolve(true);
2112
1714
  }
2113
1715
  return Promise.resolve(false);
@@ -2125,7 +1727,7 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2125
1727
  const popup = this.popups[0];
2126
1728
  const level = popup.regexClassification;
2127
1729
  const buttons = popup.buttons;
2128
- const targetButtonType = level === PopupHandlingModes.Reject ? "reject" : level === PopupHandlingModes.Tier1 ? "acknowledge" : "accept";
1730
+ const targetButtonType = level === "reject" ? "reject" : level === "tier1" ? "acknowledge" : "accept";
2129
1731
  return buttons.find((button) => button.regexClassification === targetButtonType);
2130
1732
  }
2131
1733
  optOut() {
@@ -2151,76 +1753,6 @@ var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
2151
1753
  }
2152
1754
  };
2153
1755
 
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
1756
  // lib/cmps/trustarc-top.ts
2225
1757
  var cookieSettingsButton = "#truste-show-consent";
2226
1758
  var shortcutOptOut = "#truste-consent-required";
@@ -2823,7 +2355,7 @@ var Uniconsent = class extends AutoConsentCMPBase {
2823
2355
  async optOut() {
2824
2356
  await this.waitForElement(".unic button", 1e3);
2825
2357
  document.querySelectorAll(".unic button").forEach((button) => {
2826
- const text = button.textContent;
2358
+ const text = button.textContent || "";
2827
2359
  if (text.includes("Manage Options") || text.includes("Optionen verwalten")) {
2828
2360
  button.click();
2829
2361
  }
@@ -2836,7 +2368,7 @@ var Uniconsent = class extends AutoConsentCMPBase {
2836
2368
  }
2837
2369
  });
2838
2370
  for (const b of document.querySelectorAll(".unic button")) {
2839
- const text = b.textContent;
2371
+ const text = b.textContent || "";
2840
2372
  for (const pattern of ["Confirm Choices", "Save Choices", "Auswahl speichern"]) {
2841
2373
  if (text.includes(pattern)) {
2842
2374
  b.click();
@@ -2893,6 +2425,9 @@ var Conversant = class extends AutoConsentCMPBase {
2893
2425
  item.querySelector(".cmp-accordion-item-title").click();
2894
2426
  await waitFor(() => !!item.querySelector(".cmp-accordion-item-content.cmp-active"), 10, 50);
2895
2427
  const content = item.querySelector(".cmp-accordion-item-content.cmp-active");
2428
+ if (!content) {
2429
+ return false;
2430
+ }
2896
2431
  content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((e) => e.click());
2897
2432
  content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((e) => e.click());
2898
2433
  }
@@ -3245,15 +2780,15 @@ var DomActions = class {
3245
2780
  }
3246
2781
  querySelectorChain(selectors) {
3247
2782
  let parent = document;
3248
- let matches2 = [];
2783
+ let matches = [];
3249
2784
  for (const selector of selectors) {
3250
- matches2 = this.querySingleReplySelector(selector, parent);
3251
- if (matches2.length === 0) {
2785
+ matches = this.querySingleReplySelector(selector, parent);
2786
+ if (matches.length === 0) {
3252
2787
  return [];
3253
2788
  }
3254
- parent = matches2[0];
2789
+ parent = matches[0];
3255
2790
  }
3256
- return matches2;
2791
+ return matches;
3257
2792
  }
3258
2793
  elementSelector(selector) {
3259
2794
  if (typeof selector === "string") {
@@ -3632,8 +3167,6 @@ var AutoConsent = class {
3632
3167
  this.rules = [];
3633
3168
  __privateAdd(this, _config);
3634
3169
  this.state = {
3635
- cosmeticFiltersOn: false,
3636
- filterListReported: false,
3637
3170
  lifecycle: "loading",
3638
3171
  prehideOn: false,
3639
3172
  findCmpAttempts: 0,
@@ -3683,9 +3216,6 @@ var AutoConsent = class {
3683
3216
  if (declarativeRules) {
3684
3217
  this.parseDeclarativeRules(declarativeRules);
3685
3218
  }
3686
- if (config.enableFilterList) {
3687
- this.initializeFilterList();
3688
- }
3689
3219
  this.rules = filterCMPs(this.rules, normalizedConfig);
3690
3220
  if (this.shouldPrehide) {
3691
3221
  if (document.documentElement) {
@@ -3709,8 +3239,6 @@ var AutoConsent = class {
3709
3239
  }
3710
3240
  this.updateState({ lifecycle: "initialized" });
3711
3241
  }
3712
- initializeFilterList() {
3713
- }
3714
3242
  get shouldPrehide() {
3715
3243
  return this.config.enablePrehide && !this.config.visualTest;
3716
3244
  }
@@ -3739,11 +3267,6 @@ var AutoConsent = class {
3739
3267
  parseDeclarativeRules(declarativeRules) {
3740
3268
  const perfEnabled = __privateGet(this, _config)?.performanceLoggingEnabled;
3741
3269
  perfEnabled && performance.mark("parseDeclarativeRulesStart");
3742
- if (declarativeRules.consentomatic) {
3743
- for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
3744
- this.addConsentomaticCMP(name, rule);
3745
- }
3746
- }
3747
3270
  if (declarativeRules.autoconsent) {
3748
3271
  declarativeRules.autoconsent.forEach((ruleset) => {
3749
3272
  this.addDeclarativeCMP(ruleset);
@@ -3765,9 +3288,6 @@ var AutoConsent = class {
3765
3288
  this.rules.push(new AutoConsentCMP(ruleset, this));
3766
3289
  }
3767
3290
  }
3768
- addConsentomaticCMP(name, config) {
3769
- this.rules.push(new ConsentOMaticCMP(`com_${name}`, config));
3770
- }
3771
3291
  // start the detection process, possibly with a delay
3772
3292
  start() {
3773
3293
  scheduleWhenIdle(() => this._start());
@@ -3786,7 +3306,8 @@ var AutoConsent = class {
3786
3306
  if (this.shouldPrehide) {
3787
3307
  this.undoPrehide();
3788
3308
  }
3789
- return this.filterListFallback();
3309
+ this.updateState({ lifecycle: "nothingDetected" });
3310
+ return false;
3790
3311
  }
3791
3312
  this.updateState({ lifecycle: "cmpDetected" });
3792
3313
  const staticCmps = [];
@@ -3844,7 +3365,7 @@ var AutoConsent = class {
3844
3365
  }
3845
3366
  }
3846
3367
  });
3847
- const heuristicRules = isTop && this.config.enableHeuristicAction && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
3368
+ const heuristicRules = isTop && this.config.heuristicMode !== "off" && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
3848
3369
  const rulesPriorityStages = [
3849
3370
  ["site-specific", siteSpecificRules],
3850
3371
  ["generic", genericRules],
@@ -3952,9 +3473,6 @@ var AutoConsent = class {
3952
3473
  if (this.shouldPrehide && !this.state.prehideOn) {
3953
3474
  this.prehideElements();
3954
3475
  }
3955
- if (this.state.cosmeticFiltersOn) {
3956
- this.undoCosmetics();
3957
- }
3958
3476
  this.foundCmp = cmp;
3959
3477
  if (this.config.autoAction === "optOut") {
3960
3478
  return await this.doOptOut();
@@ -4118,25 +3636,6 @@ var AutoConsent = class {
4118
3636
  this.updateState({ prehideOn: false });
4119
3637
  this.domActions.undoPrehide();
4120
3638
  }
4121
- undoCosmetics() {
4122
- }
4123
- reportFilterlist() {
4124
- this.sendContentMessage({
4125
- type: "cmpDetected",
4126
- url: location.href,
4127
- cmp: "filterList"
4128
- });
4129
- this.sendContentMessage({
4130
- type: "popupFound",
4131
- cmp: "filterList",
4132
- url: location.href
4133
- });
4134
- this.updateState({ filterListReported: true });
4135
- }
4136
- filterListFallback() {
4137
- this.updateState({ lifecycle: "nothingDetected" });
4138
- return false;
4139
- }
4140
3639
  updateState(change) {
4141
3640
  Object.assign(this.state, change);
4142
3641
  this.sendContentMessage({