@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.
- package/.github/dependabot.yml +0 -3
- package/.github/workflows/release.yml +0 -4
- package/AGENTS.md +3 -3
- package/CHANGELOG.md +32 -0
- package/build.sh +3 -2
- package/dist/addon-firefox/background.bundle.js +8 -24
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +184 -686
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/popup.bundle.js +196 -25
- package/dist/addon-firefox/popup.html +98 -5
- package/dist/addon-firefox/rule-index.json +1 -0
- package/dist/addon-firefox/rules.json +1 -1
- package/dist/addon-mv3/background.bundle.js +8 -24
- package/dist/addon-mv3/compact-rules.json +1 -1
- package/dist/addon-mv3/content.bundle.js +184 -686
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +196 -25
- package/dist/addon-mv3/popup.html +98 -5
- package/dist/addon-mv3/rule-index.json +1 -0
- package/dist/addon-mv3/rules.json +1 -1
- package/dist/autoconsent.cjs.js +184 -685
- package/dist/autoconsent.esm.js +184 -685
- package/dist/autoconsent.playwright.js +185 -689
- package/dist/autoconsent.standalone.js +3625 -0
- package/dist/types/cmps/base.d.ts +3 -3
- package/dist/types/cmps/trustarc-top.d.ts +1 -1
- package/dist/types/eval-handler.d.ts +3 -3
- package/dist/types/heuristics.d.ts +2 -2
- package/dist/types/types.d.ts +10 -23
- package/dist/types/web.d.ts +0 -9
- package/docs/api.md +1 -8
- package/docs/puppeteer.md +1 -3
- package/docs/rule-syntax.md +0 -17
- package/eslint.config.mjs +1 -1
- package/lib/cmps/base.ts +5 -6
- package/lib/cmps/conversant.ts +7 -4
- package/lib/cmps/trustarc-top.ts +1 -1
- package/lib/cmps/uniconsent.ts +4 -4
- package/lib/eval-handler.ts +6 -3
- package/lib/heuristics.ts +15 -15
- package/lib/types.ts +9 -21
- package/lib/utils.ts +13 -9
- package/lib/web.ts +3 -53
- package/package.json +4 -17
- package/playwright/content.ts +1 -2
- package/readme.md +3 -6
- package/rules/autoconsent/dreamlab-cmp.json +13 -0
- package/rules/build.ts +4 -23
- package/rules/compact-rules.json +1 -1
- package/rules/rule-index-builder.ts +58 -0
- package/rules/rule-index.json +1 -0
- package/rules/rules.json +1 -1
- package/standalone/content.ts +101 -0
- package/tests/dreamlab-cmp.spec.ts +3 -0
- package/tests/quantcast.spec.ts +0 -6
- package/tests-wtr/heuristics/get-actionable-popups.ts +13 -13
- package/tests-wtr/heuristics/heuristic-cmp.ts +32 -33
- package/tests-wtr/lifecycle/find-cmp.ts +5 -8
- package/tests-wtr/web/do-opt-in.test.ts +0 -1
- package/tests-wtr/web/do-opt-out.test.ts +0 -1
- package/tests-wtr/web/do-self-test.test.ts +0 -1
- package/tests-wtr/web/filter-cmps.test.ts +0 -1
- package/tests-wtr/web/receive-message-callback.test.ts +1 -2
- package/tests-wtr/web/update-state.test.ts +1 -3
- package/tsconfig.build.json +1 -1
- package/.github/workflows/update-filterlist.yml +0 -42
- package/dist/autoconsent.extra.cjs.js +0 -15709
- package/dist/autoconsent.extra.esm.js +0 -15641
- package/dist/types/cmps/consentomatic.d.ts +0 -34
- package/dist/types/consentomatic/index.d.ts +0 -2
- package/dist/types/consentomatic/tools.d.ts +0 -10
- package/dist/types/filterlist-engine.d.ts +0 -2
- package/dist/types/filterlist-utils.d.ts +0 -4
- package/dist/types/web-extra.d.ts +0 -11
- package/lib/cmps/consentomatic.ts +0 -97
- package/lib/consentomatic/index.ts +0 -252
- package/lib/consentomatic/tools.ts +0 -199
- package/lib/filterlist-engine.ts +0 -5
- package/lib/filterlist-utils.ts +0 -45
- package/lib/web-extra.ts +0 -116
- package/rules/consentomatic.json +0 -1
- package/rules/filterlist.txt +0 -18440
- package/rules/filterlists/overrides.txt +0 -4
- package/scripts/compile-filterlist.mjs +0 -63
- package/scripts/fetch-easylist.sh +0 -25
- package/scripts/rebuild-filterlist.mjs +0 -216
- package/tests/oil.spec.ts +0 -7
- package/tests/springer.spec.ts +0 -7
- package/tests/wordpressgdpr.spec.ts +0 -6
|
@@ -1,412 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
// lib/
|
|
4
|
-
var
|
|
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() {
|
|
@@ -434,6 +29,9 @@
|
|
|
434
29
|
sendContentMessage: null
|
|
435
30
|
};
|
|
436
31
|
function requestEval(code, snippetId) {
|
|
32
|
+
if (!evalState.sendContentMessage) {
|
|
33
|
+
return Promise.reject(new Error("AutoConsent is not initialized yet"));
|
|
34
|
+
}
|
|
437
35
|
const id = getRandomID();
|
|
438
36
|
evalState.sendContentMessage({
|
|
439
37
|
type: "eval",
|
|
@@ -456,6 +54,155 @@
|
|
|
456
54
|
}
|
|
457
55
|
}
|
|
458
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
|
+
|
|
459
206
|
// lib/eval-snippets.ts
|
|
460
207
|
var snippets = {
|
|
461
208
|
// code-based rules
|
|
@@ -633,154 +380,6 @@
|
|
|
633
380
|
return `(${snippetStr})()`;
|
|
634
381
|
}
|
|
635
382
|
|
|
636
|
-
// lib/utils.ts
|
|
637
|
-
function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
|
|
638
|
-
const styleSelector = `style#${styleOverrideElementId}`;
|
|
639
|
-
const existingElement = document.querySelector(styleSelector);
|
|
640
|
-
if (existingElement && existingElement instanceof HTMLStyleElement) {
|
|
641
|
-
return existingElement;
|
|
642
|
-
} else {
|
|
643
|
-
const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
|
644
|
-
const css = document.createElement("style");
|
|
645
|
-
css.id = styleOverrideElementId;
|
|
646
|
-
parent.appendChild(css);
|
|
647
|
-
return css;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
function getHidingStyle(method) {
|
|
651
|
-
const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
|
|
652
|
-
return `${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important;`;
|
|
653
|
-
}
|
|
654
|
-
function hideElements(styleEl, selector, method = "display") {
|
|
655
|
-
const rule = `${selector} { ${getHidingStyle(method)} } `;
|
|
656
|
-
if (styleEl instanceof HTMLStyleElement) {
|
|
657
|
-
styleEl.innerText += rule;
|
|
658
|
-
return selector.length > 0;
|
|
659
|
-
}
|
|
660
|
-
return false;
|
|
661
|
-
}
|
|
662
|
-
async function waitFor(predicate, maxTimes, interval) {
|
|
663
|
-
const result = await predicate();
|
|
664
|
-
if (!result && maxTimes > 0) {
|
|
665
|
-
return new Promise((resolve) => {
|
|
666
|
-
setTimeout(async () => {
|
|
667
|
-
resolve(waitFor(predicate, maxTimes - 1, interval));
|
|
668
|
-
}, interval);
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
return Promise.resolve(result);
|
|
672
|
-
}
|
|
673
|
-
function isElementVisible(elem) {
|
|
674
|
-
if (!elem) {
|
|
675
|
-
return false;
|
|
676
|
-
}
|
|
677
|
-
if (elem.offsetParent !== null) {
|
|
678
|
-
return true;
|
|
679
|
-
} else {
|
|
680
|
-
const css = window.getComputedStyle(elem);
|
|
681
|
-
if (css.position === "fixed" && css.display !== "none") {
|
|
682
|
-
return true;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return false;
|
|
686
|
-
}
|
|
687
|
-
function copyObject(data) {
|
|
688
|
-
if (globalThis.structuredClone) {
|
|
689
|
-
return structuredClone(data);
|
|
690
|
-
}
|
|
691
|
-
return JSON.parse(JSON.stringify(data));
|
|
692
|
-
}
|
|
693
|
-
function normalizeConfig(providedConfig) {
|
|
694
|
-
const defaultConfig = {
|
|
695
|
-
enabled: true,
|
|
696
|
-
autoAction: "optOut",
|
|
697
|
-
// if falsy, the extension will wait for an explicit user signal before opting in/out
|
|
698
|
-
disabledCmps: [],
|
|
699
|
-
enablePrehide: true,
|
|
700
|
-
enableCosmeticRules: true,
|
|
701
|
-
enableGeneratedRules: true,
|
|
702
|
-
enableHeuristicDetection: false,
|
|
703
|
-
enableHeuristicAction: false,
|
|
704
|
-
enablePopupMutationObserver: false,
|
|
705
|
-
detectRetries: 20,
|
|
706
|
-
isMainWorld: false,
|
|
707
|
-
prehideTimeout: 2e3,
|
|
708
|
-
enableFilterList: false,
|
|
709
|
-
visualTest: false,
|
|
710
|
-
logs: {
|
|
711
|
-
lifecycle: false,
|
|
712
|
-
rulesteps: false,
|
|
713
|
-
detectionsteps: false,
|
|
714
|
-
evals: false,
|
|
715
|
-
errors: true,
|
|
716
|
-
messages: false,
|
|
717
|
-
waits: false
|
|
718
|
-
},
|
|
719
|
-
performanceLoggingEnabled: false,
|
|
720
|
-
heuristicPopupSearchTimeout: 100,
|
|
721
|
-
heuristicMode: PopupHandlingModes.Reject
|
|
722
|
-
};
|
|
723
|
-
const updatedConfig = copyObject(defaultConfig);
|
|
724
|
-
for (const key of Object.keys(defaultConfig)) {
|
|
725
|
-
if (typeof providedConfig[key] !== "undefined") {
|
|
726
|
-
updatedConfig[key] = providedConfig[key];
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
return updatedConfig;
|
|
730
|
-
}
|
|
731
|
-
function scheduleWhenIdle(callback, timeout = 500) {
|
|
732
|
-
if (globalThis.requestIdleCallback) {
|
|
733
|
-
requestIdleCallback(callback, { timeout });
|
|
734
|
-
} else {
|
|
735
|
-
setTimeout(callback, 0);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
function highlightNode(node) {
|
|
739
|
-
if (!node.style) return;
|
|
740
|
-
if (node.__oldStyles !== void 0) {
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
if (node.hasAttribute("style")) {
|
|
744
|
-
node.__oldStyles = node.style.cssText;
|
|
745
|
-
}
|
|
746
|
-
node.style.animation = "pulsate .5s infinite";
|
|
747
|
-
node.style.outline = "solid red";
|
|
748
|
-
let styleTag = document.querySelector("style#autoconsent-debug-styles");
|
|
749
|
-
if (!styleTag) {
|
|
750
|
-
styleTag = document.createElement("style");
|
|
751
|
-
styleTag.id = "autoconsent-debug-styles";
|
|
752
|
-
}
|
|
753
|
-
styleTag.textContent = `
|
|
754
|
-
@keyframes pulsate {
|
|
755
|
-
0% {
|
|
756
|
-
outline-width: 8px;
|
|
757
|
-
outline-offset: -4px;
|
|
758
|
-
}
|
|
759
|
-
50% {
|
|
760
|
-
outline-width: 4px;
|
|
761
|
-
outline-offset: -2px;
|
|
762
|
-
}
|
|
763
|
-
100% {
|
|
764
|
-
outline-width: 8px;
|
|
765
|
-
outline-offset: -4px;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
`;
|
|
769
|
-
document.head.appendChild(styleTag);
|
|
770
|
-
}
|
|
771
|
-
function unhighlightNode(node) {
|
|
772
|
-
if (!node.style || !node.hasAttribute("style")) return;
|
|
773
|
-
if (node.__oldStyles !== void 0) {
|
|
774
|
-
node.style.cssText = node.__oldStyles;
|
|
775
|
-
delete node.__oldStyles;
|
|
776
|
-
} else {
|
|
777
|
-
node.removeAttribute("style");
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
function isTopFrame() {
|
|
781
|
-
return window.top === window && (!globalThis.location.ancestorOrigins || globalThis.location.ancestorOrigins.length === 0);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
383
|
// lib/heuristic-patterns.ts
|
|
785
384
|
var DETECT_PATTERNS = [
|
|
786
385
|
/accept cookies/gi,
|
|
@@ -1539,15 +1138,19 @@
|
|
|
1539
1138
|
const patterns = [];
|
|
1540
1139
|
const snippets2 = [];
|
|
1541
1140
|
for (const p of detectPatterns) {
|
|
1542
|
-
const
|
|
1543
|
-
if (
|
|
1141
|
+
const matches = allText?.match(p);
|
|
1142
|
+
if (matches) {
|
|
1544
1143
|
patterns.push(p.toString());
|
|
1545
|
-
snippets2.push(...
|
|
1144
|
+
snippets2.push(...matches.map((m) => m.substring(0, 200)));
|
|
1546
1145
|
}
|
|
1547
1146
|
}
|
|
1548
1147
|
return { patterns, snippets: snippets2 };
|
|
1549
1148
|
}
|
|
1550
|
-
function getActionablePopups(mode =
|
|
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
|
+
}
|
|
1551
1154
|
const popups = getPotentialPopups(timeout);
|
|
1552
1155
|
const result = popups.reduce((acc, popup) => {
|
|
1553
1156
|
const popupText = popup.text?.trim();
|
|
@@ -1563,9 +1166,7 @@
|
|
|
1563
1166
|
}
|
|
1564
1167
|
return acc;
|
|
1565
1168
|
}, []);
|
|
1566
|
-
return result.filter(
|
|
1567
|
-
(popup) => popup.regexClassification !== void 0 && popup.regexClassification !== PopupHandlingModes.None && popup.regexClassification <= mode
|
|
1568
|
-
).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);
|
|
1569
1170
|
}
|
|
1570
1171
|
function classifyButtons(buttons) {
|
|
1571
1172
|
for (const button of buttons) {
|
|
@@ -1583,18 +1184,18 @@
|
|
|
1583
1184
|
{ reject: 0, settings: 0, accept: 0, acknowledge: 0 }
|
|
1584
1185
|
);
|
|
1585
1186
|
if (reject > 0) {
|
|
1586
|
-
return
|
|
1187
|
+
return "reject";
|
|
1587
1188
|
}
|
|
1588
1189
|
if (settings > 0) {
|
|
1589
|
-
return
|
|
1190
|
+
return "none";
|
|
1590
1191
|
}
|
|
1591
1192
|
if (acknowledge > 0) {
|
|
1592
|
-
return
|
|
1193
|
+
return "tier1";
|
|
1593
1194
|
}
|
|
1594
1195
|
if (accept > 0) {
|
|
1595
|
-
return accept === 1 ?
|
|
1196
|
+
return accept === 1 ? "tier2" : "none";
|
|
1596
1197
|
}
|
|
1597
|
-
return
|
|
1198
|
+
return "none";
|
|
1598
1199
|
}
|
|
1599
1200
|
function testButtonMatches(buttonText, matchPatterns, neverMatchPatterns) {
|
|
1600
1201
|
if (!buttonText) {
|
|
@@ -2075,7 +1676,7 @@
|
|
|
2075
1676
|
}
|
|
2076
1677
|
};
|
|
2077
1678
|
var AutoConsentHeuristicCMP = class extends AutoConsentCMPBase {
|
|
2078
|
-
constructor(autoconsentInstance, mode =
|
|
1679
|
+
constructor(autoconsentInstance, mode = "reject") {
|
|
2079
1680
|
super(autoconsentInstance);
|
|
2080
1681
|
this.popups = [];
|
|
2081
1682
|
this.name = "HEURISTIC";
|
|
@@ -2102,7 +1703,7 @@
|
|
|
2102
1703
|
this.autoconsent.config.performanceLoggingEnabled && performance.mark("heuristicDetectorEnd");
|
|
2103
1704
|
this.autoconsent.config.performanceLoggingEnabled && performance.measure("heuristicDetector", "heuristicDetectorStart", "heuristicDetectorEnd");
|
|
2104
1705
|
if (this.popups.length > 0) {
|
|
2105
|
-
this.name = `HEURISTIC
|
|
1706
|
+
this.name = `HEURISTIC-${this.popups[0].regexClassification?.toUpperCase()}`;
|
|
2106
1707
|
return Promise.resolve(true);
|
|
2107
1708
|
}
|
|
2108
1709
|
return Promise.resolve(false);
|
|
@@ -2120,7 +1721,7 @@
|
|
|
2120
1721
|
const popup = this.popups[0];
|
|
2121
1722
|
const level = popup.regexClassification;
|
|
2122
1723
|
const buttons = popup.buttons;
|
|
2123
|
-
const targetButtonType = level ===
|
|
1724
|
+
const targetButtonType = level === "reject" ? "reject" : level === "tier1" ? "acknowledge" : "accept";
|
|
2124
1725
|
return buttons.find((button) => button.regexClassification === targetButtonType);
|
|
2125
1726
|
}
|
|
2126
1727
|
optOut() {
|
|
@@ -2146,76 +1747,6 @@
|
|
|
2146
1747
|
}
|
|
2147
1748
|
};
|
|
2148
1749
|
|
|
2149
|
-
// lib/cmps/consentomatic.ts
|
|
2150
|
-
var ConsentOMaticCMP = class {
|
|
2151
|
-
constructor(name, config) {
|
|
2152
|
-
this.name = name;
|
|
2153
|
-
this.config = config;
|
|
2154
|
-
this.methods = /* @__PURE__ */ new Map();
|
|
2155
|
-
this.runContext = defaultRunContext;
|
|
2156
|
-
this.isCosmetic = false;
|
|
2157
|
-
config.methods.forEach((methodConfig) => {
|
|
2158
|
-
if (methodConfig.action) {
|
|
2159
|
-
this.methods.set(methodConfig.name, methodConfig.action);
|
|
2160
|
-
}
|
|
2161
|
-
});
|
|
2162
|
-
this.hasSelfTest = false;
|
|
2163
|
-
}
|
|
2164
|
-
get isIntermediate() {
|
|
2165
|
-
return false;
|
|
2166
|
-
}
|
|
2167
|
-
checkRunContext() {
|
|
2168
|
-
return true;
|
|
2169
|
-
}
|
|
2170
|
-
checkFrameContext(isTop) {
|
|
2171
|
-
return true;
|
|
2172
|
-
}
|
|
2173
|
-
hasMatchingUrlPattern() {
|
|
2174
|
-
return false;
|
|
2175
|
-
}
|
|
2176
|
-
async detectCmp() {
|
|
2177
|
-
const matchResults = this.config.detectors.map((detectorConfig) => matches(detectorConfig.presentMatcher));
|
|
2178
|
-
return matchResults.some((r) => !!r);
|
|
2179
|
-
}
|
|
2180
|
-
async detectPopup() {
|
|
2181
|
-
const matchResults = this.config.detectors.map((detectorConfig) => matches(detectorConfig.showingMatcher));
|
|
2182
|
-
return matchResults.some((r) => !!r);
|
|
2183
|
-
}
|
|
2184
|
-
async executeAction(method, param) {
|
|
2185
|
-
if (this.methods.has(method)) {
|
|
2186
|
-
return executeAction(this.methods.get(method), param);
|
|
2187
|
-
}
|
|
2188
|
-
return true;
|
|
2189
|
-
}
|
|
2190
|
-
async optOut() {
|
|
2191
|
-
await this.executeAction("HIDE_CMP");
|
|
2192
|
-
await this.executeAction("OPEN_OPTIONS");
|
|
2193
|
-
await this.executeAction("HIDE_CMP");
|
|
2194
|
-
await this.executeAction("DO_CONSENT", []);
|
|
2195
|
-
await this.executeAction("SAVE_CONSENT");
|
|
2196
|
-
return true;
|
|
2197
|
-
}
|
|
2198
|
-
async optIn() {
|
|
2199
|
-
await this.executeAction("HIDE_CMP");
|
|
2200
|
-
await this.executeAction("OPEN_OPTIONS");
|
|
2201
|
-
await this.executeAction("HIDE_CMP");
|
|
2202
|
-
await this.executeAction("DO_CONSENT", ["D", "A", "B", "E", "F", "X"]);
|
|
2203
|
-
await this.executeAction("SAVE_CONSENT");
|
|
2204
|
-
return true;
|
|
2205
|
-
}
|
|
2206
|
-
async openCmp() {
|
|
2207
|
-
await this.executeAction("HIDE_CMP");
|
|
2208
|
-
await this.executeAction("OPEN_OPTIONS");
|
|
2209
|
-
return true;
|
|
2210
|
-
}
|
|
2211
|
-
async test() {
|
|
2212
|
-
return true;
|
|
2213
|
-
}
|
|
2214
|
-
};
|
|
2215
|
-
|
|
2216
|
-
// lib/rules.ts
|
|
2217
|
-
var SUPPORTED_RULE_STEP_VERSION = 2;
|
|
2218
|
-
|
|
2219
1750
|
// lib/cmps/trustarc-top.ts
|
|
2220
1751
|
var cookieSettingsButton = "#truste-show-consent";
|
|
2221
1752
|
var shortcutOptOut = "#truste-consent-required";
|
|
@@ -2818,7 +2349,7 @@
|
|
|
2818
2349
|
async optOut() {
|
|
2819
2350
|
await this.waitForElement(".unic button", 1e3);
|
|
2820
2351
|
document.querySelectorAll(".unic button").forEach((button) => {
|
|
2821
|
-
const text = button.textContent;
|
|
2352
|
+
const text = button.textContent || "";
|
|
2822
2353
|
if (text.includes("Manage Options") || text.includes("Optionen verwalten")) {
|
|
2823
2354
|
button.click();
|
|
2824
2355
|
}
|
|
@@ -2831,7 +2362,7 @@
|
|
|
2831
2362
|
}
|
|
2832
2363
|
});
|
|
2833
2364
|
for (const b of document.querySelectorAll(".unic button")) {
|
|
2834
|
-
const text = b.textContent;
|
|
2365
|
+
const text = b.textContent || "";
|
|
2835
2366
|
for (const pattern of ["Confirm Choices", "Save Choices", "Auswahl speichern"]) {
|
|
2836
2367
|
if (text.includes(pattern)) {
|
|
2837
2368
|
b.click();
|
|
@@ -2888,6 +2419,9 @@
|
|
|
2888
2419
|
item.querySelector(".cmp-accordion-item-title").click();
|
|
2889
2420
|
await waitFor(() => !!item.querySelector(".cmp-accordion-item-content.cmp-active"), 10, 50);
|
|
2890
2421
|
const content = item.querySelector(".cmp-accordion-item-content.cmp-active");
|
|
2422
|
+
if (!content) {
|
|
2423
|
+
return false;
|
|
2424
|
+
}
|
|
2891
2425
|
content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((e) => e.click());
|
|
2892
2426
|
content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((e) => e.click());
|
|
2893
2427
|
}
|
|
@@ -3240,15 +2774,15 @@
|
|
|
3240
2774
|
}
|
|
3241
2775
|
querySelectorChain(selectors) {
|
|
3242
2776
|
let parent = document;
|
|
3243
|
-
let
|
|
2777
|
+
let matches = [];
|
|
3244
2778
|
for (const selector of selectors) {
|
|
3245
|
-
|
|
3246
|
-
if (
|
|
2779
|
+
matches = this.querySingleReplySelector(selector, parent);
|
|
2780
|
+
if (matches.length === 0) {
|
|
3247
2781
|
return [];
|
|
3248
2782
|
}
|
|
3249
|
-
parent =
|
|
2783
|
+
parent = matches[0];
|
|
3250
2784
|
}
|
|
3251
|
-
return
|
|
2785
|
+
return matches;
|
|
3252
2786
|
}
|
|
3253
2787
|
elementSelector(selector) {
|
|
3254
2788
|
if (typeof selector === "string") {
|
|
@@ -3393,8 +2927,6 @@
|
|
|
3393
2927
|
this.id = getRandomID();
|
|
3394
2928
|
this.rules = [];
|
|
3395
2929
|
this.state = {
|
|
3396
|
-
cosmeticFiltersOn: false,
|
|
3397
|
-
filterListReported: false,
|
|
3398
2930
|
lifecycle: "loading",
|
|
3399
2931
|
prehideOn: false,
|
|
3400
2932
|
findCmpAttempts: 0,
|
|
@@ -3445,9 +2977,6 @@
|
|
|
3445
2977
|
if (declarativeRules) {
|
|
3446
2978
|
this.parseDeclarativeRules(declarativeRules);
|
|
3447
2979
|
}
|
|
3448
|
-
if (config.enableFilterList) {
|
|
3449
|
-
this.initializeFilterList();
|
|
3450
|
-
}
|
|
3451
2980
|
this.rules = filterCMPs(this.rules, normalizedConfig);
|
|
3452
2981
|
if (this.shouldPrehide) {
|
|
3453
2982
|
if (document.documentElement) {
|
|
@@ -3471,8 +3000,6 @@
|
|
|
3471
3000
|
}
|
|
3472
3001
|
this.updateState({ lifecycle: "initialized" });
|
|
3473
3002
|
}
|
|
3474
|
-
initializeFilterList() {
|
|
3475
|
-
}
|
|
3476
3003
|
get shouldPrehide() {
|
|
3477
3004
|
return this.config.enablePrehide && !this.config.visualTest;
|
|
3478
3005
|
}
|
|
@@ -3501,11 +3028,6 @@
|
|
|
3501
3028
|
parseDeclarativeRules(declarativeRules) {
|
|
3502
3029
|
const perfEnabled = this.#config?.performanceLoggingEnabled;
|
|
3503
3030
|
perfEnabled && performance.mark("parseDeclarativeRulesStart");
|
|
3504
|
-
if (declarativeRules.consentomatic) {
|
|
3505
|
-
for (const [name, rule] of Object.entries(declarativeRules.consentomatic)) {
|
|
3506
|
-
this.addConsentomaticCMP(name, rule);
|
|
3507
|
-
}
|
|
3508
|
-
}
|
|
3509
3031
|
if (declarativeRules.autoconsent) {
|
|
3510
3032
|
declarativeRules.autoconsent.forEach((ruleset) => {
|
|
3511
3033
|
this.addDeclarativeCMP(ruleset);
|
|
@@ -3527,9 +3049,6 @@
|
|
|
3527
3049
|
this.rules.push(new AutoConsentCMP(ruleset, this));
|
|
3528
3050
|
}
|
|
3529
3051
|
}
|
|
3530
|
-
addConsentomaticCMP(name, config) {
|
|
3531
|
-
this.rules.push(new ConsentOMaticCMP(`com_${name}`, config));
|
|
3532
|
-
}
|
|
3533
3052
|
// start the detection process, possibly with a delay
|
|
3534
3053
|
start() {
|
|
3535
3054
|
scheduleWhenIdle(() => this._start());
|
|
@@ -3548,7 +3067,8 @@
|
|
|
3548
3067
|
if (this.shouldPrehide) {
|
|
3549
3068
|
this.undoPrehide();
|
|
3550
3069
|
}
|
|
3551
|
-
|
|
3070
|
+
this.updateState({ lifecycle: "nothingDetected" });
|
|
3071
|
+
return false;
|
|
3552
3072
|
}
|
|
3553
3073
|
this.updateState({ lifecycle: "cmpDetected" });
|
|
3554
3074
|
const staticCmps = [];
|
|
@@ -3606,7 +3126,7 @@
|
|
|
3606
3126
|
}
|
|
3607
3127
|
}
|
|
3608
3128
|
});
|
|
3609
|
-
const heuristicRules = isTop && this.config.
|
|
3129
|
+
const heuristicRules = isTop && this.config.heuristicMode !== "off" && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
|
|
3610
3130
|
const rulesPriorityStages = [
|
|
3611
3131
|
["site-specific", siteSpecificRules],
|
|
3612
3132
|
["generic", genericRules],
|
|
@@ -3714,9 +3234,6 @@
|
|
|
3714
3234
|
if (this.shouldPrehide && !this.state.prehideOn) {
|
|
3715
3235
|
this.prehideElements();
|
|
3716
3236
|
}
|
|
3717
|
-
if (this.state.cosmeticFiltersOn) {
|
|
3718
|
-
this.undoCosmetics();
|
|
3719
|
-
}
|
|
3720
3237
|
this.foundCmp = cmp;
|
|
3721
3238
|
if (this.config.autoAction === "optOut") {
|
|
3722
3239
|
return await this.doOptOut();
|
|
@@ -3880,25 +3397,6 @@
|
|
|
3880
3397
|
this.updateState({ prehideOn: false });
|
|
3881
3398
|
this.domActions.undoPrehide();
|
|
3882
3399
|
}
|
|
3883
|
-
undoCosmetics() {
|
|
3884
|
-
}
|
|
3885
|
-
reportFilterlist() {
|
|
3886
|
-
this.sendContentMessage({
|
|
3887
|
-
type: "cmpDetected",
|
|
3888
|
-
url: location.href,
|
|
3889
|
-
cmp: "filterList"
|
|
3890
|
-
});
|
|
3891
|
-
this.sendContentMessage({
|
|
3892
|
-
type: "popupFound",
|
|
3893
|
-
cmp: "filterList",
|
|
3894
|
-
url: location.href
|
|
3895
|
-
});
|
|
3896
|
-
this.updateState({ filterListReported: true });
|
|
3897
|
-
}
|
|
3898
|
-
filterListFallback() {
|
|
3899
|
-
this.updateState({ lifecycle: "nothingDetected" });
|
|
3900
|
-
return false;
|
|
3901
|
-
}
|
|
3902
3400
|
updateState(change) {
|
|
3903
3401
|
Object.assign(this.state, change);
|
|
3904
3402
|
this.sendContentMessage({
|