@duckduckgo/autoconsent 6.2.0 → 6.4.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/CHANGELOG.md +42 -0
- package/data/coverage.json +820 -793
- package/dist/addon-firefox/content.bundle.js +14 -6
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/rules.json +105 -2
- package/dist/addon-mv3/content.bundle.js +14 -6
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/rules.json +105 -2
- package/dist/autoconsent.cjs.js +14 -6
- package/dist/autoconsent.esm.js +14 -6
- package/dist/autoconsent.playwright.js +1 -1
- package/lib/cmps/onetrust.ts +13 -9
- package/lib/eval-snippets.ts +2 -0
- package/lib/web.ts +4 -0
- package/package.json +3 -3
- package/rules/autoconsent/cc-banner-springer.json +26 -0
- package/rules/autoconsent/takealot-com.json +7 -2
- package/rules/autoconsent/zdf.json +9 -0
- package/rules/rules.json +105 -2
- package/tests/cc-banner-springer.spec.ts +6 -0
- package/tests/onetrust.spec.ts +0 -1
- package/tests/takealot-com.spec.ts +9 -1
- package/tests/zdf.spec.ts +5 -0
package/lib/cmps/onetrust.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { click, elementExists, elementVisible, wait, waitForElement } from "../rule-executors";
|
|
1
|
+
import { click, elementExists, elementVisible, wait, waitForElement, waitForVisible } from "../rule-executors";
|
|
2
2
|
import { RunContext } from "../rules";
|
|
3
3
|
import { waitFor } from "../utils";
|
|
4
4
|
import AutoConsentCMPBase from "./base";
|
|
@@ -32,6 +32,10 @@ export default class Onetrust extends AutoConsentCMPBase {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async optOut() {
|
|
35
|
+
if (elementVisible("#onetrust-reject-all-handler,.js-reject-cookies", 'any')) { // 'reject all' shortcut
|
|
36
|
+
return click("#onetrust-reject-all-handler,.js-reject-cookies");
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
if (elementExists("#onetrust-pc-btn-handler")) { // "show purposes" button inside a popup
|
|
36
40
|
click("#onetrust-pc-btn-handler");
|
|
37
41
|
} else { // otherwise look for a generic "show settings" button
|
|
@@ -39,19 +43,15 @@ export default class Onetrust extends AutoConsentCMPBase {
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
await waitForElement('#onetrust-consent-sdk', 2000);
|
|
42
|
-
await wait(1000);
|
|
46
|
+
await wait(1000); // ideally we want to wait for popup visivility, but it's tricky on e.g. stackoverflow.com
|
|
43
47
|
click("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked", true); // optional step
|
|
44
48
|
|
|
45
|
-
await wait(1000);
|
|
49
|
+
await wait(1000); // ideally we want to wait for popup visivility, but it's tricky on e.g. stackoverflow.com
|
|
46
50
|
await waitForElement(".save-preference-btn-handler,.js-consent-save", 2000);
|
|
47
51
|
click(".save-preference-btn-handler,.js-consent-save");
|
|
48
52
|
|
|
49
53
|
// popup doesn't disappear immediately
|
|
50
|
-
await
|
|
51
|
-
() => elementVisible("#onetrust-banner-sdk", 'none'),
|
|
52
|
-
10,
|
|
53
|
-
500
|
|
54
|
-
);
|
|
54
|
+
await waitForVisible("#onetrust-banner-sdk", 5000, 'none');
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -60,6 +60,10 @@ export default class Onetrust extends AutoConsentCMPBase {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
async test() {
|
|
63
|
-
return await
|
|
63
|
+
return await waitFor(
|
|
64
|
+
() => this.mainWorldEval('EVAL_ONETRUST_1'),
|
|
65
|
+
10,
|
|
66
|
+
500
|
|
67
|
+
)
|
|
64
68
|
}
|
|
65
69
|
}
|
package/lib/eval-snippets.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const snippets = {
|
|
|
26
26
|
EVAL_BORLABS_0: () => !JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('borlabs-cookie') !== -1).split('=', 2)[1])).consents.statistics,
|
|
27
27
|
EVAL_BUNDESREGIERUNG_DE_0: () => document.cookie.match('cookie-allow-tracking=0'),
|
|
28
28
|
EVAL_CANVA_0: () => !document.cookie.includes('gtm_fpc_engagement_event'),
|
|
29
|
+
EVAL_CC_BANNER2_0: () => !!document.cookie.match(/sncc=[^;]+D%3Dtrue/),
|
|
29
30
|
EVAL_CLICKIO_0: () => document.cookie.includes('__lxG__consent__v2_daisybit='),
|
|
30
31
|
EVAL_CLINCH_0: () => document.cookie.includes('ctc_rejected=1'),
|
|
31
32
|
EVAL_COINBASE_0: () => JSON.parse(decodeURIComponent(document.cookie.match(/cm_(eu|default)_preferences=([0-9a-zA-Z\\{\\}\\[\\]%:]*);?/)[2])).consent.length <= 1,
|
|
@@ -70,6 +71,7 @@ export const snippets = {
|
|
|
70
71
|
EVAL_SIRDATA_0: () => document.cookie.includes('euconsent-v2'),
|
|
71
72
|
EVAL_SNIGEL_0: () => !!document.cookie.match('snconsent'),
|
|
72
73
|
EVAL_STEAMPOWERED_0: () => JSON.parse(decodeURIComponent(document.cookie.split(';').find(s => s.trim().startsWith('cookieSettings')).split('=')[1])).preference_state === 2,
|
|
74
|
+
EVAL_TAKEALOT_0: () => document.body.classList.remove('freeze') || (document.body.style = '') || true,
|
|
73
75
|
EVAL_TARTEAUCITRON_0: () => tarteaucitron.userInterface.respondAll(false) || true,
|
|
74
76
|
EVAL_TARTEAUCITRON_1: () => tarteaucitron.userInterface.respondAll(true) || true,
|
|
75
77
|
EVAL_TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)[0].includes('false'),
|
package/lib/web.ts
CHANGED
|
@@ -158,7 +158,11 @@ export default class AutoConsent {
|
|
|
158
158
|
}
|
|
159
159
|
return false;
|
|
160
160
|
}
|
|
161
|
+
|
|
161
162
|
this.updateState({ lifecycle: 'openPopupDetected' });
|
|
163
|
+
if (this.config.enablePrehide && !this.state.prehideOn) { // prehide might have timeouted by this time, apply it again
|
|
164
|
+
this.prehideElements();
|
|
165
|
+
}
|
|
162
166
|
|
|
163
167
|
if (foundPopups.length > 1) {
|
|
164
168
|
const errorDetails = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckduckgo/autoconsent",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/autoconsent.cjs.js",
|
|
6
6
|
"module": "dist/autoconsent.esm.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"clean": "rm -r dist",
|
|
12
12
|
"lint": "eslint lib/ playwright/ tests/ rules/autoconsent/*.json",
|
|
13
13
|
"bundle": "./build.sh",
|
|
14
|
-
"watch": "chokidar \"lib\" \"addon\" \"rules\" -c \"
|
|
14
|
+
"watch": "chokidar \"lib\" \"addon\" \"rules/autoconsent\" -c \"npm run prepublish\"",
|
|
15
15
|
"create-rule": "node rules/create-rule.mjs",
|
|
16
16
|
"test": "playwright test",
|
|
17
17
|
"test:webkit": "playwright test --project webkit",
|
|
@@ -33,7 +33,7 @@
|
|
|
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.
|
|
36
|
+
"@types/chrome": "^0.0.251",
|
|
37
37
|
"@types/mocha": "^10.0.1",
|
|
38
38
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
39
39
|
"@typescript-eslint/parser": "^5.42.1",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cc-banner-springer",
|
|
3
|
+
"prehideSelectors": [".cc-banner[data-cc-banner]"],
|
|
4
|
+
"detectCmp": [{ "exists": ".cc-banner[data-cc-banner]" }],
|
|
5
|
+
"detectPopup": [{ "visible": ".cc-banner[data-cc-banner]" }],
|
|
6
|
+
"optIn": [
|
|
7
|
+
{ "waitForThenClick": ".cc-banner[data-cc-banner] button[data-cc-action=accept]" }
|
|
8
|
+
],
|
|
9
|
+
"optOut": [
|
|
10
|
+
{
|
|
11
|
+
"if": { "exists": ".cc-banner[data-cc-banner] button[data-cc-action=reject]" },
|
|
12
|
+
"then": [{ "click": ".cc-banner[data-cc-banner] button[data-cc-action=reject]" }],
|
|
13
|
+
"else": [
|
|
14
|
+
{ "waitForThenClick": ".cc-banner[data-cc-banner] button[data-cc-action=preferences]" },
|
|
15
|
+
{ "waitFor": ".cc-preferences[data-cc-preferences]" },
|
|
16
|
+
{ "click": ".cc-preferences[data-cc-preferences] input[type=radio][data-cc-action=toggle-category][value=off]", "all": true },
|
|
17
|
+
{
|
|
18
|
+
"if": { "exists": ".cc-preferences[data-cc-preferences] button[data-cc-action=reject]" },
|
|
19
|
+
"then": [{ "click": ".cc-preferences[data-cc-preferences] button[data-cc-action=reject]" }],
|
|
20
|
+
"else": [{ "click": ".cc-preferences[data-cc-preferences] button[data-cc-action=save]" }]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"test": [{ "eval": "EVAL_CC_BANNER2_0"}]
|
|
26
|
+
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "takealot.com",
|
|
3
3
|
"cosmetic": true,
|
|
4
|
-
"prehideSelectors": ["div[class^=\"cookies-banner-
|
|
4
|
+
"prehideSelectors": ["div[class^=\"cookies-banner-module_\"]"],
|
|
5
5
|
"detectCmp": [{ "exists": "div[class^=\"cookies-banner-module_cookie-banner_\"]" }],
|
|
6
6
|
"detectPopup": [{ "exists": "div[class^=\"cookies-banner-module_cookie-banner_\"]" }],
|
|
7
7
|
"optIn": [
|
|
8
8
|
{ "click": "button[class*=\"cookies-banner-module_dismiss-button_\"]" }
|
|
9
9
|
],
|
|
10
10
|
"optOut": [
|
|
11
|
-
{ "hide": ["div[class^=\"cookies-banner-
|
|
11
|
+
{ "hide": ["div[class^=\"cookies-banner-module_\"]"] },
|
|
12
|
+
{
|
|
13
|
+
"if": { "exists": "div[class^=\"cookies-banner-module_small-cookie-banner_\"]" },
|
|
14
|
+
"then": [{ "eval": "EVAL_TAKEALOT_0"}],
|
|
15
|
+
"else": []
|
|
16
|
+
}
|
|
12
17
|
]
|
|
13
18
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zdf",
|
|
3
|
+
"prehideSelectors": ["#zdf-cmp-banner-sdk"],
|
|
4
|
+
"detectCmp": [{ "exists": "#zdf-cmp-banner-sdk" }],
|
|
5
|
+
"detectPopup": [{ "visible": "#zdf-cmp-main.zdf-cmp-show" }],
|
|
6
|
+
"optIn": [ { "waitForThenClick": "#zdf-cmp-main #zdf-cmp-accept-btn" } ],
|
|
7
|
+
"optOut": [ { "waitForThenClick": "#zdf-cmp-main #zdf-cmp-deny-btn" } ],
|
|
8
|
+
"test": []
|
|
9
|
+
}
|
package/rules/rules.json
CHANGED
|
@@ -777,6 +777,71 @@
|
|
|
777
777
|
}
|
|
778
778
|
]
|
|
779
779
|
},
|
|
780
|
+
{
|
|
781
|
+
"name": "cc-banner-springer",
|
|
782
|
+
"prehideSelectors": [
|
|
783
|
+
".cc-banner[data-cc-banner]"
|
|
784
|
+
],
|
|
785
|
+
"detectCmp": [
|
|
786
|
+
{
|
|
787
|
+
"exists": ".cc-banner[data-cc-banner]"
|
|
788
|
+
}
|
|
789
|
+
],
|
|
790
|
+
"detectPopup": [
|
|
791
|
+
{
|
|
792
|
+
"visible": ".cc-banner[data-cc-banner]"
|
|
793
|
+
}
|
|
794
|
+
],
|
|
795
|
+
"optIn": [
|
|
796
|
+
{
|
|
797
|
+
"waitForThenClick": ".cc-banner[data-cc-banner] button[data-cc-action=accept]"
|
|
798
|
+
}
|
|
799
|
+
],
|
|
800
|
+
"optOut": [
|
|
801
|
+
{
|
|
802
|
+
"if": {
|
|
803
|
+
"exists": ".cc-banner[data-cc-banner] button[data-cc-action=reject]"
|
|
804
|
+
},
|
|
805
|
+
"then": [
|
|
806
|
+
{
|
|
807
|
+
"click": ".cc-banner[data-cc-banner] button[data-cc-action=reject]"
|
|
808
|
+
}
|
|
809
|
+
],
|
|
810
|
+
"else": [
|
|
811
|
+
{
|
|
812
|
+
"waitForThenClick": ".cc-banner[data-cc-banner] button[data-cc-action=preferences]"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"waitFor": ".cc-preferences[data-cc-preferences]"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"click": ".cc-preferences[data-cc-preferences] input[type=radio][data-cc-action=toggle-category][value=off]",
|
|
819
|
+
"all": true
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
"if": {
|
|
823
|
+
"exists": ".cc-preferences[data-cc-preferences] button[data-cc-action=reject]"
|
|
824
|
+
},
|
|
825
|
+
"then": [
|
|
826
|
+
{
|
|
827
|
+
"click": ".cc-preferences[data-cc-preferences] button[data-cc-action=reject]"
|
|
828
|
+
}
|
|
829
|
+
],
|
|
830
|
+
"else": [
|
|
831
|
+
{
|
|
832
|
+
"click": ".cc-preferences[data-cc-preferences] button[data-cc-action=save]"
|
|
833
|
+
}
|
|
834
|
+
]
|
|
835
|
+
}
|
|
836
|
+
]
|
|
837
|
+
}
|
|
838
|
+
],
|
|
839
|
+
"test": [
|
|
840
|
+
{
|
|
841
|
+
"eval": "EVAL_CC_BANNER2_0"
|
|
842
|
+
}
|
|
843
|
+
]
|
|
844
|
+
},
|
|
780
845
|
{
|
|
781
846
|
"name": "cc_banner",
|
|
782
847
|
"cosmetic": true,
|
|
@@ -3917,7 +3982,7 @@
|
|
|
3917
3982
|
"name": "takealot.com",
|
|
3918
3983
|
"cosmetic": true,
|
|
3919
3984
|
"prehideSelectors": [
|
|
3920
|
-
"div[class^=\"cookies-banner-
|
|
3985
|
+
"div[class^=\"cookies-banner-module_\"]"
|
|
3921
3986
|
],
|
|
3922
3987
|
"detectCmp": [
|
|
3923
3988
|
{
|
|
@@ -3937,8 +4002,19 @@
|
|
|
3937
4002
|
"optOut": [
|
|
3938
4003
|
{
|
|
3939
4004
|
"hide": [
|
|
3940
|
-
"div[class^=\"cookies-banner-
|
|
4005
|
+
"div[class^=\"cookies-banner-module_\"]"
|
|
3941
4006
|
]
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
"if": {
|
|
4010
|
+
"exists": "div[class^=\"cookies-banner-module_small-cookie-banner_\"]"
|
|
4011
|
+
},
|
|
4012
|
+
"then": [
|
|
4013
|
+
{
|
|
4014
|
+
"eval": "EVAL_TAKEALOT_0"
|
|
4015
|
+
}
|
|
4016
|
+
],
|
|
4017
|
+
"else": []
|
|
3942
4018
|
}
|
|
3943
4019
|
]
|
|
3944
4020
|
},
|
|
@@ -5229,6 +5305,33 @@
|
|
|
5229
5305
|
"eval": "EVAL_YOUTUBE_MOBILE_0"
|
|
5230
5306
|
}
|
|
5231
5307
|
]
|
|
5308
|
+
},
|
|
5309
|
+
{
|
|
5310
|
+
"name": "zdf",
|
|
5311
|
+
"prehideSelectors": [
|
|
5312
|
+
"#zdf-cmp-banner-sdk"
|
|
5313
|
+
],
|
|
5314
|
+
"detectCmp": [
|
|
5315
|
+
{
|
|
5316
|
+
"exists": "#zdf-cmp-banner-sdk"
|
|
5317
|
+
}
|
|
5318
|
+
],
|
|
5319
|
+
"detectPopup": [
|
|
5320
|
+
{
|
|
5321
|
+
"visible": "#zdf-cmp-main.zdf-cmp-show"
|
|
5322
|
+
}
|
|
5323
|
+
],
|
|
5324
|
+
"optIn": [
|
|
5325
|
+
{
|
|
5326
|
+
"waitForThenClick": "#zdf-cmp-main #zdf-cmp-accept-btn"
|
|
5327
|
+
}
|
|
5328
|
+
],
|
|
5329
|
+
"optOut": [
|
|
5330
|
+
{
|
|
5331
|
+
"waitForThenClick": "#zdf-cmp-main #zdf-cmp-deny-btn"
|
|
5332
|
+
}
|
|
5333
|
+
],
|
|
5334
|
+
"test": []
|
|
5232
5335
|
}
|
|
5233
5336
|
],
|
|
5234
5337
|
"consentomatic": {
|
package/tests/onetrust.spec.ts
CHANGED
|
@@ -2,4 +2,12 @@ import generateCMPTests from "../playwright/runner";
|
|
|
2
2
|
|
|
3
3
|
generateCMPTests('takealot.com', [
|
|
4
4
|
'https://www.takealot.com/',
|
|
5
|
-
], {
|
|
5
|
+
], {
|
|
6
|
+
mobile: false,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
generateCMPTests('takealot.com', [
|
|
10
|
+
'https://www.takealot.com/',
|
|
11
|
+
], {
|
|
12
|
+
mobile: true,
|
|
13
|
+
});
|