@duckduckgo/autoconsent 10.5.0 → 10.6.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.
@@ -480,6 +480,22 @@
480
480
  return Object.keys(consents).filter((k) => optionalServices.includes(k)).every((k) => consents[k] === false);
481
481
  }
482
482
  },
483
+ EVAL_KLARO_OPEN_POPUP: () => {
484
+ klaro.show(void 0, true);
485
+ },
486
+ EVAL_KLARO_TRY_API_OPT_OUT: () => {
487
+ if (window.klaro && typeof klaro.show === "function" && typeof klaro.getManager === "function") {
488
+ try {
489
+ klaro.getManager().changeAll(false);
490
+ klaro.getManager().saveAndApplyConsents();
491
+ return true;
492
+ } catch (e) {
493
+ console.warn(e);
494
+ return false;
495
+ }
496
+ }
497
+ return false;
498
+ },
483
499
  EVAL_ONETRUST_1: () => window.OnetrustActiveGroups.split(",").filter((s) => s.length > 0).length <= 1,
484
500
  EVAL_TRUSTARC_TOP: () => window && window.truste && window.truste.eu.bindMap.prefCookie === "0",
485
501
  // declarative rules
@@ -563,7 +579,7 @@
563
579
  EVAL_TAKEALOT_0: () => document.body.classList.remove("freeze") || (document.body.style = "") || true,
564
580
  EVAL_TARTEAUCITRON_0: () => tarteaucitron.userInterface.respondAll(false) || true,
565
581
  EVAL_TARTEAUCITRON_1: () => tarteaucitron.userInterface.respondAll(true) || true,
566
- EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)[0].includes("false"),
582
+ EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)?.[0].includes("false"),
567
583
  EVAL_TAUNTON_TEST: () => document.cookie.includes("taunton_user_consent_submitted=true"),
568
584
  EVAL_TEALIUM_0: () => typeof window.utag !== "undefined" && typeof utag.gdpr === "object",
569
585
  EVAL_TEALIUM_1: () => utag.gdpr.setConsentValue(false) || true,
@@ -1504,14 +1520,14 @@
1504
1520
  return this.elementVisible(".klaro > .cookie-notice,.klaro > .cookie-modal", "any");
1505
1521
  }
1506
1522
  async optOut() {
1507
- if (this.click(".klaro .cn-decline")) {
1523
+ const apiOptOutSuccess = await this.mainWorldEval("EVAL_KLARO_TRY_API_OPT_OUT");
1524
+ if (apiOptOutSuccess) {
1508
1525
  return true;
1509
1526
  }
1510
- if (!this.settingsOpen) {
1511
- this.click(".klaro .cn-learn-more,.klaro .cm-button-manage");
1512
- await this.waitForElement(".klaro > .cookie-modal", 2e3);
1513
- this.settingsOpen = true;
1527
+ if (this.click(".klaro .cn-decline")) {
1528
+ return true;
1514
1529
  }
1530
+ await this.mainWorldEval("EVAL_KLARO_OPEN_POPUP");
1515
1531
  if (this.click(".klaro .cn-decline")) {
1516
1532
  return true;
1517
1533
  }
@@ -7909,7 +7925,7 @@
7909
7925
  ],
7910
7926
  detectPopup: [
7911
7927
  {
7912
- visible: "#tarteaucitronRoot #tarteaucitronAlertSmall,#tarteaucitronRoot #tarteaucitronAlertBig",
7928
+ visible: "#tarteaucitronRoot #tarteaucitronAlertBig",
7913
7929
  check: "any"
7914
7930
  }
7915
7931
  ],
package/lib/cmps/klaro.ts CHANGED
@@ -30,15 +30,18 @@ export default class Klaro extends AutoConsentCMPBase {
30
30
  }
31
31
 
32
32
  async optOut() {
33
+ const apiOptOutSuccess = await this.mainWorldEval("EVAL_KLARO_TRY_API_OPT_OUT")
34
+ if (apiOptOutSuccess) {
35
+ return true
36
+ }
37
+ // if the API is broken for some reason, try clicking instead
38
+
33
39
  if (this.click('.klaro .cn-decline')) {
34
40
  return true;
35
41
  }
36
42
 
37
- if (!this.settingsOpen) {
38
- this.click('.klaro .cn-learn-more,.klaro .cm-button-manage');
39
- await this.waitForElement('.klaro > .cookie-modal', 2000);
40
- this.settingsOpen = true;
41
- }
43
+ // open popup via Javascript API
44
+ await this.mainWorldEval("EVAL_KLARO_OPEN_POPUP")
42
45
 
43
46
  if (this.click('.klaro .cn-decline')) {
44
47
  return true;
@@ -30,6 +30,23 @@ export const snippets = {
30
30
  return Object.keys(consents).filter(k => optionalServices.includes(k)).every(k => consents[k] === false)
31
31
  }
32
32
  },
33
+ EVAL_KLARO_OPEN_POPUP: () => {
34
+ klaro.show(undefined, true)
35
+ },
36
+ EVAL_KLARO_TRY_API_OPT_OUT: () => {
37
+ if (window.klaro && typeof klaro.show === 'function' && typeof klaro.getManager === 'function') {
38
+ try {
39
+ // opt-out directly via API
40
+ klaro.getManager().changeAll(false)
41
+ klaro.getManager().saveAndApplyConsents()
42
+ return true
43
+ } catch (e) {
44
+ console.warn(e)
45
+ return false
46
+ }
47
+ }
48
+ return false
49
+ },
33
50
  EVAL_ONETRUST_1: () => window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1,
34
51
  EVAL_TRUSTARC_TOP: () => window && window.truste && window.truste.eu.bindMap.prefCookie === '0',
35
52
 
@@ -105,7 +122,7 @@ export const snippets = {
105
122
  EVAL_TAKEALOT_0: () => document.body.classList.remove('freeze') || (document.body.style = '') || true,
106
123
  EVAL_TARTEAUCITRON_0: () => tarteaucitron.userInterface.respondAll(false) || true,
107
124
  EVAL_TARTEAUCITRON_1: () => tarteaucitron.userInterface.respondAll(true) || true,
108
- EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)[0].includes('false'),
125
+ EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)?.[0].includes('false'),
109
126
  EVAL_TAUNTON_TEST: () => document.cookie.includes('taunton_user_consent_submitted=true'),
110
127
  EVAL_TEALIUM_0: () => typeof window.utag !== 'undefined' && typeof utag.gdpr === 'object',
111
128
  EVAL_TEALIUM_1: () => utag.gdpr.setConsentValue(false) || true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckduckgo/autoconsent",
3
- "version": "10.5.0",
3
+ "version": "10.6.1",
4
4
  "description": "",
5
5
  "main": "dist/autoconsent.cjs.js",
6
6
  "module": "dist/autoconsent.esm.js",
@@ -3,7 +3,7 @@
3
3
  "prehideSelectors": ["#tarteaucitronRoot"],
4
4
  "detectCmp": [{ "exists": "#tarteaucitronRoot" }],
5
5
  "detectPopup": [{
6
- "visible": "#tarteaucitronRoot #tarteaucitronAlertSmall,#tarteaucitronRoot #tarteaucitronAlertBig",
6
+ "visible": "#tarteaucitronRoot #tarteaucitronAlertBig",
7
7
  "check": "any"
8
8
  }],
9
9
  "optIn": [
package/rules/rules.json CHANGED
@@ -5549,7 +5549,7 @@
5549
5549
  ],
5550
5550
  "detectPopup": [
5551
5551
  {
5552
- "visible": "#tarteaucitronRoot #tarteaucitronAlertSmall,#tarteaucitronRoot #tarteaucitronAlertBig",
5552
+ "visible": "#tarteaucitronRoot #tarteaucitronAlertBig",
5553
5553
  "check": "any"
5554
5554
  }
5555
5555
  ],