@duckduckgo/autoconsent 16.26.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 +45 -0
- package/dist/addon-firefox/compact-rules.json +1 -1
- package/dist/addon-firefox/content.bundle.js +28 -3
- 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 +28 -3
- 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 +28 -3
- package/dist/autoconsent.esm.js +28 -3
- package/dist/autoconsent.playwright.js +28 -3
- package/dist/autoconsent.standalone.js +29 -4
- 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/heuristic-patterns.ts +2 -2
- 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/complianz-opt-out.json +6 -0
- package/rules/autoconsent/deliveroo.json +15 -0
- package/rules/autoconsent/ebay.json +34 -0
- package/rules/autoconsent/gemini-google-com.json +9 -0
- package/rules/autoconsent/justwatch-com.json +1 -1
- package/rules/autoconsent/kingrecords-co-jp.json +21 -0
- package/rules/autoconsent/paypal-us.json +4 -3
- package/rules/autoconsent/pornpics-de.json +1 -1
- package/rules/autoconsent/rule34-xxx.json +12 -0
- package/rules/autoconsent/sex.com.json +45 -0
- package/rules/autoconsent/theguardian.com.json +13 -3
- package/rules/autoconsent/twitch.json +27 -12
- package/rules/autoconsent/wpconsent.json +30 -0
- package/rules/autoconsent/xhamster-eu.json +3 -1
- 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/complianz-opt-out.spec.ts +5 -0
- package/tests/deliveroo.spec.ts +3 -0
- package/tests/gemini-google-com.spec.ts +5 -0
- package/tests/justwatch-com.spec.ts +1 -1
- package/tests/kingrecords-co-jp.spec.ts +3 -0
- package/tests/paypal-us.spec.ts +4 -0
- package/tests/pornpics-de.spec.ts +1 -1
- package/tests/rule34-xxx.spec.ts +6 -0
- package/tests/sex.com.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/heuristics/heuristics-utils.test.ts +6 -0
- package/tests-wtr/utils/append-stylesheet-rule.html +11 -0
- package/tests-wtr/utils/append-stylesheet-rule.test.ts +29 -0
package/dist/autoconsent.cjs.js
CHANGED
|
@@ -37,7 +37,7 @@ __export(web_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(web_exports);
|
|
38
38
|
|
|
39
39
|
// lib/rules.ts
|
|
40
|
-
var SUPPORTED_RULE_STEP_VERSION =
|
|
40
|
+
var SUPPORTED_RULE_STEP_VERSION = 3;
|
|
41
41
|
|
|
42
42
|
// lib/random.ts
|
|
43
43
|
function getRandomID() {
|
|
@@ -116,6 +116,20 @@ function hideElements(styleEl, selector, method = "display") {
|
|
|
116
116
|
}
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
|
+
function appendStylesheetRule(styleEl, cssRule, marker) {
|
|
120
|
+
if (!(styleEl instanceof HTMLStyleElement) || cssRule.length === 0) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const markerComment = marker ? `/* autoconsent:${marker} */` : "";
|
|
124
|
+
if (markerComment && styleEl.innerText.includes(markerComment)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
if (!markerComment && styleEl.innerText.includes(cssRule.trim())) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
styleEl.innerText += `${markerComment}${markerComment ? " " : ""}${cssRule} `;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
119
133
|
async function waitFor(predicate, maxTimes, interval) {
|
|
120
134
|
const result = await predicate();
|
|
121
135
|
if (!result && maxTimes > 0) {
|
|
@@ -581,8 +595,8 @@ var REJECT_PATTERNS_ENGLISH = [
|
|
|
581
595
|
// "reject non-essential cookies", "reject unnecessary cookies", "reject all but necessary", "reject all and close"
|
|
582
596
|
// note that "reject and subscribe" and "reject and pay" are excluded via BUTTON_NEVER_MATCH_PATTERNS
|
|
583
597
|
/^\s*(no,?\s*)?(i\s+)?(reject|deny|refuse|decline|disable)\s*(all)?\s*(but|except)?\s*(non[- ]?essential|un(necessary|required)|optional|additional|targeting|analytics|marketing|non[- ]?necessary|extra|tracking|advertising|necessary|essential)?\s*(cookies)?\s*(and\s+close)?\s*$/is,
|
|
584
|
-
// e.g. "i do not accept", "do not accept cookies"
|
|
585
|
-
/^\s*(i\s+)?do\s+not\s+accept\s*(cookies)?\s*$/is,
|
|
598
|
+
// e.g. "i do not accept", "do not accept cookies", "i do not accept the use of cookies"
|
|
599
|
+
/^\s*(no,?\s*)?(i\s+)?do\s+not\s+accept\s*(the\s+use\s+of\s+)?(any\s+)?(cookies)?\s*$/is,
|
|
586
600
|
// e.g. "continue without accepting", "continue without agreeing", "continue without agreeing →"
|
|
587
601
|
/^\s*(continue|proceed|continue\s+browsing)\s+without\s+(accepting|agreeing|consent|cookies|tracking)(\s*→)?\s*$/is,
|
|
588
602
|
// essential/necessary/functional-only, e.g. "essential cookies only", "accept only essential cookies",
|
|
@@ -1497,6 +1511,9 @@ var AutoConsentCMPBase = class {
|
|
|
1497
1511
|
hide(selector, method) {
|
|
1498
1512
|
return this.autoconsent.domActions.hide(selector, method);
|
|
1499
1513
|
}
|
|
1514
|
+
stylesheet(cssRule, stylesheetId) {
|
|
1515
|
+
return this.autoconsent.domActions.stylesheet(cssRule, stylesheetId);
|
|
1516
|
+
}
|
|
1500
1517
|
removeClass(selector, className) {
|
|
1501
1518
|
return this.autoconsent.domActions.removeClass(selector, className);
|
|
1502
1519
|
}
|
|
@@ -1618,6 +1635,9 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
1618
1635
|
if (rule.hide) {
|
|
1619
1636
|
results.push(this.hide(rule.hide, rule.method));
|
|
1620
1637
|
}
|
|
1638
|
+
if (rule.stylesheet !== void 0) {
|
|
1639
|
+
results.push(this.stylesheet(rule.stylesheet, rule.stylesheetId));
|
|
1640
|
+
}
|
|
1621
1641
|
if (rule.removeClass !== void 0) {
|
|
1622
1642
|
results.push(rule.selector ? this.removeClass(rule.selector, rule.removeClass) : false);
|
|
1623
1643
|
}
|
|
@@ -2644,6 +2664,11 @@ var DomActions = class {
|
|
|
2644
2664
|
const styleEl = getStyleElement();
|
|
2645
2665
|
return hideElements(styleEl, selector, method);
|
|
2646
2666
|
}
|
|
2667
|
+
stylesheet(cssRule, stylesheetId) {
|
|
2668
|
+
this.autoconsentInstance.config.logs.rulesteps && console.log("[stylesheet]", cssRule, stylesheetId);
|
|
2669
|
+
const styleEl = getStyleElement();
|
|
2670
|
+
return appendStylesheetRule(styleEl, cssRule, stylesheetId);
|
|
2671
|
+
}
|
|
2647
2672
|
removeClass(selector, className) {
|
|
2648
2673
|
const elements = this.elementSelector(selector);
|
|
2649
2674
|
this.autoconsentInstance.config.logs.rulesteps && console.log("[removeClass]", selector, className, elements);
|
package/dist/autoconsent.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
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
9
|
// lib/rules.ts
|
|
10
|
-
var SUPPORTED_RULE_STEP_VERSION =
|
|
10
|
+
var SUPPORTED_RULE_STEP_VERSION = 3;
|
|
11
11
|
|
|
12
12
|
// lib/random.ts
|
|
13
13
|
function getRandomID() {
|
|
@@ -86,6 +86,20 @@ function hideElements(styleEl, selector, method = "display") {
|
|
|
86
86
|
}
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
|
+
function appendStylesheetRule(styleEl, cssRule, marker) {
|
|
90
|
+
if (!(styleEl instanceof HTMLStyleElement) || cssRule.length === 0) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const markerComment = marker ? `/* autoconsent:${marker} */` : "";
|
|
94
|
+
if (markerComment && styleEl.innerText.includes(markerComment)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
if (!markerComment && styleEl.innerText.includes(cssRule.trim())) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
styleEl.innerText += `${markerComment}${markerComment ? " " : ""}${cssRule} `;
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
89
103
|
async function waitFor(predicate, maxTimes, interval) {
|
|
90
104
|
const result = await predicate();
|
|
91
105
|
if (!result && maxTimes > 0) {
|
|
@@ -551,8 +565,8 @@ var REJECT_PATTERNS_ENGLISH = [
|
|
|
551
565
|
// "reject non-essential cookies", "reject unnecessary cookies", "reject all but necessary", "reject all and close"
|
|
552
566
|
// note that "reject and subscribe" and "reject and pay" are excluded via BUTTON_NEVER_MATCH_PATTERNS
|
|
553
567
|
/^\s*(no,?\s*)?(i\s+)?(reject|deny|refuse|decline|disable)\s*(all)?\s*(but|except)?\s*(non[- ]?essential|un(necessary|required)|optional|additional|targeting|analytics|marketing|non[- ]?necessary|extra|tracking|advertising|necessary|essential)?\s*(cookies)?\s*(and\s+close)?\s*$/is,
|
|
554
|
-
// e.g. "i do not accept", "do not accept cookies"
|
|
555
|
-
/^\s*(i\s+)?do\s+not\s+accept\s*(cookies)?\s*$/is,
|
|
568
|
+
// e.g. "i do not accept", "do not accept cookies", "i do not accept the use of cookies"
|
|
569
|
+
/^\s*(no,?\s*)?(i\s+)?do\s+not\s+accept\s*(the\s+use\s+of\s+)?(any\s+)?(cookies)?\s*$/is,
|
|
556
570
|
// e.g. "continue without accepting", "continue without agreeing", "continue without agreeing →"
|
|
557
571
|
/^\s*(continue|proceed|continue\s+browsing)\s+without\s+(accepting|agreeing|consent|cookies|tracking)(\s*→)?\s*$/is,
|
|
558
572
|
// essential/necessary/functional-only, e.g. "essential cookies only", "accept only essential cookies",
|
|
@@ -1467,6 +1481,9 @@ var AutoConsentCMPBase = class {
|
|
|
1467
1481
|
hide(selector, method) {
|
|
1468
1482
|
return this.autoconsent.domActions.hide(selector, method);
|
|
1469
1483
|
}
|
|
1484
|
+
stylesheet(cssRule, stylesheetId) {
|
|
1485
|
+
return this.autoconsent.domActions.stylesheet(cssRule, stylesheetId);
|
|
1486
|
+
}
|
|
1470
1487
|
removeClass(selector, className) {
|
|
1471
1488
|
return this.autoconsent.domActions.removeClass(selector, className);
|
|
1472
1489
|
}
|
|
@@ -1588,6 +1605,9 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
1588
1605
|
if (rule.hide) {
|
|
1589
1606
|
results.push(this.hide(rule.hide, rule.method));
|
|
1590
1607
|
}
|
|
1608
|
+
if (rule.stylesheet !== void 0) {
|
|
1609
|
+
results.push(this.stylesheet(rule.stylesheet, rule.stylesheetId));
|
|
1610
|
+
}
|
|
1591
1611
|
if (rule.removeClass !== void 0) {
|
|
1592
1612
|
results.push(rule.selector ? this.removeClass(rule.selector, rule.removeClass) : false);
|
|
1593
1613
|
}
|
|
@@ -2614,6 +2634,11 @@ var DomActions = class {
|
|
|
2614
2634
|
const styleEl = getStyleElement();
|
|
2615
2635
|
return hideElements(styleEl, selector, method);
|
|
2616
2636
|
}
|
|
2637
|
+
stylesheet(cssRule, stylesheetId) {
|
|
2638
|
+
this.autoconsentInstance.config.logs.rulesteps && console.log("[stylesheet]", cssRule, stylesheetId);
|
|
2639
|
+
const styleEl = getStyleElement();
|
|
2640
|
+
return appendStylesheetRule(styleEl, cssRule, stylesheetId);
|
|
2641
|
+
}
|
|
2617
2642
|
removeClass(selector, className) {
|
|
2618
2643
|
const elements = this.elementSelector(selector);
|
|
2619
2644
|
this.autoconsentInstance.config.logs.rulesteps && console.log("[removeClass]", selector, className, elements);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
10
10
|
|
|
11
11
|
// lib/rules.ts
|
|
12
|
-
var SUPPORTED_RULE_STEP_VERSION =
|
|
12
|
+
var SUPPORTED_RULE_STEP_VERSION = 3;
|
|
13
13
|
|
|
14
14
|
// lib/random.ts
|
|
15
15
|
function getRandomID() {
|
|
@@ -88,6 +88,20 @@
|
|
|
88
88
|
}
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
|
+
function appendStylesheetRule(styleEl, cssRule, marker) {
|
|
92
|
+
if (!(styleEl instanceof HTMLStyleElement) || cssRule.length === 0) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const markerComment = marker ? `/* autoconsent:${marker} */` : "";
|
|
96
|
+
if (markerComment && styleEl.innerText.includes(markerComment)) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (!markerComment && styleEl.innerText.includes(cssRule.trim())) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
styleEl.innerText += `${markerComment}${markerComment ? " " : ""}${cssRule} `;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
91
105
|
async function waitFor(predicate, maxTimes, interval) {
|
|
92
106
|
const result = await predicate();
|
|
93
107
|
if (!result && maxTimes > 0) {
|
|
@@ -553,8 +567,8 @@
|
|
|
553
567
|
// "reject non-essential cookies", "reject unnecessary cookies", "reject all but necessary", "reject all and close"
|
|
554
568
|
// note that "reject and subscribe" and "reject and pay" are excluded via BUTTON_NEVER_MATCH_PATTERNS
|
|
555
569
|
/^\s*(no,?\s*)?(i\s+)?(reject|deny|refuse|decline|disable)\s*(all)?\s*(but|except)?\s*(non[- ]?essential|un(necessary|required)|optional|additional|targeting|analytics|marketing|non[- ]?necessary|extra|tracking|advertising|necessary|essential)?\s*(cookies)?\s*(and\s+close)?\s*$/is,
|
|
556
|
-
// e.g. "i do not accept", "do not accept cookies"
|
|
557
|
-
/^\s*(i\s+)?do\s+not\s+accept\s*(cookies)?\s*$/is,
|
|
570
|
+
// e.g. "i do not accept", "do not accept cookies", "i do not accept the use of cookies"
|
|
571
|
+
/^\s*(no,?\s*)?(i\s+)?do\s+not\s+accept\s*(the\s+use\s+of\s+)?(any\s+)?(cookies)?\s*$/is,
|
|
558
572
|
// e.g. "continue without accepting", "continue without agreeing", "continue without agreeing →"
|
|
559
573
|
/^\s*(continue|proceed|continue\s+browsing)\s+without\s+(accepting|agreeing|consent|cookies|tracking)(\s*→)?\s*$/is,
|
|
560
574
|
// essential/necessary/functional-only, e.g. "essential cookies only", "accept only essential cookies",
|
|
@@ -1469,6 +1483,9 @@
|
|
|
1469
1483
|
hide(selector, method) {
|
|
1470
1484
|
return this.autoconsent.domActions.hide(selector, method);
|
|
1471
1485
|
}
|
|
1486
|
+
stylesheet(cssRule, stylesheetId) {
|
|
1487
|
+
return this.autoconsent.domActions.stylesheet(cssRule, stylesheetId);
|
|
1488
|
+
}
|
|
1472
1489
|
removeClass(selector, className) {
|
|
1473
1490
|
return this.autoconsent.domActions.removeClass(selector, className);
|
|
1474
1491
|
}
|
|
@@ -1590,6 +1607,9 @@
|
|
|
1590
1607
|
if (rule.hide) {
|
|
1591
1608
|
results.push(this.hide(rule.hide, rule.method));
|
|
1592
1609
|
}
|
|
1610
|
+
if (rule.stylesheet !== void 0) {
|
|
1611
|
+
results.push(this.stylesheet(rule.stylesheet, rule.stylesheetId));
|
|
1612
|
+
}
|
|
1593
1613
|
if (rule.removeClass !== void 0) {
|
|
1594
1614
|
results.push(rule.selector ? this.removeClass(rule.selector, rule.removeClass) : false);
|
|
1595
1615
|
}
|
|
@@ -2616,6 +2636,11 @@
|
|
|
2616
2636
|
const styleEl = getStyleElement();
|
|
2617
2637
|
return hideElements(styleEl, selector, method);
|
|
2618
2638
|
}
|
|
2639
|
+
stylesheet(cssRule, stylesheetId) {
|
|
2640
|
+
this.autoconsentInstance.config.logs.rulesteps && console.log("[stylesheet]", cssRule, stylesheetId);
|
|
2641
|
+
const styleEl = getStyleElement();
|
|
2642
|
+
return appendStylesheetRule(styleEl, cssRule, stylesheetId);
|
|
2643
|
+
}
|
|
2619
2644
|
removeClass(selector, className) {
|
|
2620
2645
|
const elements = this.elementSelector(selector);
|
|
2621
2646
|
this.autoconsentInstance.config.logs.rulesteps && console.log("[removeClass]", selector, className, elements);
|