@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
@@ -0,0 +1,3 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('amazon-pay', ['https://pay.amazon.co.jp/', 'https://pay.amazon.co.uk/', 'https://pay.amazon.de/']);
@@ -0,0 +1,4 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ // bbva.es uses the same banner, but its bot protection blocks datacenter IPs, so it is not listed here.
4
+ generateCMPTests('bbva', ['https://www.bbvauk.com/', 'https://www.bbva.be/'], {});
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('Complianz opt-out', ['https://www.thefoxandpheasant.com/food-menu/', 'https://www.museum.de/', 'https://www.dtv.de/'], {
4
+ testOptIn: false,
5
+ });
@@ -0,0 +1,3 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('deliveroo', ['https://deliveroo.co.uk/', 'https://deliveroo.fr/', 'https://deliveroo.it/', 'https://deliveroo.ie/']);
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('gemini.google.com', ['https://gemini.google.com/app'], {
4
+ skipRegions: ['NA'],
5
+ });
@@ -1,3 +1,3 @@
1
1
  import generateCMPTests from '../playwright/runner';
2
2
 
3
- generateCMPTests('justwatch.com', ['https://www.justwatch.com/'], {});
3
+ generateCMPTests('justwatch.com', ['https://www.justwatch.com/', 'https://www.justwatch.com/us/movie/a-knights-tale'], {});
@@ -0,0 +1,3 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('kingrecords-co-jp', ['https://www.kingrecords.co.jp/']);
@@ -1,3 +1,7 @@
1
1
  import generateCMPTests from '../playwright/runner';
2
2
 
3
3
  generateCMPTests('paypal-us', ['https://www.paypal.com/us/home'], {});
4
+
5
+ // This banner variant has no "Decline" button, so opting out goes through the cookie
6
+ // preferences page, which navigates away and back, running the rule more than once.
7
+ generateCMPTests('paypal-us', ['https://www.paypal.com/ca/home'], { expectedRuns: 3 });
@@ -1,3 +1,3 @@
1
1
  import generateCMPTests from '../playwright/runner';
2
2
 
3
- generateCMPTests('pornpics.de', ['https://www.pornpics.de/']);
3
+ generateCMPTests('pornpics.de', ['https://www.pornpics.de/', 'https://www.pornpics.com/']);
@@ -0,0 +1,6 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('rule34-xxx', ['https://rule34.xxx/index.php?page=post&s=list&tags=all'], {
4
+ onlyRegions: ['DE'],
5
+ testOptIn: false,
6
+ });
@@ -0,0 +1,3 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('sex.com', ['https://www.sex.com/']);
@@ -0,0 +1,5 @@
1
+ import generateCMPTests from '../playwright/runner';
2
+
3
+ generateCMPTests('WPConsent', ['https://www.allthebestfights.com/', 'https://usatourist.com/'], {
4
+ testSelfTest: false,
5
+ });
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <body>
3
+ <script type="module">
4
+ import { runTests } from '@web/test-runner-mocha';
5
+
6
+ runTests(async () => {
7
+ await import('./dom-actions.stylesheet');
8
+ });
9
+ </script>
10
+
11
+ <div id="target"></div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,26 @@
1
+ import { expect } from '@esm-bundle/chai';
2
+ import { instantiateDomActions } from './utils';
3
+
4
+ describe('stylesheet', () => {
5
+ const domActions = instantiateDomActions();
6
+
7
+ afterEach(() => {
8
+ document.getElementById('autoconsent-css-rules')?.remove();
9
+ });
10
+
11
+ it('appends a stylesheet rule', () => {
12
+ const result = domActions.stylesheet('.locked body { position: static !important; }', 'test-scroll-unlock');
13
+ expect(result).to.be.true;
14
+ const styleEl = document.getElementById('autoconsent-css-rules');
15
+ expect(styleEl?.textContent).to.include('position: static !important');
16
+ expect(styleEl?.textContent).to.include('/* autoconsent:test-scroll-unlock */');
17
+ });
18
+
19
+ it('does not duplicate rules with the same stylesheetId', () => {
20
+ domActions.stylesheet('.locked body { position: static !important; }', 'test-scroll-unlock');
21
+ const result = domActions.stylesheet('.locked body { position: static !important; }', 'test-scroll-unlock');
22
+ expect(result).to.be.true;
23
+ const styleEl = document.getElementById('autoconsent-css-rules');
24
+ expect(styleEl?.textContent?.match(/test-scroll-unlock/g)?.length).to.equal(1);
25
+ });
26
+ });
@@ -141,6 +141,12 @@ describe('classifyButtonTextRegex', () => {
141
141
  expect(classifyButtonTextRegex('Reject All (except Necessary)')).to.equal('reject');
142
142
  });
143
143
 
144
+ it('matches "do not accept" variants', () => {
145
+ expect(classifyButtonTextRegex('I do not accept')).to.equal('reject');
146
+ expect(classifyButtonTextRegex('Do not accept cookies')).to.equal('reject');
147
+ expect(classifyButtonTextRegex('I do not accept the use of cookies')).to.equal('reject');
148
+ });
149
+
144
150
  it('returns other for empty string', () => {
145
151
  expect(classifyButtonTextRegex('')).to.equal('other');
146
152
  });
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <body>
3
+ <script type="module">
4
+ import { runTests } from '@web/test-runner-mocha';
5
+
6
+ runTests(async () => {
7
+ await import('./append-stylesheet-rule.test');
8
+ });
9
+ </script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,29 @@
1
+ import { expect } from '@esm-bundle/chai';
2
+ import { appendStylesheetRule } from '../../lib/utils';
3
+
4
+ describe('appendStylesheetRule', () => {
5
+ let styleEl: HTMLStyleElement;
6
+
7
+ beforeEach(() => {
8
+ styleEl = document.createElement('style');
9
+ document.head.appendChild(styleEl);
10
+ });
11
+
12
+ afterEach(() => {
13
+ styleEl.remove();
14
+ });
15
+
16
+ it('appends a CSS rule to the stylesheet', () => {
17
+ const result = appendStylesheetRule(styleEl, 'html.locked body { overflow: auto !important; }', 'scroll-unlock');
18
+ expect(result).to.be.true;
19
+ expect(styleEl.innerText).to.include('overflow: auto !important');
20
+ expect(styleEl.innerText).to.include('/* autoconsent:scroll-unlock */');
21
+ });
22
+
23
+ it('is idempotent when called with the same marker', () => {
24
+ appendStylesheetRule(styleEl, 'html.locked body { overflow: auto !important; }', 'scroll-unlock');
25
+ const lengthAfterFirst = styleEl.innerText.length;
26
+ appendStylesheetRule(styleEl, 'html.locked body { overflow: auto !important; }', 'scroll-unlock');
27
+ expect(styleEl.innerText.length).to.equal(lengthAfterFirst);
28
+ });
29
+ });