@duckduckgo/autoconsent 16.27.0 → 16.28.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/AGENTS.md +1 -1
- package/CHANGELOG.md +21 -0
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +26 -1
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/rule-index.json +1 -1
- package/dist/addon-firefox/rules.json +1 -1
- package/dist/addon-mv3/compact-rules.json +1 -1
- package/dist/addon-mv3/content.bundle.js +26 -1
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/rule-index.json +1 -1
- package/dist/addon-mv3/rules.json +1 -1
- package/dist/autoconsent.cjs.js +26 -1
- package/dist/autoconsent.esm.js +26 -1
- package/dist/autoconsent.playwright.js +26 -1
- package/dist/autoconsent.standalone.js +27 -2
- package/dist/types/cmps/base.d.ts +1 -0
- package/dist/types/dom-actions.d.ts +1 -0
- package/dist/types/rules.d.ts +6 -2
- package/dist/types/utils.d.ts +1 -0
- package/docs/rule-syntax.md +14 -0
- package/lib/cmps/base.ts +7 -0
- package/lib/dom-actions.ts +7 -1
- package/lib/rules.ts +9 -2
- package/lib/utils.ts +16 -0
- package/package.json +1 -1
- package/rules/autoconsent/amazon-pay.json +13 -0
- package/rules/autoconsent/bbva.json +12 -0
- package/rules/autoconsent/deliveroo.json +15 -0
- package/rules/autoconsent/ebay.json +34 -0
- package/rules/autoconsent/theguardian.com.json +13 -3
- package/rules/autoconsent/wpconsent.json +30 -0
- package/rules/compact-rules.json +1 -1
- package/rules/rule-index.json +1 -1
- package/rules/rules.json +1 -1
- package/tests/amazon-pay.spec.ts +3 -0
- package/tests/bbva.spec.ts +4 -0
- package/tests/deliveroo.spec.ts +3 -0
- package/tests/wpconsent.spec.ts +5 -0
- package/tests-wtr/dom-actions/dom-actions.stylesheet.html +13 -0
- package/tests-wtr/dom-actions/dom-actions.stylesheet.ts +26 -0
- package/tests-wtr/utils/append-stylesheet-rule.html +11 -0
- package/tests-wtr/utils/append-stylesheet-rule.test.ts +29 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
// lib/rules.ts
|
|
4
|
-
var SUPPORTED_RULE_STEP_VERSION =
|
|
4
|
+
var SUPPORTED_RULE_STEP_VERSION = 3;
|
|
5
5
|
|
|
6
6
|
// lib/random.ts
|
|
7
7
|
function getRandomID() {
|
|
@@ -80,6 +80,20 @@
|
|
|
80
80
|
}
|
|
81
81
|
return false;
|
|
82
82
|
}
|
|
83
|
+
function appendStylesheetRule(styleEl, cssRule, marker) {
|
|
84
|
+
if (!(styleEl instanceof HTMLStyleElement) || cssRule.length === 0) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const markerComment = marker ? `/* autoconsent:${marker} */` : "";
|
|
88
|
+
if (markerComment && styleEl.innerText.includes(markerComment)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
if (!markerComment && styleEl.innerText.includes(cssRule.trim())) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
styleEl.innerText += `${markerComment}${markerComment ? " " : ""}${cssRule} `;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
83
97
|
async function waitFor(predicate, maxTimes, interval) {
|
|
84
98
|
const result = await predicate();
|
|
85
99
|
if (!result && maxTimes > 0) {
|
|
@@ -1461,6 +1475,9 @@
|
|
|
1461
1475
|
hide(selector, method) {
|
|
1462
1476
|
return this.autoconsent.domActions.hide(selector, method);
|
|
1463
1477
|
}
|
|
1478
|
+
stylesheet(cssRule, stylesheetId) {
|
|
1479
|
+
return this.autoconsent.domActions.stylesheet(cssRule, stylesheetId);
|
|
1480
|
+
}
|
|
1464
1481
|
removeClass(selector, className) {
|
|
1465
1482
|
return this.autoconsent.domActions.removeClass(selector, className);
|
|
1466
1483
|
}
|
|
@@ -1582,6 +1599,9 @@
|
|
|
1582
1599
|
if (rule.hide) {
|
|
1583
1600
|
results.push(this.hide(rule.hide, rule.method));
|
|
1584
1601
|
}
|
|
1602
|
+
if (rule.stylesheet !== void 0) {
|
|
1603
|
+
results.push(this.stylesheet(rule.stylesheet, rule.stylesheetId));
|
|
1604
|
+
}
|
|
1585
1605
|
if (rule.removeClass !== void 0) {
|
|
1586
1606
|
results.push(rule.selector ? this.removeClass(rule.selector, rule.removeClass) : false);
|
|
1587
1607
|
}
|
|
@@ -2608,6 +2628,11 @@
|
|
|
2608
2628
|
const styleEl = getStyleElement();
|
|
2609
2629
|
return hideElements(styleEl, selector, method);
|
|
2610
2630
|
}
|
|
2631
|
+
stylesheet(cssRule, stylesheetId) {
|
|
2632
|
+
this.autoconsentInstance.config.logs.rulesteps && console.log("[stylesheet]", cssRule, stylesheetId);
|
|
2633
|
+
const styleEl = getStyleElement();
|
|
2634
|
+
return appendStylesheetRule(styleEl, cssRule, stylesheetId);
|
|
2635
|
+
}
|
|
2611
2636
|
removeClass(selector, className) {
|
|
2612
2637
|
const elements = this.elementSelector(selector);
|
|
2613
2638
|
this.autoconsentInstance.config.logs.rulesteps && console.log("[removeClass]", selector, className, elements);
|