@duckduckgo/autoconsent 16.46.0 → 16.47.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/lib/encoding.ts CHANGED
@@ -13,14 +13,7 @@ export type CompactRuleStep = {
13
13
 
14
14
  export type CompactCMPRuleStep = AutoConsentRuleStep & Partial<CompactRuleStep>;
15
15
  type CompactableRuleStepKey =
16
- | 'exists'
17
- | 'visible'
18
- | 'waitForThenClick'
19
- | 'click'
20
- | 'waitFor'
21
- | 'waitForVisible'
22
- | 'hide'
23
- | 'cookieContains';
16
+ 'exists' | 'visible' | 'waitForThenClick' | 'click' | 'waitFor' | 'waitForVisible' | 'hide' | 'cookieContains';
24
17
  type CompactNullableBoolean = 0 | 1 | 2;
25
18
 
26
19
  export type CompactCMPRule = [
package/lib/messages.ts CHANGED
@@ -2,12 +2,7 @@ import { snippets } from './eval-snippets';
2
2
  import { Config, ConsentState, RuleBundle } from './types';
3
3
 
4
4
  export type BackgroundMessage =
5
- | InitResponseMessage
6
- | EvalResponseMessage
7
- | OptOutMessage
8
- | OptInMessage
9
- | SelfTestMessage
10
- | MeasurePerformanceMessage;
5
+ InitResponseMessage | EvalResponseMessage | OptOutMessage | OptInMessage | SelfTestMessage | MeasurePerformanceMessage;
11
6
 
12
7
  export type ContentScriptMessage =
13
8
  | InitMessage
package/lib/web.ts CHANGED
@@ -274,10 +274,9 @@ export default class AutoConsent {
274
274
  }
275
275
  });
276
276
  // heuristic CMP is only run in the top frame and only if heuristic action is enabled and retries is odd
277
+ const heuristicEnabled = isTop && this.config.heuristicMode !== 'off';
277
278
  const heuristicRules =
278
- isTop && this.config.heuristicMode !== 'off' && this.state.findCmpAttempts % 2 === 0
279
- ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)]
280
- : [];
279
+ heuristicEnabled && this.state.findCmpAttempts % 2 === 0 ? [new AutoConsentHeuristicCMP(this, this.config.heuristicMode)] : [];
281
280
 
282
281
  const rulesPriorityStages: [string, AutoCMP[]][] = [
283
282
  ['site-specific', siteSpecificRules],
@@ -330,7 +329,9 @@ export default class AutoConsent {
330
329
  // We wait 500ms, and also for some kind of dom mutation to happen before
331
330
  // rerunning the findCmp check
332
331
  const waitFor: Promise<boolean>[] = [this.domActions.wait(500)];
333
- if (this.state.findCmpAttempts > 1) {
332
+ // a skipped heuristic has not seen the current DOM yet, so the next attempt must not wait for another mutation
333
+ const heuristicSkipped = heuristicEnabled && heuristicRules.length === 0;
334
+ if (this.state.findCmpAttempts > 1 && !heuristicSkipped) {
334
335
  waitFor.push(mutationObserver);
335
336
  }
336
337
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckduckgo/autoconsent",
3
- "version": "16.46.0",
3
+ "version": "16.47.0",
4
4
  "description": "",
5
5
  "types": "./dist/types/web.d.ts",
6
6
  "exports": {
@@ -42,7 +42,7 @@
42
42
  "author": "Sam Macbeth",
43
43
  "license": "MPL-2.0",
44
44
  "devDependencies": {
45
- "@duckduckgo/eslint-config": "github:duckduckgo/eslint-config#v0.3.0",
45
+ "@duckduckgo/eslint-config": "github:duckduckgo/eslint-config#v0.3.1",
46
46
  "@esm-bundle/chai": "^4.3.4-fix.0",
47
47
  "@octokit/rest": "^22.0.1",
48
48
  "@playwright/test": "^1.63.0",
@@ -65,13 +65,13 @@
65
65
  "jsonc-parser": "^3.3.1",
66
66
  "markdown-it": "^15.0.2",
67
67
  "mocha": "^12.0.3",
68
- "prettier": "3.8.3",
68
+ "prettier": "3.9.9",
69
69
  "randexp": "^0.5.3",
70
70
  "sinon": "^22.0.0",
71
71
  "ts-json-schema-generator": "^2.3.0",
72
72
  "ts-node": "^10.9.2",
73
73
  "tslib": "^2.4.0",
74
- "typescript": "^5.1.6",
74
+ "typescript": "^6.0.3",
75
75
  "typescript-eslint": "^8.12.2",
76
76
  "web-ext": "^10.0.0"
77
77
  },
@@ -182,10 +182,10 @@
182
182
  "color": "#ededed"
183
183
  },
184
184
  {
185
- "name": "code-update-needed",
185
+ "name": "needs-code-update",
186
186
  "description": "Changes the autoconsent library code, so consuming browsers need a version update",
187
187
  "releaseType": "none",
188
- "color": "#fbca04"
188
+ "color": "#0b591c"
189
189
  }
190
190
  ],
191
191
  "plugins": [
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "controlgame",
3
+ "vendorUrl": "https://controlgame.com/",
4
+ "runContext": {
5
+ "urlPattern": "^https?://(www\\.)?controlgame\\.com/"
6
+ },
7
+ "detectCmp": [{ "exists": "[data-consent-button][data-value=accept_partial]" }],
8
+ "detectPopup": [{ "visible": "[data-consent-button][data-value=accept_partial]" }],
9
+ "optIn": [{ "waitForThenClick": "[data-consent-button][data-value=accept_all]", "retry": 10, "retryInterval": 500 }],
10
+ "optOut": [{ "waitForThenClick": "[data-consent-button][data-value=accept_partial]", "retry": 10, "retryInterval": 500 }],
11
+ "test": [{ "cookieContains": "advertisement:no" }]
12
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "dalecarnegie",
3
+ "vendorUrl": "https://www.dalecarnegie.com/",
4
+ "runContext": {
5
+ "urlPattern": "^https?://(\\w+\\.)?dalecarnegie\\.com/"
6
+ },
7
+ "prehideSelectors": [],
8
+ "detectCmp": [
9
+ {
10
+ "exists": "[class*=\"PrivacyBar_gdprAgreement\"] [class*=\"PrivacyBar_managePrefsBtn\"]"
11
+ }
12
+ ],
13
+ "detectPopup": [
14
+ {
15
+ "visible": "[class*=\"PrivacyBar_gdprAgreement\"]"
16
+ }
17
+ ],
18
+ "optIn": [
19
+ {
20
+ "waitForThenClick": "[class*=\"PrivacyBar_gdprAgreement\"] [class*=\"PrivacyBar_allowBtn\"]"
21
+ }
22
+ ],
23
+ "optOut": [
24
+ {
25
+ "waitForThenClick": "[class*=\"PrivacyBar_gdprAgreement\"] [class*=\"PrivacyBar_managePrefsBtn\"]"
26
+ },
27
+ {
28
+ "waitForVisible": "[class*=\"CookieManagementModal_confirmBtn\"]"
29
+ },
30
+ {
31
+ "click": "[class*=\"CookieManagementModal_dropdownHeader\"] [class*=\"SwitchButton_toggleSwitch\"] input:checked",
32
+ "all": true,
33
+ "optional": true
34
+ },
35
+ {
36
+ "click": "[class*=\"CookieManagementModal_confirmBtn\"]"
37
+ }
38
+ ],
39
+ "test": [
40
+ {
41
+ "cookieContains": "%22targeting%22:false"
42
+ }
43
+ ]
44
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "jpmorgan-chase",
3
+ "vendorUrl": "https://www.jpmorganchase.com/",
4
+ "prehideSelectors": [".consent-banner:has(.consent-close-icon-wrapper)"],
5
+ "detectCmp": [{ "exists": ".consent-banner a.consent-close-icon-wrapper[data-pt-name=\"consent-closed\"]" }],
6
+ "detectPopup": [{ "visible": ".consent-banner a.consent-close-icon-wrapper[data-pt-name=\"consent-closed\"]" }],
7
+ "optIn": [{ "waitForThenClick": ".consent-banner a.consent-close-icon-wrapper[data-pt-name=\"consent-closed\"]" }],
8
+ "optOut": [{ "waitForThenClick": ".consent-banner a.consent-close-icon-wrapper[data-pt-name=\"consent-closed\"]" }],
9
+ "test": [{ "cookieContains": "cbc=true" }]
10
+ }