@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.
Files changed (63) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +45 -0
  3. package/dist/addon-firefox/compact-rules.json +1 -1
  4. package/dist/addon-firefox/content.bundle.js +28 -3
  5. package/dist/addon-firefox/manifest.json +1 -1
  6. package/dist/addon-firefox/rule-index.json +1 -1
  7. package/dist/addon-firefox/rules.json +1 -1
  8. package/dist/addon-mv3/compact-rules.json +1 -1
  9. package/dist/addon-mv3/content.bundle.js +28 -3
  10. package/dist/addon-mv3/manifest.json +1 -1
  11. package/dist/addon-mv3/rule-index.json +1 -1
  12. package/dist/addon-mv3/rules.json +1 -1
  13. package/dist/autoconsent.cjs.js +28 -3
  14. package/dist/autoconsent.esm.js +28 -3
  15. package/dist/autoconsent.playwright.js +28 -3
  16. package/dist/autoconsent.standalone.js +29 -4
  17. package/dist/types/cmps/base.d.ts +1 -0
  18. package/dist/types/dom-actions.d.ts +1 -0
  19. package/dist/types/rules.d.ts +6 -2
  20. package/dist/types/utils.d.ts +1 -0
  21. package/docs/rule-syntax.md +14 -0
  22. package/lib/cmps/base.ts +7 -0
  23. package/lib/dom-actions.ts +7 -1
  24. package/lib/heuristic-patterns.ts +2 -2
  25. package/lib/rules.ts +9 -2
  26. package/lib/utils.ts +16 -0
  27. package/package.json +1 -1
  28. package/rules/autoconsent/amazon-pay.json +13 -0
  29. package/rules/autoconsent/bbva.json +12 -0
  30. package/rules/autoconsent/complianz-opt-out.json +6 -0
  31. package/rules/autoconsent/deliveroo.json +15 -0
  32. package/rules/autoconsent/ebay.json +34 -0
  33. package/rules/autoconsent/gemini-google-com.json +9 -0
  34. package/rules/autoconsent/justwatch-com.json +1 -1
  35. package/rules/autoconsent/kingrecords-co-jp.json +21 -0
  36. package/rules/autoconsent/paypal-us.json +4 -3
  37. package/rules/autoconsent/pornpics-de.json +1 -1
  38. package/rules/autoconsent/rule34-xxx.json +12 -0
  39. package/rules/autoconsent/sex.com.json +45 -0
  40. package/rules/autoconsent/theguardian.com.json +13 -3
  41. package/rules/autoconsent/twitch.json +27 -12
  42. package/rules/autoconsent/wpconsent.json +30 -0
  43. package/rules/autoconsent/xhamster-eu.json +3 -1
  44. package/rules/compact-rules.json +1 -1
  45. package/rules/rule-index.json +1 -1
  46. package/rules/rules.json +1 -1
  47. package/tests/amazon-pay.spec.ts +3 -0
  48. package/tests/bbva.spec.ts +4 -0
  49. package/tests/complianz-opt-out.spec.ts +5 -0
  50. package/tests/deliveroo.spec.ts +3 -0
  51. package/tests/gemini-google-com.spec.ts +5 -0
  52. package/tests/justwatch-com.spec.ts +1 -1
  53. package/tests/kingrecords-co-jp.spec.ts +3 -0
  54. package/tests/paypal-us.spec.ts +4 -0
  55. package/tests/pornpics-de.spec.ts +1 -1
  56. package/tests/rule34-xxx.spec.ts +6 -0
  57. package/tests/sex.com.spec.ts +3 -0
  58. package/tests/wpconsent.spec.ts +5 -0
  59. package/tests-wtr/dom-actions/dom-actions.stylesheet.html +13 -0
  60. package/tests-wtr/dom-actions/dom-actions.stylesheet.ts +26 -0
  61. package/tests-wtr/heuristics/heuristics-utils.test.ts +6 -0
  62. package/tests-wtr/utils/append-stylesheet-rule.html +11 -0
  63. 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 = 2;
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) {
@@ -545,8 +559,8 @@
545
559
  // "reject non-essential cookies", "reject unnecessary cookies", "reject all but necessary", "reject all and close"
546
560
  // note that "reject and subscribe" and "reject and pay" are excluded via BUTTON_NEVER_MATCH_PATTERNS
547
561
  /^\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,
548
- // e.g. "i do not accept", "do not accept cookies"
549
- /^\s*(i\s+)?do\s+not\s+accept\s*(cookies)?\s*$/is,
562
+ // e.g. "i do not accept", "do not accept cookies", "i do not accept the use of cookies"
563
+ /^\s*(no,?\s*)?(i\s+)?do\s+not\s+accept\s*(the\s+use\s+of\s+)?(any\s+)?(cookies)?\s*$/is,
550
564
  // e.g. "continue without accepting", "continue without agreeing", "continue without agreeing →"
551
565
  /^\s*(continue|proceed|continue\s+browsing)\s+without\s+(accepting|agreeing|consent|cookies|tracking)(\s*→)?\s*$/is,
552
566
  // essential/necessary/functional-only, e.g. "essential cookies only", "accept only essential cookies",
@@ -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);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Autoconsent",
4
- "version": "2026.8.23",
4
+ "version": "2026.8.25",
5
5
  "background": {
6
6
  "scripts": [
7
7
  "background.bundle.js"