@duckduckgo/autoconsent 6.4.0 → 6.4.1

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/cmps/base.ts CHANGED
@@ -63,7 +63,6 @@ export default class AutoConsentCMPBase implements AutoCMP {
63
63
  }
64
64
 
65
65
  const snippetSrc = getFunctionBody(snippet);
66
- enableLogs && console.log('async eval:', snippetId, snippetSrc);
67
66
  return requestEval(snippetSrc).catch((e) => {
68
67
  enableLogs && console.error('error evaluating rule', snippetId, e);
69
68
  return false;
@@ -1,5 +1,5 @@
1
1
  import { enableLogs } from "../config";
2
- import { click, elementExists, wait, waitForElement } from "../rule-executors";
2
+ import { click, elementExists, wait, waitForElement, waitForThenClick } from "../rule-executors";
3
3
  import { RunContext } from "../rules";
4
4
  import { waitFor } from "../utils";
5
5
  import AutoConsentCMPBase from "./base";
@@ -38,7 +38,7 @@ export default class SourcePoint extends AutoConsentCMPBase {
38
38
  this.ccpaPopup = true;
39
39
  return true;
40
40
  }
41
- return (url.pathname === '/index.html' || url.pathname === '/privacy-manager/index.html')
41
+ return (url.pathname === '/index.html' || url.pathname === '/privacy-manager/index.html' || url.pathname === '/ccpa_pm/index.html')
42
42
  && (url.searchParams.has('message_id') || url.searchParams.has('requestUUID') || url.searchParams.has('consentUUID'));
43
43
  }
44
44
 
@@ -50,7 +50,7 @@ export default class SourcePoint extends AutoConsentCMPBase {
50
50
  return await waitForElement('.priv-save-btn', 2000);
51
51
  }
52
52
  // check for the paywall button, and bail if it exists to prevent broken opt out
53
- await waitForElement(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL", 2000);
53
+ await waitForElement(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL,.sp_choice_type_SAVE_AND_EXIT", 2000);
54
54
  return !elementExists('.sp_choice_type_9');
55
55
  }
56
56
 
@@ -67,7 +67,7 @@ export default class SourcePoint extends AutoConsentCMPBase {
67
67
  }
68
68
 
69
69
  isManagerOpen() {
70
- return location.pathname === "/privacy-manager/index.html";
70
+ return location.pathname === "/privacy-manager/index.html" || location.pathname === '/ccpa_pm/index.html';
71
71
  }
72
72
 
73
73
  async optOut() {
@@ -104,6 +104,10 @@ export default class SourcePoint extends AutoConsentCMPBase {
104
104
  }
105
105
 
106
106
  await waitForElement('.type-modal', 20000);
107
+
108
+ // check "Do Not Sell" (CCPA) toggle if it exists
109
+ waitForThenClick('.ccpa-stack .pm-switch[aria-checked=true] .slider', 500, true); // the UI is reversed: "unchecked" switch displays as an enabled toggle
110
+
107
111
  // reject all button is offered by some sites
108
112
  try {
109
113
  const rejectSelector1 = '.sp_choice_type_REJECT_ALL';
@@ -127,7 +131,7 @@ export default class SourcePoint extends AutoConsentCMPBase {
127
131
  } catch (e) {
128
132
  enableLogs && console.warn(e);
129
133
  }
130
- // TODO: race condition: the popup disappears very quickly, so the background script may not receive a success report.
134
+ // TODO: race condition: if the reject button was clicked, the popup disappears very quickly, so the background script may not receive a success report.
131
135
  return click('.sp_choice_type_SAVE_AND_EXIT');
132
136
  }
133
137
  }
package/lib/config.ts CHANGED
@@ -1 +1,2 @@
1
+ // TODO: make this configurable through DevTools (and possibly toggleable per rule step type)
1
2
  export const enableLogs = false; // change this to enable debug logs
@@ -43,7 +43,7 @@ export function elementVisible(selector: ElementSelector, check: VisibilityCheck
43
43
  export function waitForElement(selector: ElementSelector, timeout = 10000): Promise<boolean> {
44
44
  const interval = 200;
45
45
  const times = Math.ceil((timeout) / interval);
46
- // enableLogs && console.log("[waitFor]", ruleStep.waitFor);
46
+ enableLogs && console.log("[waitForElement]", selector);
47
47
  return waitFor(
48
48
  () => elementSelector(selector).length > 0,
49
49
  times,
package/lib/web.ts CHANGED
@@ -110,7 +110,6 @@ export default class AutoConsent {
110
110
  declarativeRules.autoconsent.forEach((ruleset) => {
111
111
  this.addDeclarativeCMP(ruleset);
112
112
  });
113
- enableLogs && console.log("added rules", this.rules);
114
113
  }
115
114
 
116
115
  addDeclarativeCMP(ruleset: AutoConsentCMPRule) {
@@ -397,7 +396,7 @@ export default class AutoConsent {
397
396
  }
398
397
 
399
398
  async receiveMessageCallback(message: BackgroundMessage) {
400
- if (enableLogs && ['evalResp', 'report'].includes(message.type) /* evals are noisy */) {
399
+ if (enableLogs && !['evalResp', 'report'].includes(message.type) /* evals are noisy */) {
401
400
  console.log('received from background', message, window.location.href);
402
401
  }
403
402
  switch (message.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckduckgo/autoconsent",
3
- "version": "6.4.0",
3
+ "version": "6.4.1",
4
4
  "description": "",
5
5
  "main": "dist/autoconsent.cjs.js",
6
6
  "module": "dist/autoconsent.esm.js",
@@ -33,10 +33,10 @@
33
33
  "@playwright/test": "^1.17.1",
34
34
  "@puppeteer/replay": "^2.11.0",
35
35
  "@types/chai": "^4.3.1",
36
- "@types/chrome": "^0.0.251",
36
+ "@types/chrome": "^0.0.253",
37
37
  "@types/mocha": "^10.0.1",
38
- "@typescript-eslint/eslint-plugin": "^5.42.1",
39
- "@typescript-eslint/parser": "^5.42.1",
38
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
39
+ "@typescript-eslint/parser": "^6.12.0",
40
40
  "auto": "^11.0.1",
41
41
  "bulma": "^0.9.4",
42
42
  "chai": "^4.2.0",
@@ -3,6 +3,7 @@ import generateCMPTests from "../playwright/runner";
3
3
  generateCMPTests('Sourcepoint-frame', [
4
4
  'https://www.theguardian.com/',
5
5
  'https://news.sky.com/',
6
+ 'https://www.economist.com/',
6
7
  ]);
7
8
 
8
9
  generateCMPTests('Sourcepoint-frame', [