@duckduckgo/autoconsent 8.2.0 → 9.0.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 +17 -0
- package/build.sh +1 -0
- package/dist/addon-firefox/background.bundle.js +45 -42
- package/dist/addon-firefox/content.bundle.js +468 -380
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-mv3/background.bundle.js +45 -42
- package/dist/addon-mv3/content.bundle.js +468 -380
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +71 -33
- package/dist/addon-mv3/popup.html +28 -0
- package/dist/autoconsent.cjs.js +468 -380
- package/dist/autoconsent.esm.js +468 -380
- package/dist/autoconsent.playwright.js +1 -1
- package/dist/autoconsent.unit.js +10370 -0
- package/lib/cmps/airbnb.ts +5 -6
- package/lib/cmps/base.ts +97 -41
- package/lib/cmps/consentmanager.ts +13 -14
- package/lib/cmps/conversant.ts +8 -9
- package/lib/cmps/cookiebot.ts +8 -9
- package/lib/cmps/evidon.ts +7 -8
- package/lib/cmps/klaro.ts +13 -14
- package/lib/cmps/onetrust.ts +15 -16
- package/lib/cmps/sourcepoint-frame.ts +25 -26
- package/lib/cmps/tiktok.ts +7 -7
- package/lib/cmps/trustarc-frame.ts +27 -28
- package/lib/cmps/trustarc-top.ts +5 -6
- package/lib/cmps/uniconsent.ts +9 -10
- package/lib/dom-actions.ts +145 -0
- package/lib/types.ts +24 -1
- package/lib/utils.ts +32 -1
- package/lib/web.ts +46 -34
- package/package.json +4 -4
- package/playwright/runner.ts +11 -3
- package/playwright/unit.ts +15 -0
- package/readme.md +1 -1
- package/tests/{rule-executors.spec.ts → dom-actions.spec.ts} +20 -21
- package/lib/config.ts +0 -2
- package/lib/rule-executors.ts +0 -147
package/dist/autoconsent.cjs.js
CHANGED
|
@@ -421,181 +421,6 @@ async function evalAction(config) {
|
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
// lib/config.ts
|
|
425
|
-
var enableLogs = false;
|
|
426
|
-
|
|
427
|
-
// lib/utils.ts
|
|
428
|
-
function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
|
|
429
|
-
const styleSelector = `style#${styleOverrideElementId}`;
|
|
430
|
-
const existingElement = document.querySelector(styleSelector);
|
|
431
|
-
if (existingElement && existingElement instanceof HTMLStyleElement) {
|
|
432
|
-
return existingElement;
|
|
433
|
-
} else {
|
|
434
|
-
const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
|
435
|
-
const css = document.createElement("style");
|
|
436
|
-
css.id = styleOverrideElementId;
|
|
437
|
-
parent.appendChild(css);
|
|
438
|
-
return css;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
function hideElements(styleEl, selector, method = "display") {
|
|
442
|
-
const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
|
|
443
|
-
const rule = `${selector} { ${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important; } `;
|
|
444
|
-
if (styleEl instanceof HTMLStyleElement) {
|
|
445
|
-
styleEl.innerText += rule;
|
|
446
|
-
return selector.length > 0;
|
|
447
|
-
}
|
|
448
|
-
return false;
|
|
449
|
-
}
|
|
450
|
-
async function waitFor(predicate, maxTimes, interval) {
|
|
451
|
-
const result = await predicate();
|
|
452
|
-
if (!result && maxTimes > 0) {
|
|
453
|
-
return new Promise((resolve) => {
|
|
454
|
-
setTimeout(async () => {
|
|
455
|
-
resolve(waitFor(predicate, maxTimes - 1, interval));
|
|
456
|
-
}, interval);
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
return Promise.resolve(result);
|
|
460
|
-
}
|
|
461
|
-
function isElementVisible(elem) {
|
|
462
|
-
if (!elem) {
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
if (elem.offsetParent !== null) {
|
|
466
|
-
return true;
|
|
467
|
-
} else {
|
|
468
|
-
const css = window.getComputedStyle(elem);
|
|
469
|
-
if (css.position === "fixed" && css.display !== "none") {
|
|
470
|
-
return true;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// lib/rule-executors.ts
|
|
477
|
-
function click(selector, all = false) {
|
|
478
|
-
const elem = elementSelector(selector);
|
|
479
|
-
enableLogs && console.log("[click]", selector, all, elem);
|
|
480
|
-
if (elem.length > 0) {
|
|
481
|
-
if (all) {
|
|
482
|
-
elem.forEach((e) => e.click());
|
|
483
|
-
} else {
|
|
484
|
-
elem[0].click();
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return elem.length > 0;
|
|
488
|
-
}
|
|
489
|
-
function elementExists(selector) {
|
|
490
|
-
const exists = elementSelector(selector).length > 0;
|
|
491
|
-
return exists;
|
|
492
|
-
}
|
|
493
|
-
function elementVisible(selector, check) {
|
|
494
|
-
const elem = elementSelector(selector);
|
|
495
|
-
const results = new Array(elem.length);
|
|
496
|
-
elem.forEach((e, i) => {
|
|
497
|
-
results[i] = isElementVisible(e);
|
|
498
|
-
});
|
|
499
|
-
if (check === "none") {
|
|
500
|
-
return results.every((r) => !r);
|
|
501
|
-
} else if (results.length === 0) {
|
|
502
|
-
return false;
|
|
503
|
-
} else if (check === "any") {
|
|
504
|
-
return results.some((r) => r);
|
|
505
|
-
}
|
|
506
|
-
return results.every((r) => r);
|
|
507
|
-
}
|
|
508
|
-
function waitForElement(selector, timeout = 1e4) {
|
|
509
|
-
const interval = 200;
|
|
510
|
-
const times = Math.ceil(timeout / interval);
|
|
511
|
-
enableLogs && console.log("[waitForElement]", selector);
|
|
512
|
-
return waitFor(
|
|
513
|
-
() => elementSelector(selector).length > 0,
|
|
514
|
-
times,
|
|
515
|
-
interval
|
|
516
|
-
);
|
|
517
|
-
}
|
|
518
|
-
function waitForVisible(selector, timeout = 1e4, check = "any") {
|
|
519
|
-
const interval = 200;
|
|
520
|
-
const times = Math.ceil(timeout / interval);
|
|
521
|
-
return waitFor(
|
|
522
|
-
() => elementVisible(selector, check),
|
|
523
|
-
times,
|
|
524
|
-
interval
|
|
525
|
-
);
|
|
526
|
-
}
|
|
527
|
-
async function waitForThenClick2(selector, timeout = 1e4, all = false) {
|
|
528
|
-
await waitForElement(selector, timeout);
|
|
529
|
-
return click(selector, all);
|
|
530
|
-
}
|
|
531
|
-
function wait(ms) {
|
|
532
|
-
return new Promise((resolve) => {
|
|
533
|
-
setTimeout(() => {
|
|
534
|
-
resolve(true);
|
|
535
|
-
}, ms);
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
function hide(selector, method) {
|
|
539
|
-
const styleEl = getStyleElement();
|
|
540
|
-
return hideElements(styleEl, selector, method);
|
|
541
|
-
}
|
|
542
|
-
function prehide(selector) {
|
|
543
|
-
const styleEl = getStyleElement("autoconsent-prehide");
|
|
544
|
-
enableLogs && console.log("[prehide]", styleEl, location.href);
|
|
545
|
-
return hideElements(styleEl, selector, "opacity");
|
|
546
|
-
}
|
|
547
|
-
function undoPrehide() {
|
|
548
|
-
const existingElement = getStyleElement("autoconsent-prehide");
|
|
549
|
-
enableLogs && console.log("[undoprehide]", existingElement, location.href);
|
|
550
|
-
if (existingElement) {
|
|
551
|
-
existingElement.remove();
|
|
552
|
-
}
|
|
553
|
-
return !!existingElement;
|
|
554
|
-
}
|
|
555
|
-
function querySingleReplySelector(selector, parent = document) {
|
|
556
|
-
if (selector.startsWith("aria/")) {
|
|
557
|
-
return [];
|
|
558
|
-
}
|
|
559
|
-
if (selector.startsWith("xpath/")) {
|
|
560
|
-
const xpath = selector.slice(6);
|
|
561
|
-
const result = document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null);
|
|
562
|
-
let node = null;
|
|
563
|
-
const elements = [];
|
|
564
|
-
while (node = result.iterateNext()) {
|
|
565
|
-
elements.push(node);
|
|
566
|
-
}
|
|
567
|
-
return elements;
|
|
568
|
-
}
|
|
569
|
-
if (selector.startsWith("text/")) {
|
|
570
|
-
return [];
|
|
571
|
-
}
|
|
572
|
-
if (selector.startsWith("pierce/")) {
|
|
573
|
-
return [];
|
|
574
|
-
}
|
|
575
|
-
if (parent.shadowRoot) {
|
|
576
|
-
return Array.from(parent.shadowRoot.querySelectorAll(selector));
|
|
577
|
-
}
|
|
578
|
-
return Array.from(parent.querySelectorAll(selector));
|
|
579
|
-
}
|
|
580
|
-
function querySelectorChain(selectors) {
|
|
581
|
-
let parent = document;
|
|
582
|
-
let matches2;
|
|
583
|
-
for (const selector of selectors) {
|
|
584
|
-
matches2 = querySingleReplySelector(selector, parent);
|
|
585
|
-
if (matches2.length === 0) {
|
|
586
|
-
return [];
|
|
587
|
-
}
|
|
588
|
-
parent = matches2[0];
|
|
589
|
-
}
|
|
590
|
-
return matches2;
|
|
591
|
-
}
|
|
592
|
-
function elementSelector(selector) {
|
|
593
|
-
if (typeof selector === "string") {
|
|
594
|
-
return querySingleReplySelector(selector);
|
|
595
|
-
}
|
|
596
|
-
return querySelectorChain(selector);
|
|
597
|
-
}
|
|
598
|
-
|
|
599
424
|
// lib/random.ts
|
|
600
425
|
function getRandomID() {
|
|
601
426
|
if (crypto && typeof crypto.randomUUID !== "undefined") {
|
|
@@ -805,20 +630,21 @@ var AutoConsentCMPBase = class {
|
|
|
805
630
|
console.warn("Snippet not found", snippetId);
|
|
806
631
|
return Promise.resolve(false);
|
|
807
632
|
}
|
|
633
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
808
634
|
if (this.autoconsent.config.isMainWorld) {
|
|
809
|
-
|
|
635
|
+
logsConfig.evals && console.log("inline eval:", snippetId, snippet);
|
|
810
636
|
let result = false;
|
|
811
637
|
try {
|
|
812
638
|
result = !!snippet.call(globalThis);
|
|
813
639
|
} catch (e) {
|
|
814
|
-
|
|
640
|
+
logsConfig.evals && console.error("error evaluating rule", snippetId, e);
|
|
815
641
|
}
|
|
816
642
|
return Promise.resolve(result);
|
|
817
643
|
}
|
|
818
644
|
const snippetSrc = getFunctionBody(snippet);
|
|
819
|
-
|
|
645
|
+
logsConfig.evals && console.log("async eval:", snippetId, snippetSrc);
|
|
820
646
|
return requestEval(snippetSrc, snippetId).catch((e) => {
|
|
821
|
-
|
|
647
|
+
logsConfig.evals && console.error("error evaluating rule", snippetId, e);
|
|
822
648
|
return false;
|
|
823
649
|
});
|
|
824
650
|
}
|
|
@@ -857,93 +683,136 @@ var AutoConsentCMPBase = class {
|
|
|
857
683
|
async test() {
|
|
858
684
|
return Promise.resolve(true);
|
|
859
685
|
}
|
|
686
|
+
// Implementing DomActionsProvider below:
|
|
687
|
+
click(selector, all = false) {
|
|
688
|
+
return this.autoconsent.domActions.click(selector, all);
|
|
689
|
+
}
|
|
690
|
+
elementExists(selector) {
|
|
691
|
+
return this.autoconsent.domActions.elementExists(selector);
|
|
692
|
+
}
|
|
693
|
+
elementVisible(selector, check) {
|
|
694
|
+
return this.autoconsent.domActions.elementVisible(selector, check);
|
|
695
|
+
}
|
|
696
|
+
waitForElement(selector, timeout) {
|
|
697
|
+
return this.autoconsent.domActions.waitForElement(selector, timeout);
|
|
698
|
+
}
|
|
699
|
+
waitForVisible(selector, timeout, check) {
|
|
700
|
+
return this.autoconsent.domActions.waitForVisible(selector, timeout, check);
|
|
701
|
+
}
|
|
702
|
+
waitForThenClick(selector, timeout, all) {
|
|
703
|
+
return this.autoconsent.domActions.waitForThenClick(selector, timeout, all);
|
|
704
|
+
}
|
|
705
|
+
wait(ms) {
|
|
706
|
+
return this.autoconsent.domActions.wait(ms);
|
|
707
|
+
}
|
|
708
|
+
hide(selector, method) {
|
|
709
|
+
return this.autoconsent.domActions.hide(selector, method);
|
|
710
|
+
}
|
|
711
|
+
prehide(selector) {
|
|
712
|
+
return this.autoconsent.domActions.prehide(selector);
|
|
713
|
+
}
|
|
714
|
+
undoPrehide() {
|
|
715
|
+
return this.autoconsent.domActions.undoPrehide();
|
|
716
|
+
}
|
|
717
|
+
querySingleReplySelector(selector, parent) {
|
|
718
|
+
return this.autoconsent.domActions.querySingleReplySelector(selector, parent);
|
|
719
|
+
}
|
|
720
|
+
querySelectorChain(selectors) {
|
|
721
|
+
return this.autoconsent.domActions.querySelectorChain(selectors);
|
|
722
|
+
}
|
|
723
|
+
elementSelector(selector) {
|
|
724
|
+
return this.autoconsent.domActions.elementSelector(selector);
|
|
725
|
+
}
|
|
860
726
|
};
|
|
861
727
|
var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
862
|
-
constructor(
|
|
728
|
+
constructor(rule, autoconsentInstance) {
|
|
863
729
|
super(autoconsentInstance);
|
|
864
|
-
this.
|
|
865
|
-
this.name =
|
|
866
|
-
this.runContext =
|
|
730
|
+
this.rule = rule;
|
|
731
|
+
this.name = rule.name;
|
|
732
|
+
this.runContext = rule.runContext || defaultRunContext;
|
|
867
733
|
}
|
|
868
734
|
get hasSelfTest() {
|
|
869
|
-
return !!this.
|
|
735
|
+
return !!this.rule.test;
|
|
870
736
|
}
|
|
871
737
|
get isIntermediate() {
|
|
872
|
-
return !!this.
|
|
738
|
+
return !!this.rule.intermediate;
|
|
873
739
|
}
|
|
874
740
|
get isCosmetic() {
|
|
875
|
-
return !!this.
|
|
741
|
+
return !!this.rule.cosmetic;
|
|
876
742
|
}
|
|
877
743
|
get prehideSelectors() {
|
|
878
|
-
return this.
|
|
744
|
+
return this.rule.prehideSelectors;
|
|
879
745
|
}
|
|
880
746
|
async detectCmp() {
|
|
881
|
-
if (this.
|
|
882
|
-
return this._runRulesParallel(this.
|
|
747
|
+
if (this.rule.detectCmp) {
|
|
748
|
+
return this._runRulesParallel(this.rule.detectCmp);
|
|
883
749
|
}
|
|
884
750
|
return false;
|
|
885
751
|
}
|
|
886
752
|
async detectPopup() {
|
|
887
|
-
if (this.
|
|
888
|
-
return this._runRulesSequentially(this.
|
|
753
|
+
if (this.rule.detectPopup) {
|
|
754
|
+
return this._runRulesSequentially(this.rule.detectPopup);
|
|
889
755
|
}
|
|
890
756
|
return false;
|
|
891
757
|
}
|
|
892
758
|
async optOut() {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
759
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
760
|
+
if (this.rule.optOut) {
|
|
761
|
+
logsConfig.lifecycle && console.log("Initiated optOut()", this.rule.optOut);
|
|
762
|
+
return this._runRulesSequentially(this.rule.optOut);
|
|
896
763
|
}
|
|
897
764
|
return false;
|
|
898
765
|
}
|
|
899
766
|
async optIn() {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
767
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
768
|
+
if (this.rule.optIn) {
|
|
769
|
+
logsConfig.lifecycle && console.log("Initiated optIn()", this.rule.optIn);
|
|
770
|
+
return this._runRulesSequentially(this.rule.optIn);
|
|
903
771
|
}
|
|
904
772
|
return false;
|
|
905
773
|
}
|
|
906
774
|
async openCmp() {
|
|
907
|
-
if (this.
|
|
908
|
-
return this._runRulesSequentially(this.
|
|
775
|
+
if (this.rule.openCmp) {
|
|
776
|
+
return this._runRulesSequentially(this.rule.openCmp);
|
|
909
777
|
}
|
|
910
778
|
return false;
|
|
911
779
|
}
|
|
912
780
|
async test() {
|
|
913
781
|
if (this.hasSelfTest) {
|
|
914
|
-
return this._runRulesSequentially(this.
|
|
782
|
+
return this._runRulesSequentially(this.rule.test);
|
|
915
783
|
}
|
|
916
784
|
return super.test();
|
|
917
785
|
}
|
|
918
786
|
async evaluateRuleStep(rule) {
|
|
919
787
|
const results = [];
|
|
788
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
920
789
|
if (rule.exists) {
|
|
921
|
-
results.push(elementExists(rule.exists));
|
|
790
|
+
results.push(this.elementExists(rule.exists));
|
|
922
791
|
}
|
|
923
792
|
if (rule.visible) {
|
|
924
|
-
results.push(elementVisible(rule.visible, rule.check));
|
|
793
|
+
results.push(this.elementVisible(rule.visible, rule.check));
|
|
925
794
|
}
|
|
926
795
|
if (rule.eval) {
|
|
927
796
|
const res = this.mainWorldEval(rule.eval);
|
|
928
797
|
results.push(res);
|
|
929
798
|
}
|
|
930
799
|
if (rule.waitFor) {
|
|
931
|
-
results.push(waitForElement(rule.waitFor, rule.timeout));
|
|
800
|
+
results.push(this.waitForElement(rule.waitFor, rule.timeout));
|
|
932
801
|
}
|
|
933
802
|
if (rule.waitForVisible) {
|
|
934
|
-
results.push(waitForVisible(rule.waitForVisible, rule.timeout, rule.check));
|
|
803
|
+
results.push(this.waitForVisible(rule.waitForVisible, rule.timeout, rule.check));
|
|
935
804
|
}
|
|
936
805
|
if (rule.click) {
|
|
937
|
-
results.push(click(rule.click, rule.all));
|
|
806
|
+
results.push(this.click(rule.click, rule.all));
|
|
938
807
|
}
|
|
939
808
|
if (rule.waitForThenClick) {
|
|
940
|
-
results.push(
|
|
809
|
+
results.push(this.waitForThenClick(rule.waitForThenClick, rule.timeout, rule.all));
|
|
941
810
|
}
|
|
942
811
|
if (rule.wait) {
|
|
943
|
-
results.push(wait(rule.wait));
|
|
812
|
+
results.push(this.wait(rule.wait));
|
|
944
813
|
}
|
|
945
814
|
if (rule.hide) {
|
|
946
|
-
results.push(hide(rule.hide, rule.method));
|
|
815
|
+
results.push(this.hide(rule.hide, rule.method));
|
|
947
816
|
}
|
|
948
817
|
if (rule.if) {
|
|
949
818
|
if (!rule.if.exists && !rule.if.visible) {
|
|
@@ -951,7 +820,7 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
951
820
|
return false;
|
|
952
821
|
}
|
|
953
822
|
const condition = await this.evaluateRuleStep(rule.if);
|
|
954
|
-
|
|
823
|
+
logsConfig.rulesteps && console.log("Condition is", condition);
|
|
955
824
|
if (condition) {
|
|
956
825
|
results.push(this._runRulesSequentially(rule.then));
|
|
957
826
|
} else if (rule.else) {
|
|
@@ -967,7 +836,7 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
967
836
|
return false;
|
|
968
837
|
}
|
|
969
838
|
if (results.length === 0) {
|
|
970
|
-
|
|
839
|
+
logsConfig.errors && console.warn("Unrecognized rule", rule);
|
|
971
840
|
return false;
|
|
972
841
|
}
|
|
973
842
|
const all = await Promise.all(results);
|
|
@@ -979,10 +848,11 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
979
848
|
return detections.every((r) => !!r);
|
|
980
849
|
}
|
|
981
850
|
async _runRulesSequentially(rules) {
|
|
851
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
982
852
|
for (const rule of rules) {
|
|
983
|
-
|
|
853
|
+
logsConfig.rulesteps && console.log("Running rule...", rule);
|
|
984
854
|
const result = await this.evaluateRuleStep(rule);
|
|
985
|
-
|
|
855
|
+
logsConfig.rulesteps && console.log("...rule result", result);
|
|
986
856
|
if (!result && !rule.optional) {
|
|
987
857
|
return false;
|
|
988
858
|
}
|
|
@@ -1056,6 +926,82 @@ var ConsentOMaticCMP = class {
|
|
|
1056
926
|
}
|
|
1057
927
|
};
|
|
1058
928
|
|
|
929
|
+
// lib/utils.ts
|
|
930
|
+
function getStyleElement(styleOverrideElementId = "autoconsent-css-rules") {
|
|
931
|
+
const styleSelector = `style#${styleOverrideElementId}`;
|
|
932
|
+
const existingElement = document.querySelector(styleSelector);
|
|
933
|
+
if (existingElement && existingElement instanceof HTMLStyleElement) {
|
|
934
|
+
return existingElement;
|
|
935
|
+
} else {
|
|
936
|
+
const parent = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
|
937
|
+
const css = document.createElement("style");
|
|
938
|
+
css.id = styleOverrideElementId;
|
|
939
|
+
parent.appendChild(css);
|
|
940
|
+
return css;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
function hideElements(styleEl, selector, method = "display") {
|
|
944
|
+
const hidingSnippet = method === "opacity" ? `opacity: 0` : `display: none`;
|
|
945
|
+
const rule = `${selector} { ${hidingSnippet} !important; z-index: -1 !important; pointer-events: none !important; } `;
|
|
946
|
+
if (styleEl instanceof HTMLStyleElement) {
|
|
947
|
+
styleEl.innerText += rule;
|
|
948
|
+
return selector.length > 0;
|
|
949
|
+
}
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
async function waitFor(predicate, maxTimes, interval) {
|
|
953
|
+
const result = await predicate();
|
|
954
|
+
if (!result && maxTimes > 0) {
|
|
955
|
+
return new Promise((resolve) => {
|
|
956
|
+
setTimeout(async () => {
|
|
957
|
+
resolve(waitFor(predicate, maxTimes - 1, interval));
|
|
958
|
+
}, interval);
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
return Promise.resolve(result);
|
|
962
|
+
}
|
|
963
|
+
function isElementVisible(elem) {
|
|
964
|
+
if (!elem) {
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
if (elem.offsetParent !== null) {
|
|
968
|
+
return true;
|
|
969
|
+
} else {
|
|
970
|
+
const css = window.getComputedStyle(elem);
|
|
971
|
+
if (css.position === "fixed" && css.display !== "none") {
|
|
972
|
+
return true;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return false;
|
|
976
|
+
}
|
|
977
|
+
function normalizeConfig(providedConfig) {
|
|
978
|
+
const defaultConfig = {
|
|
979
|
+
enabled: true,
|
|
980
|
+
autoAction: "optOut",
|
|
981
|
+
// if falsy, the extension will wait for an explicit user signal before opting in/out
|
|
982
|
+
disabledCmps: [],
|
|
983
|
+
enablePrehide: true,
|
|
984
|
+
enableCosmeticRules: true,
|
|
985
|
+
detectRetries: 20,
|
|
986
|
+
isMainWorld: false,
|
|
987
|
+
prehideTimeout: 2e3,
|
|
988
|
+
logs: {
|
|
989
|
+
lifecycle: false,
|
|
990
|
+
rulesteps: false,
|
|
991
|
+
evals: false,
|
|
992
|
+
errors: true,
|
|
993
|
+
messages: false
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
const updatedConfig = structuredClone(defaultConfig);
|
|
997
|
+
for (const key of Object.keys(defaultConfig)) {
|
|
998
|
+
if (typeof providedConfig[key] !== "undefined") {
|
|
999
|
+
updatedConfig[key] = providedConfig[key];
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return updatedConfig;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1059
1005
|
// lib/cmps/trustarc-top.ts
|
|
1060
1006
|
var cookieSettingsButton = "#truste-show-consent";
|
|
1061
1007
|
var shortcutOptOut = "#truste-consent-required";
|
|
@@ -1091,17 +1037,17 @@ var TrustArcTop = class extends AutoConsentCMPBase {
|
|
|
1091
1037
|
return false;
|
|
1092
1038
|
}
|
|
1093
1039
|
async detectCmp() {
|
|
1094
|
-
const result = elementExists(`${cookieSettingsButton},${bannerContainer}`);
|
|
1040
|
+
const result = this.elementExists(`${cookieSettingsButton},${bannerContainer}`);
|
|
1095
1041
|
if (result) {
|
|
1096
1042
|
this._shortcutButton = document.querySelector(shortcutOptOut);
|
|
1097
1043
|
}
|
|
1098
1044
|
return result;
|
|
1099
1045
|
}
|
|
1100
1046
|
async detectPopup() {
|
|
1101
|
-
return elementVisible(`${popupContent},${bannerOverlay},${bannerContainer}`, "all");
|
|
1047
|
+
return this.elementVisible(`${popupContent},${bannerOverlay},${bannerContainer}`, "all");
|
|
1102
1048
|
}
|
|
1103
1049
|
openFrame() {
|
|
1104
|
-
click(cookieSettingsButton);
|
|
1050
|
+
this.click(cookieSettingsButton);
|
|
1105
1051
|
}
|
|
1106
1052
|
async optOut() {
|
|
1107
1053
|
if (this._shortcutButton) {
|
|
@@ -1112,7 +1058,7 @@ var TrustArcTop = class extends AutoConsentCMPBase {
|
|
|
1112
1058
|
getStyleElement(),
|
|
1113
1059
|
`.truste_popframe, .truste_overlay, .truste_box_overlay, ${bannerContainer}`
|
|
1114
1060
|
);
|
|
1115
|
-
click(cookieSettingsButton);
|
|
1061
|
+
this.click(cookieSettingsButton);
|
|
1116
1062
|
setTimeout(() => {
|
|
1117
1063
|
getStyleElement().remove();
|
|
1118
1064
|
}, 1e4);
|
|
@@ -1120,7 +1066,7 @@ var TrustArcTop = class extends AutoConsentCMPBase {
|
|
|
1120
1066
|
}
|
|
1121
1067
|
async optIn() {
|
|
1122
1068
|
this._optInDone = true;
|
|
1123
|
-
return click(shortcutOptIn);
|
|
1069
|
+
return this.click(shortcutOptIn);
|
|
1124
1070
|
}
|
|
1125
1071
|
async openCmp() {
|
|
1126
1072
|
return true;
|
|
@@ -1154,62 +1100,62 @@ var TrustArcFrame = class extends AutoConsentCMPBase {
|
|
|
1154
1100
|
return true;
|
|
1155
1101
|
}
|
|
1156
1102
|
async detectPopup() {
|
|
1157
|
-
return elementVisible("#defaultpreferencemanager", "any") && elementVisible(".mainContent", "any");
|
|
1103
|
+
return this.elementVisible("#defaultpreferencemanager", "any") && this.elementVisible(".mainContent", "any");
|
|
1158
1104
|
}
|
|
1159
1105
|
async navigateToSettings() {
|
|
1160
1106
|
await waitFor(
|
|
1161
1107
|
async () => {
|
|
1162
|
-
return elementExists(".shp") || elementVisible(".advance", "any") || elementExists(".switch span:first-child");
|
|
1108
|
+
return this.elementExists(".shp") || this.elementVisible(".advance", "any") || this.elementExists(".switch span:first-child");
|
|
1163
1109
|
},
|
|
1164
1110
|
10,
|
|
1165
1111
|
500
|
|
1166
1112
|
);
|
|
1167
|
-
if (elementExists(".shp")) {
|
|
1168
|
-
click(".shp");
|
|
1113
|
+
if (this.elementExists(".shp")) {
|
|
1114
|
+
this.click(".shp");
|
|
1169
1115
|
}
|
|
1170
|
-
await waitForElement(".prefPanel", 5e3);
|
|
1171
|
-
if (elementVisible(".advance", "any")) {
|
|
1172
|
-
click(".advance");
|
|
1116
|
+
await this.waitForElement(".prefPanel", 5e3);
|
|
1117
|
+
if (this.elementVisible(".advance", "any")) {
|
|
1118
|
+
this.click(".advance");
|
|
1173
1119
|
}
|
|
1174
1120
|
return await waitFor(
|
|
1175
|
-
() => elementVisible(".switch span:first-child", "any"),
|
|
1121
|
+
() => this.elementVisible(".switch span:first-child", "any"),
|
|
1176
1122
|
5,
|
|
1177
1123
|
1e3
|
|
1178
1124
|
);
|
|
1179
1125
|
}
|
|
1180
1126
|
async optOut() {
|
|
1181
1127
|
await waitFor(() => document.readyState === "complete", 20, 100);
|
|
1182
|
-
await waitForElement(".mainContent[aria-hidden=false]", 5e3);
|
|
1183
|
-
if (click(".rejectAll")) {
|
|
1128
|
+
await this.waitForElement(".mainContent[aria-hidden=false]", 5e3);
|
|
1129
|
+
if (this.click(".rejectAll")) {
|
|
1184
1130
|
return true;
|
|
1185
1131
|
}
|
|
1186
|
-
if (elementExists(".prefPanel")) {
|
|
1187
|
-
await waitForElement('.prefPanel[style="visibility: visible;"]', 3e3);
|
|
1132
|
+
if (this.elementExists(".prefPanel")) {
|
|
1133
|
+
await this.waitForElement('.prefPanel[style="visibility: visible;"]', 3e3);
|
|
1188
1134
|
}
|
|
1189
|
-
if (click("#catDetails0")) {
|
|
1190
|
-
click(".submit");
|
|
1191
|
-
waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1135
|
+
if (this.click("#catDetails0")) {
|
|
1136
|
+
this.click(".submit");
|
|
1137
|
+
this.waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1192
1138
|
return true;
|
|
1193
1139
|
}
|
|
1194
|
-
if (click(".required")) {
|
|
1195
|
-
waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1140
|
+
if (this.click(".required")) {
|
|
1141
|
+
this.waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1196
1142
|
return true;
|
|
1197
1143
|
}
|
|
1198
1144
|
await this.navigateToSettings();
|
|
1199
|
-
click(".switch span:nth-child(1):not(.active)", true);
|
|
1200
|
-
click(".submit");
|
|
1201
|
-
waitForThenClick("#gwt-debug-close_id", 3e5);
|
|
1145
|
+
this.click(".switch span:nth-child(1):not(.active)", true);
|
|
1146
|
+
this.click(".submit");
|
|
1147
|
+
this.waitForThenClick("#gwt-debug-close_id", 3e5);
|
|
1202
1148
|
return true;
|
|
1203
1149
|
}
|
|
1204
1150
|
async optIn() {
|
|
1205
|
-
if (click(".call")) {
|
|
1151
|
+
if (this.click(".call")) {
|
|
1206
1152
|
return true;
|
|
1207
1153
|
}
|
|
1208
1154
|
await this.navigateToSettings();
|
|
1209
|
-
click(".switch span:nth-child(2)", true);
|
|
1210
|
-
click(".submit");
|
|
1211
|
-
waitForElement("#gwt-debug-close_id", 3e5).then(() => {
|
|
1212
|
-
click("#gwt-debug-close_id");
|
|
1155
|
+
this.click(".switch span:nth-child(2)", true);
|
|
1156
|
+
this.click(".submit");
|
|
1157
|
+
this.waitForElement("#gwt-debug-close_id", 3e5).then(() => {
|
|
1158
|
+
this.click("#gwt-debug-close_id");
|
|
1213
1159
|
});
|
|
1214
1160
|
return true;
|
|
1215
1161
|
}
|
|
@@ -1238,23 +1184,23 @@ var Cookiebot = class extends AutoConsentCMPBase {
|
|
|
1238
1184
|
return this.mainWorldEval("EVAL_COOKIEBOT_2");
|
|
1239
1185
|
}
|
|
1240
1186
|
async optOut() {
|
|
1241
|
-
await wait(500);
|
|
1187
|
+
await this.wait(500);
|
|
1242
1188
|
let res = await this.mainWorldEval("EVAL_COOKIEBOT_3");
|
|
1243
|
-
await wait(500);
|
|
1189
|
+
await this.wait(500);
|
|
1244
1190
|
res = res && await this.mainWorldEval("EVAL_COOKIEBOT_4");
|
|
1245
1191
|
return res;
|
|
1246
1192
|
}
|
|
1247
1193
|
async optIn() {
|
|
1248
|
-
if (elementExists("#dtcookie-container")) {
|
|
1249
|
-
return click(".h-dtcookie-accept");
|
|
1194
|
+
if (this.elementExists("#dtcookie-container")) {
|
|
1195
|
+
return this.click(".h-dtcookie-accept");
|
|
1250
1196
|
}
|
|
1251
|
-
click(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled", true);
|
|
1252
|
-
click("#CybotCookiebotDialogBodyLevelButtonAccept");
|
|
1253
|
-
click("#CybotCookiebotDialogBodyButtonAccept");
|
|
1197
|
+
this.click(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled", true);
|
|
1198
|
+
this.click("#CybotCookiebotDialogBodyLevelButtonAccept");
|
|
1199
|
+
this.click("#CybotCookiebotDialogBodyButtonAccept");
|
|
1254
1200
|
return true;
|
|
1255
1201
|
}
|
|
1256
1202
|
async test() {
|
|
1257
|
-
await wait(500);
|
|
1203
|
+
await this.wait(500);
|
|
1258
1204
|
return await this.mainWorldEval("EVAL_COOKIEBOT_5");
|
|
1259
1205
|
}
|
|
1260
1206
|
};
|
|
@@ -1298,17 +1244,17 @@ var SourcePoint = class extends AutoConsentCMPBase {
|
|
|
1298
1244
|
return true;
|
|
1299
1245
|
}
|
|
1300
1246
|
if (this.ccpaPopup) {
|
|
1301
|
-
return await waitForElement(".priv-save-btn", 2e3);
|
|
1247
|
+
return await this.waitForElement(".priv-save-btn", 2e3);
|
|
1302
1248
|
}
|
|
1303
|
-
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", 2e3);
|
|
1304
|
-
return !elementExists(".sp_choice_type_9");
|
|
1249
|
+
await this.waitForElement(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL,.sp_choice_type_SAVE_AND_EXIT", 2e3);
|
|
1250
|
+
return !this.elementExists(".sp_choice_type_9");
|
|
1305
1251
|
}
|
|
1306
1252
|
async optIn() {
|
|
1307
|
-
await waitForElement(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL", 2e3);
|
|
1308
|
-
if (click(".sp_choice_type_11")) {
|
|
1253
|
+
await this.waitForElement(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL", 2e3);
|
|
1254
|
+
if (this.click(".sp_choice_type_11")) {
|
|
1309
1255
|
return true;
|
|
1310
1256
|
}
|
|
1311
|
-
if (click(".sp_choice_type_ACCEPT_ALL")) {
|
|
1257
|
+
if (this.click(".sp_choice_type_ACCEPT_ALL")) {
|
|
1312
1258
|
return true;
|
|
1313
1259
|
}
|
|
1314
1260
|
return false;
|
|
@@ -1317,6 +1263,7 @@ var SourcePoint = class extends AutoConsentCMPBase {
|
|
|
1317
1263
|
return location.pathname === "/privacy-manager/index.html" || location.pathname === "/ccpa_pm/index.html";
|
|
1318
1264
|
}
|
|
1319
1265
|
async optOut() {
|
|
1266
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
1320
1267
|
if (this.ccpaPopup) {
|
|
1321
1268
|
const toggles = document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");
|
|
1322
1269
|
for (const t of toggles) {
|
|
@@ -1326,47 +1273,47 @@ var SourcePoint = class extends AutoConsentCMPBase {
|
|
|
1326
1273
|
for (const t of switches) {
|
|
1327
1274
|
t.click();
|
|
1328
1275
|
}
|
|
1329
|
-
return click(".priv-save-btn");
|
|
1276
|
+
return this.click(".priv-save-btn");
|
|
1330
1277
|
}
|
|
1331
1278
|
if (!this.isManagerOpen()) {
|
|
1332
|
-
const actionable = await waitForElement(".sp_choice_type_12,.sp_choice_type_13");
|
|
1279
|
+
const actionable = await this.waitForElement(".sp_choice_type_12,.sp_choice_type_13");
|
|
1333
1280
|
if (!actionable) {
|
|
1334
1281
|
return false;
|
|
1335
1282
|
}
|
|
1336
|
-
if (!elementExists(".sp_choice_type_12")) {
|
|
1337
|
-
return click(".sp_choice_type_13");
|
|
1283
|
+
if (!this.elementExists(".sp_choice_type_12")) {
|
|
1284
|
+
return this.click(".sp_choice_type_13");
|
|
1338
1285
|
}
|
|
1339
|
-
click(".sp_choice_type_12");
|
|
1286
|
+
this.click(".sp_choice_type_12");
|
|
1340
1287
|
await waitFor(
|
|
1341
1288
|
() => this.isManagerOpen(),
|
|
1342
1289
|
200,
|
|
1343
1290
|
100
|
|
1344
1291
|
);
|
|
1345
1292
|
}
|
|
1346
|
-
await waitForElement(".type-modal", 2e4);
|
|
1347
|
-
|
|
1293
|
+
await this.waitForElement(".type-modal", 2e4);
|
|
1294
|
+
this.waitForThenClick(".ccpa-stack .pm-switch[aria-checked=true] .slider", 500, true);
|
|
1348
1295
|
try {
|
|
1349
1296
|
const rejectSelector1 = ".sp_choice_type_REJECT_ALL";
|
|
1350
1297
|
const rejectSelector2 = ".reject-toggle";
|
|
1351
1298
|
const path = await Promise.race([
|
|
1352
|
-
waitForElement(rejectSelector1, 2e3).then((success) => success ? 0 : -1),
|
|
1353
|
-
waitForElement(rejectSelector2, 2e3).then((success) => success ? 1 : -1),
|
|
1354
|
-
waitForElement(".pm-features", 2e3).then((success) => success ? 2 : -1)
|
|
1299
|
+
this.waitForElement(rejectSelector1, 2e3).then((success) => success ? 0 : -1),
|
|
1300
|
+
this.waitForElement(rejectSelector2, 2e3).then((success) => success ? 1 : -1),
|
|
1301
|
+
this.waitForElement(".pm-features", 2e3).then((success) => success ? 2 : -1)
|
|
1355
1302
|
]);
|
|
1356
1303
|
if (path === 0) {
|
|
1357
|
-
await wait(1e3);
|
|
1358
|
-
return click(rejectSelector1);
|
|
1304
|
+
await this.wait(1e3);
|
|
1305
|
+
return this.click(rejectSelector1);
|
|
1359
1306
|
} else if (path === 1) {
|
|
1360
|
-
click(rejectSelector2);
|
|
1307
|
+
this.click(rejectSelector2);
|
|
1361
1308
|
} else if (path === 2) {
|
|
1362
|
-
await waitForElement(".pm-features", 1e4);
|
|
1363
|
-
click(".checked > span", true);
|
|
1364
|
-
click(".chevron");
|
|
1309
|
+
await this.waitForElement(".pm-features", 1e4);
|
|
1310
|
+
this.click(".checked > span", true);
|
|
1311
|
+
this.click(".chevron");
|
|
1365
1312
|
}
|
|
1366
1313
|
} catch (e) {
|
|
1367
|
-
|
|
1314
|
+
logsConfig.errors && console.warn(e);
|
|
1368
1315
|
}
|
|
1369
|
-
return click(".sp_choice_type_SAVE_AND_EXIT");
|
|
1316
|
+
return this.click(".sp_choice_type_SAVE_AND_EXIT");
|
|
1370
1317
|
}
|
|
1371
1318
|
};
|
|
1372
1319
|
|
|
@@ -1390,42 +1337,42 @@ var ConsentManager = class extends AutoConsentCMPBase {
|
|
|
1390
1337
|
async detectCmp() {
|
|
1391
1338
|
this.apiAvailable = await this.mainWorldEval("EVAL_CONSENTMANAGER_1");
|
|
1392
1339
|
if (!this.apiAvailable) {
|
|
1393
|
-
return elementExists("#cmpbox");
|
|
1340
|
+
return this.elementExists("#cmpbox");
|
|
1394
1341
|
} else {
|
|
1395
1342
|
return true;
|
|
1396
1343
|
}
|
|
1397
1344
|
}
|
|
1398
1345
|
async detectPopup() {
|
|
1399
1346
|
if (this.apiAvailable) {
|
|
1400
|
-
await wait(500);
|
|
1347
|
+
await this.wait(500);
|
|
1401
1348
|
return await this.mainWorldEval("EVAL_CONSENTMANAGER_2");
|
|
1402
1349
|
}
|
|
1403
|
-
return elementVisible("#cmpbox .cmpmore", "any");
|
|
1350
|
+
return this.elementVisible("#cmpbox .cmpmore", "any");
|
|
1404
1351
|
}
|
|
1405
1352
|
async optOut() {
|
|
1406
|
-
await wait(500);
|
|
1353
|
+
await this.wait(500);
|
|
1407
1354
|
if (this.apiAvailable) {
|
|
1408
1355
|
return await this.mainWorldEval("EVAL_CONSENTMANAGER_3");
|
|
1409
1356
|
}
|
|
1410
|
-
if (click(".cmpboxbtnno")) {
|
|
1357
|
+
if (this.click(".cmpboxbtnno")) {
|
|
1411
1358
|
return true;
|
|
1412
1359
|
}
|
|
1413
|
-
if (elementExists(".cmpwelcomeprpsbtn")) {
|
|
1414
|
-
click(".cmpwelcomeprpsbtn > a[aria-checked=true]", true);
|
|
1415
|
-
click(".cmpboxbtnsave");
|
|
1360
|
+
if (this.elementExists(".cmpwelcomeprpsbtn")) {
|
|
1361
|
+
this.click(".cmpwelcomeprpsbtn > a[aria-checked=true]", true);
|
|
1362
|
+
this.click(".cmpboxbtnsave");
|
|
1416
1363
|
return true;
|
|
1417
1364
|
}
|
|
1418
|
-
click(".cmpboxbtncustom");
|
|
1419
|
-
await waitForElement(".cmptblbox", 2e3);
|
|
1420
|
-
click(".cmptdchoice > a[aria-checked=true]", true);
|
|
1421
|
-
click(".cmpboxbtnyescustomchoices");
|
|
1365
|
+
this.click(".cmpboxbtncustom");
|
|
1366
|
+
await this.waitForElement(".cmptblbox", 2e3);
|
|
1367
|
+
this.click(".cmptdchoice > a[aria-checked=true]", true);
|
|
1368
|
+
this.click(".cmpboxbtnyescustomchoices");
|
|
1422
1369
|
return true;
|
|
1423
1370
|
}
|
|
1424
1371
|
async optIn() {
|
|
1425
1372
|
if (this.apiAvailable) {
|
|
1426
1373
|
return await this.mainWorldEval("EVAL_CONSENTMANAGER_4");
|
|
1427
1374
|
}
|
|
1428
|
-
return click(".cmpboxbtnyes");
|
|
1375
|
+
return this.click(".cmpboxbtnyes");
|
|
1429
1376
|
}
|
|
1430
1377
|
async test() {
|
|
1431
1378
|
if (this.apiAvailable) {
|
|
@@ -1450,23 +1397,23 @@ var Evidon = class extends AutoConsentCMPBase {
|
|
|
1450
1397
|
return false;
|
|
1451
1398
|
}
|
|
1452
1399
|
async detectCmp() {
|
|
1453
|
-
return elementExists("#_evidon_banner");
|
|
1400
|
+
return this.elementExists("#_evidon_banner");
|
|
1454
1401
|
}
|
|
1455
1402
|
async detectPopup() {
|
|
1456
|
-
return elementVisible("#_evidon_banner", "any");
|
|
1403
|
+
return this.elementVisible("#_evidon_banner", "any");
|
|
1457
1404
|
}
|
|
1458
1405
|
async optOut() {
|
|
1459
|
-
if (click("#_evidon-decline-button")) {
|
|
1406
|
+
if (this.click("#_evidon-decline-button")) {
|
|
1460
1407
|
return true;
|
|
1461
1408
|
}
|
|
1462
1409
|
hideElements(getStyleElement(), "#evidon-prefdiag-overlay,#evidon-prefdiag-background");
|
|
1463
|
-
click("#_evidon-option-button");
|
|
1464
|
-
await waitForElement("#evidon-prefdiag-overlay", 5e3);
|
|
1465
|
-
click("#evidon-prefdiag-decline");
|
|
1410
|
+
this.click("#_evidon-option-button");
|
|
1411
|
+
await this.waitForElement("#evidon-prefdiag-overlay", 5e3);
|
|
1412
|
+
this.click("#evidon-prefdiag-decline");
|
|
1466
1413
|
return true;
|
|
1467
1414
|
}
|
|
1468
1415
|
async optIn() {
|
|
1469
|
-
return click("#_evidon-accept-button");
|
|
1416
|
+
return this.click("#_evidon-accept-button");
|
|
1470
1417
|
}
|
|
1471
1418
|
};
|
|
1472
1419
|
|
|
@@ -1490,31 +1437,31 @@ var Onetrust = class extends AutoConsentCMPBase {
|
|
|
1490
1437
|
return false;
|
|
1491
1438
|
}
|
|
1492
1439
|
async detectCmp() {
|
|
1493
|
-
return elementExists("#onetrust-banner-sdk");
|
|
1440
|
+
return this.elementExists("#onetrust-banner-sdk");
|
|
1494
1441
|
}
|
|
1495
1442
|
async detectPopup() {
|
|
1496
|
-
return elementVisible("#onetrust-banner-sdk", "all");
|
|
1443
|
+
return this.elementVisible("#onetrust-banner-sdk", "all");
|
|
1497
1444
|
}
|
|
1498
1445
|
async optOut() {
|
|
1499
|
-
if (elementVisible("#onetrust-reject-all-handler,.js-reject-cookies", "any")) {
|
|
1500
|
-
return click("#onetrust-reject-all-handler,.js-reject-cookies");
|
|
1446
|
+
if (this.elementVisible("#onetrust-reject-all-handler,.js-reject-cookies", "any")) {
|
|
1447
|
+
return this.click("#onetrust-reject-all-handler,.js-reject-cookies");
|
|
1501
1448
|
}
|
|
1502
|
-
if (elementExists("#onetrust-pc-btn-handler")) {
|
|
1503
|
-
click("#onetrust-pc-btn-handler");
|
|
1449
|
+
if (this.elementExists("#onetrust-pc-btn-handler")) {
|
|
1450
|
+
this.click("#onetrust-pc-btn-handler");
|
|
1504
1451
|
} else {
|
|
1505
|
-
click(".ot-sdk-show-settings,button.js-cookie-settings");
|
|
1506
|
-
}
|
|
1507
|
-
await waitForElement("#onetrust-consent-sdk", 2e3);
|
|
1508
|
-
await wait(1e3);
|
|
1509
|
-
click("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked", true);
|
|
1510
|
-
await wait(1e3);
|
|
1511
|
-
await waitForElement(".save-preference-btn-handler,.js-consent-save", 2e3);
|
|
1512
|
-
click(".save-preference-btn-handler,.js-consent-save");
|
|
1513
|
-
await waitForVisible("#onetrust-banner-sdk", 5e3, "none");
|
|
1452
|
+
this.click(".ot-sdk-show-settings,button.js-cookie-settings");
|
|
1453
|
+
}
|
|
1454
|
+
await this.waitForElement("#onetrust-consent-sdk", 2e3);
|
|
1455
|
+
await this.wait(1e3);
|
|
1456
|
+
this.click("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked", true);
|
|
1457
|
+
await this.wait(1e3);
|
|
1458
|
+
await this.waitForElement(".save-preference-btn-handler,.js-consent-save", 2e3);
|
|
1459
|
+
this.click(".save-preference-btn-handler,.js-consent-save");
|
|
1460
|
+
await this.waitForVisible("#onetrust-banner-sdk", 5e3, "none");
|
|
1514
1461
|
return true;
|
|
1515
1462
|
}
|
|
1516
1463
|
async optIn() {
|
|
1517
|
-
return click("#onetrust-accept-btn-handler,.js-accept-cookies");
|
|
1464
|
+
return this.click("#onetrust-accept-btn-handler,.js-accept-cookies");
|
|
1518
1465
|
}
|
|
1519
1466
|
async test() {
|
|
1520
1467
|
return await waitFor(
|
|
@@ -1543,39 +1490,39 @@ var Klaro = class extends AutoConsentCMPBase {
|
|
|
1543
1490
|
return false;
|
|
1544
1491
|
}
|
|
1545
1492
|
async detectCmp() {
|
|
1546
|
-
if (elementExists(".klaro > .cookie-modal")) {
|
|
1493
|
+
if (this.elementExists(".klaro > .cookie-modal")) {
|
|
1547
1494
|
this.settingsOpen = true;
|
|
1548
1495
|
return true;
|
|
1549
1496
|
}
|
|
1550
|
-
return elementExists(".klaro > .cookie-notice");
|
|
1497
|
+
return this.elementExists(".klaro > .cookie-notice");
|
|
1551
1498
|
}
|
|
1552
1499
|
async detectPopup() {
|
|
1553
|
-
return elementVisible(".klaro > .cookie-notice,.klaro > .cookie-modal", "any");
|
|
1500
|
+
return this.elementVisible(".klaro > .cookie-notice,.klaro > .cookie-modal", "any");
|
|
1554
1501
|
}
|
|
1555
1502
|
async optOut() {
|
|
1556
|
-
if (click(".klaro .cn-decline")) {
|
|
1503
|
+
if (this.click(".klaro .cn-decline")) {
|
|
1557
1504
|
return true;
|
|
1558
1505
|
}
|
|
1559
1506
|
if (!this.settingsOpen) {
|
|
1560
|
-
click(".klaro .cn-learn-more,.klaro .cm-button-manage");
|
|
1561
|
-
await waitForElement(".klaro > .cookie-modal", 2e3);
|
|
1507
|
+
this.click(".klaro .cn-learn-more,.klaro .cm-button-manage");
|
|
1508
|
+
await this.waitForElement(".klaro > .cookie-modal", 2e3);
|
|
1562
1509
|
this.settingsOpen = true;
|
|
1563
1510
|
}
|
|
1564
|
-
if (click(".klaro .cn-decline")) {
|
|
1511
|
+
if (this.click(".klaro .cn-decline")) {
|
|
1565
1512
|
return true;
|
|
1566
1513
|
}
|
|
1567
|
-
click(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked,.required,.only-required),.cm-purpose:not(.cm-toggle-all) > div > input:not(.half-checked,.required,.only-required)", true);
|
|
1568
|
-
return click(".cm-btn-accept,.cm-button");
|
|
1514
|
+
this.click(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked,.required,.only-required),.cm-purpose:not(.cm-toggle-all) > div > input:not(.half-checked,.required,.only-required)", true);
|
|
1515
|
+
return this.click(".cm-btn-accept,.cm-button");
|
|
1569
1516
|
}
|
|
1570
1517
|
async optIn() {
|
|
1571
|
-
if (click(".klaro .cm-btn-accept-all")) {
|
|
1518
|
+
if (this.click(".klaro .cm-btn-accept-all")) {
|
|
1572
1519
|
return true;
|
|
1573
1520
|
}
|
|
1574
1521
|
if (this.settingsOpen) {
|
|
1575
|
-
click(".cm-purpose:not(.cm-toggle-all) > input.half-checked", true);
|
|
1576
|
-
return click(".cm-btn-accept");
|
|
1522
|
+
this.click(".cm-purpose:not(.cm-toggle-all) > input.half-checked", true);
|
|
1523
|
+
return this.click(".cm-btn-accept");
|
|
1577
1524
|
}
|
|
1578
|
-
return click(".klaro .cookie-notice .cm-btn-success");
|
|
1525
|
+
return this.click(".klaro .cookie-notice .cm-btn-success");
|
|
1579
1526
|
}
|
|
1580
1527
|
async test() {
|
|
1581
1528
|
return await this.mainWorldEval("EVAL_KLARO_1");
|
|
@@ -1601,21 +1548,21 @@ var Uniconsent = class extends AutoConsentCMPBase {
|
|
|
1601
1548
|
return false;
|
|
1602
1549
|
}
|
|
1603
1550
|
async detectCmp() {
|
|
1604
|
-
return elementExists(".unic .unic-box,.unic .unic-bar");
|
|
1551
|
+
return this.elementExists(".unic .unic-box,.unic .unic-bar");
|
|
1605
1552
|
}
|
|
1606
1553
|
async detectPopup() {
|
|
1607
|
-
return elementVisible(".unic .unic-box,.unic .unic-bar", "any");
|
|
1554
|
+
return this.elementVisible(".unic .unic-box,.unic .unic-bar", "any");
|
|
1608
1555
|
}
|
|
1609
1556
|
async optOut() {
|
|
1610
|
-
await waitForElement(".unic button", 1e3);
|
|
1557
|
+
await this.waitForElement(".unic button", 1e3);
|
|
1611
1558
|
document.querySelectorAll(".unic button").forEach((button) => {
|
|
1612
1559
|
const text = button.textContent;
|
|
1613
1560
|
if (text.includes("Manage Options") || text.includes("Optionen verwalten")) {
|
|
1614
1561
|
button.click();
|
|
1615
1562
|
}
|
|
1616
1563
|
});
|
|
1617
|
-
if (await waitForElement(".unic input[type=checkbox]", 1e3)) {
|
|
1618
|
-
await waitForElement(".unic button", 1e3);
|
|
1564
|
+
if (await this.waitForElement(".unic input[type=checkbox]", 1e3)) {
|
|
1565
|
+
await this.waitForElement(".unic button", 1e3);
|
|
1619
1566
|
document.querySelectorAll(".unic input[type=checkbox]").forEach((c) => {
|
|
1620
1567
|
if (c.checked) {
|
|
1621
1568
|
c.click();
|
|
@@ -1626,7 +1573,7 @@ var Uniconsent = class extends AutoConsentCMPBase {
|
|
|
1626
1573
|
for (const pattern of ["Confirm Choices", "Save Choices", "Auswahl speichern"]) {
|
|
1627
1574
|
if (text.includes(pattern)) {
|
|
1628
1575
|
b.click();
|
|
1629
|
-
await wait(500);
|
|
1576
|
+
await this.wait(500);
|
|
1630
1577
|
return true;
|
|
1631
1578
|
}
|
|
1632
1579
|
}
|
|
@@ -1635,11 +1582,11 @@ var Uniconsent = class extends AutoConsentCMPBase {
|
|
|
1635
1582
|
return false;
|
|
1636
1583
|
}
|
|
1637
1584
|
async optIn() {
|
|
1638
|
-
return
|
|
1585
|
+
return this.waitForThenClick(".unic #unic-agree");
|
|
1639
1586
|
}
|
|
1640
1587
|
async test() {
|
|
1641
|
-
await wait(1e3);
|
|
1642
|
-
const res = elementExists(".unic .unic-box,.unic .unic-bar");
|
|
1588
|
+
await this.wait(1e3);
|
|
1589
|
+
const res = this.elementExists(".unic .unic-box,.unic .unic-bar");
|
|
1643
1590
|
return !res;
|
|
1644
1591
|
}
|
|
1645
1592
|
};
|
|
@@ -1661,20 +1608,20 @@ var Conversant = class extends AutoConsentCMPBase {
|
|
|
1661
1608
|
return false;
|
|
1662
1609
|
}
|
|
1663
1610
|
async detectCmp() {
|
|
1664
|
-
return elementExists(".cmp-root .cmp-receptacle");
|
|
1611
|
+
return this.elementExists(".cmp-root .cmp-receptacle");
|
|
1665
1612
|
}
|
|
1666
1613
|
async detectPopup() {
|
|
1667
|
-
return elementVisible(".cmp-root .cmp-receptacle", "any");
|
|
1614
|
+
return this.elementVisible(".cmp-root .cmp-receptacle", "any");
|
|
1668
1615
|
}
|
|
1669
1616
|
async optOut() {
|
|
1670
|
-
if (!await
|
|
1617
|
+
if (!await this.waitForThenClick(".cmp-main-button:not(.cmp-main-button--primary)")) {
|
|
1671
1618
|
return false;
|
|
1672
1619
|
}
|
|
1673
|
-
if (!await waitForElement(".cmp-view-tab-tabs")) {
|
|
1620
|
+
if (!await this.waitForElement(".cmp-view-tab-tabs")) {
|
|
1674
1621
|
return false;
|
|
1675
1622
|
}
|
|
1676
|
-
await
|
|
1677
|
-
await
|
|
1623
|
+
await this.waitForThenClick(".cmp-view-tab-tabs > :first-child");
|
|
1624
|
+
await this.waitForThenClick(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");
|
|
1678
1625
|
for (const item of Array.from(document.querySelectorAll(".cmp-accordion-item"))) {
|
|
1679
1626
|
item.querySelector(".cmp-accordion-item-title").click();
|
|
1680
1627
|
await waitFor(() => !!item.querySelector(".cmp-accordion-item-content.cmp-active"), 10, 50);
|
|
@@ -1682,11 +1629,11 @@ var Conversant = class extends AutoConsentCMPBase {
|
|
|
1682
1629
|
content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((e) => e.click());
|
|
1683
1630
|
content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((e) => e.click());
|
|
1684
1631
|
}
|
|
1685
|
-
await click(".cmp-main-button:not(.cmp-main-button--primary)");
|
|
1632
|
+
await this.click(".cmp-main-button:not(.cmp-main-button--primary)");
|
|
1686
1633
|
return true;
|
|
1687
1634
|
}
|
|
1688
1635
|
async optIn() {
|
|
1689
|
-
return
|
|
1636
|
+
return this.waitForThenClick(".cmp-main-button.cmp-main-button--primary");
|
|
1690
1637
|
}
|
|
1691
1638
|
async test() {
|
|
1692
1639
|
return document.cookie.includes("cmp-data=0");
|
|
@@ -1719,31 +1666,33 @@ var Tiktok = class extends AutoConsentCMPBase {
|
|
|
1719
1666
|
return container.shadowRoot;
|
|
1720
1667
|
}
|
|
1721
1668
|
async detectCmp() {
|
|
1722
|
-
return elementExists("tiktok-cookie-banner");
|
|
1669
|
+
return this.elementExists("tiktok-cookie-banner");
|
|
1723
1670
|
}
|
|
1724
1671
|
async detectPopup() {
|
|
1725
1672
|
const banner = this.getShadowRoot().querySelector(".tiktok-cookie-banner");
|
|
1726
1673
|
return isElementVisible(banner);
|
|
1727
1674
|
}
|
|
1728
1675
|
async optOut() {
|
|
1676
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
1729
1677
|
const declineButton = this.getShadowRoot().querySelector(".button-wrapper button:first-child");
|
|
1730
1678
|
if (declineButton) {
|
|
1731
|
-
|
|
1679
|
+
logsConfig.rulesteps && console.log("[clicking]", declineButton);
|
|
1732
1680
|
declineButton.click();
|
|
1733
1681
|
return true;
|
|
1734
1682
|
} else {
|
|
1735
|
-
|
|
1683
|
+
logsConfig.errors && console.log("no decline button found");
|
|
1736
1684
|
return false;
|
|
1737
1685
|
}
|
|
1738
1686
|
}
|
|
1739
1687
|
async optIn() {
|
|
1688
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
1740
1689
|
const acceptButton = this.getShadowRoot().querySelector(".button-wrapper button:last-child");
|
|
1741
1690
|
if (acceptButton) {
|
|
1742
|
-
|
|
1691
|
+
logsConfig.rulesteps && console.log("[clicking]", acceptButton);
|
|
1743
1692
|
acceptButton.click();
|
|
1744
1693
|
return true;
|
|
1745
1694
|
} else {
|
|
1746
|
-
|
|
1695
|
+
logsConfig.errors && console.log("no accept button found");
|
|
1747
1696
|
return false;
|
|
1748
1697
|
}
|
|
1749
1698
|
}
|
|
@@ -1779,21 +1728,21 @@ var Airbnb = class extends AutoConsentCMPBase {
|
|
|
1779
1728
|
return false;
|
|
1780
1729
|
}
|
|
1781
1730
|
async detectCmp() {
|
|
1782
|
-
return elementExists("div[data-testid=main-cookies-banner-container]");
|
|
1731
|
+
return this.elementExists("div[data-testid=main-cookies-banner-container]");
|
|
1783
1732
|
}
|
|
1784
1733
|
async detectPopup() {
|
|
1785
|
-
return elementVisible("div[data-testid=main-cookies-banner-container", "any");
|
|
1734
|
+
return this.elementVisible("div[data-testid=main-cookies-banner-container", "any");
|
|
1786
1735
|
}
|
|
1787
1736
|
async optOut() {
|
|
1788
|
-
await
|
|
1737
|
+
await this.waitForThenClick("div[data-testid=main-cookies-banner-container] button._snbhip0");
|
|
1789
1738
|
let check;
|
|
1790
1739
|
while (check = document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])")) {
|
|
1791
1740
|
check.click();
|
|
1792
1741
|
}
|
|
1793
|
-
return
|
|
1742
|
+
return this.waitForThenClick("button[data-testid=save-btn]");
|
|
1794
1743
|
}
|
|
1795
1744
|
async optIn() {
|
|
1796
|
-
return
|
|
1745
|
+
return this.waitForThenClick("div[data-testid=main-cookies-banner-container] button._148dgdpk");
|
|
1797
1746
|
}
|
|
1798
1747
|
async test() {
|
|
1799
1748
|
return await waitFor(
|
|
@@ -1820,6 +1769,134 @@ var dynamicCMPs = [
|
|
|
1820
1769
|
Airbnb
|
|
1821
1770
|
];
|
|
1822
1771
|
|
|
1772
|
+
// lib/dom-actions.ts
|
|
1773
|
+
var DomActions = class {
|
|
1774
|
+
constructor(autoconsentInstance) {
|
|
1775
|
+
this.autoconsentInstance = autoconsentInstance;
|
|
1776
|
+
}
|
|
1777
|
+
click(selector, all = false) {
|
|
1778
|
+
const elem = this.elementSelector(selector);
|
|
1779
|
+
this.autoconsentInstance.config.logs.rulesteps && console.log("[click]", selector, all, elem);
|
|
1780
|
+
if (elem.length > 0) {
|
|
1781
|
+
if (all) {
|
|
1782
|
+
elem.forEach((e) => e.click());
|
|
1783
|
+
} else {
|
|
1784
|
+
elem[0].click();
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return elem.length > 0;
|
|
1788
|
+
}
|
|
1789
|
+
elementExists(selector) {
|
|
1790
|
+
const exists = this.elementSelector(selector).length > 0;
|
|
1791
|
+
return exists;
|
|
1792
|
+
}
|
|
1793
|
+
elementVisible(selector, check) {
|
|
1794
|
+
const elem = this.elementSelector(selector);
|
|
1795
|
+
const results = new Array(elem.length);
|
|
1796
|
+
elem.forEach((e, i) => {
|
|
1797
|
+
results[i] = isElementVisible(e);
|
|
1798
|
+
});
|
|
1799
|
+
if (check === "none") {
|
|
1800
|
+
return results.every((r) => !r);
|
|
1801
|
+
} else if (results.length === 0) {
|
|
1802
|
+
return false;
|
|
1803
|
+
} else if (check === "any") {
|
|
1804
|
+
return results.some((r) => r);
|
|
1805
|
+
}
|
|
1806
|
+
return results.every((r) => r);
|
|
1807
|
+
}
|
|
1808
|
+
waitForElement(selector, timeout = 1e4) {
|
|
1809
|
+
const interval = 200;
|
|
1810
|
+
const times = Math.ceil(timeout / interval);
|
|
1811
|
+
this.autoconsentInstance.config.logs.rulesteps && console.log("[waitForElement]", selector);
|
|
1812
|
+
return waitFor(
|
|
1813
|
+
() => this.elementSelector(selector).length > 0,
|
|
1814
|
+
times,
|
|
1815
|
+
interval
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
waitForVisible(selector, timeout = 1e4, check = "any") {
|
|
1819
|
+
const interval = 200;
|
|
1820
|
+
const times = Math.ceil(timeout / interval);
|
|
1821
|
+
return waitFor(
|
|
1822
|
+
() => this.elementVisible(selector, check),
|
|
1823
|
+
times,
|
|
1824
|
+
interval
|
|
1825
|
+
);
|
|
1826
|
+
}
|
|
1827
|
+
async waitForThenClick(selector, timeout = 1e4, all = false) {
|
|
1828
|
+
await this.waitForElement(selector, timeout);
|
|
1829
|
+
return this.click(selector, all);
|
|
1830
|
+
}
|
|
1831
|
+
wait(ms) {
|
|
1832
|
+
return new Promise((resolve) => {
|
|
1833
|
+
setTimeout(() => {
|
|
1834
|
+
resolve(true);
|
|
1835
|
+
}, ms);
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
hide(selector, method) {
|
|
1839
|
+
const styleEl = getStyleElement();
|
|
1840
|
+
return hideElements(styleEl, selector, method);
|
|
1841
|
+
}
|
|
1842
|
+
prehide(selector) {
|
|
1843
|
+
const styleEl = getStyleElement("autoconsent-prehide");
|
|
1844
|
+
this.autoconsentInstance.config.logs.lifecycle && console.log("[prehide]", styleEl, location.href);
|
|
1845
|
+
return hideElements(styleEl, selector, "opacity");
|
|
1846
|
+
}
|
|
1847
|
+
undoPrehide() {
|
|
1848
|
+
const existingElement = getStyleElement("autoconsent-prehide");
|
|
1849
|
+
this.autoconsentInstance.config.logs.lifecycle && console.log("[undoprehide]", existingElement, location.href);
|
|
1850
|
+
if (existingElement) {
|
|
1851
|
+
existingElement.remove();
|
|
1852
|
+
}
|
|
1853
|
+
return !!existingElement;
|
|
1854
|
+
}
|
|
1855
|
+
querySingleReplySelector(selector, parent = document) {
|
|
1856
|
+
if (selector.startsWith("aria/")) {
|
|
1857
|
+
return [];
|
|
1858
|
+
}
|
|
1859
|
+
if (selector.startsWith("xpath/")) {
|
|
1860
|
+
const xpath = selector.slice(6);
|
|
1861
|
+
const result = document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null);
|
|
1862
|
+
let node = null;
|
|
1863
|
+
const elements = [];
|
|
1864
|
+
while (node = result.iterateNext()) {
|
|
1865
|
+
elements.push(node);
|
|
1866
|
+
}
|
|
1867
|
+
return elements;
|
|
1868
|
+
}
|
|
1869
|
+
if (selector.startsWith("text/")) {
|
|
1870
|
+
return [];
|
|
1871
|
+
}
|
|
1872
|
+
if (selector.startsWith("pierce/")) {
|
|
1873
|
+
return [];
|
|
1874
|
+
}
|
|
1875
|
+
if (parent.shadowRoot) {
|
|
1876
|
+
return Array.from(parent.shadowRoot.querySelectorAll(selector));
|
|
1877
|
+
}
|
|
1878
|
+
return Array.from(parent.querySelectorAll(selector));
|
|
1879
|
+
}
|
|
1880
|
+
querySelectorChain(selectors) {
|
|
1881
|
+
let parent = document;
|
|
1882
|
+
let matches2;
|
|
1883
|
+
for (const selector of selectors) {
|
|
1884
|
+
matches2 = this.querySingleReplySelector(selector, parent);
|
|
1885
|
+
if (matches2.length === 0) {
|
|
1886
|
+
return [];
|
|
1887
|
+
}
|
|
1888
|
+
parent = matches2[0];
|
|
1889
|
+
}
|
|
1890
|
+
return matches2;
|
|
1891
|
+
}
|
|
1892
|
+
elementSelector(selector) {
|
|
1893
|
+
if (typeof selector === "string") {
|
|
1894
|
+
return this.querySingleReplySelector(selector);
|
|
1895
|
+
}
|
|
1896
|
+
return this.querySelectorChain(selector);
|
|
1897
|
+
}
|
|
1898
|
+
};
|
|
1899
|
+
|
|
1823
1900
|
// lib/web.ts
|
|
1824
1901
|
function filterCMPs(rules, config) {
|
|
1825
1902
|
return rules.filter((cmp) => {
|
|
@@ -1842,7 +1919,6 @@ var AutoConsent = class {
|
|
|
1842
1919
|
evalState.sendContentMessage = sendContentMessage;
|
|
1843
1920
|
this.sendContentMessage = sendContentMessage;
|
|
1844
1921
|
this.rules = [];
|
|
1845
|
-
enableLogs && console.log("autoconsent init", window.location.href);
|
|
1846
1922
|
this.updateState({ lifecycle: "loading" });
|
|
1847
1923
|
this.addDynamicRules();
|
|
1848
1924
|
if (config) {
|
|
@@ -1858,17 +1934,20 @@ var AutoConsent = class {
|
|
|
1858
1934
|
sendContentMessage(initMsg);
|
|
1859
1935
|
this.updateState({ lifecycle: "waitingForInitResponse" });
|
|
1860
1936
|
}
|
|
1937
|
+
this.domActions = new DomActions(this);
|
|
1861
1938
|
}
|
|
1862
1939
|
initialize(config, declarativeRules) {
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1940
|
+
const normalizedConfig = normalizeConfig(config);
|
|
1941
|
+
normalizedConfig.logs.lifecycle && console.log("autoconsent init", window.location.href);
|
|
1942
|
+
this.config = normalizedConfig;
|
|
1943
|
+
if (!normalizedConfig.enabled) {
|
|
1944
|
+
normalizedConfig.logs.lifecycle && console.log("autoconsent is disabled");
|
|
1866
1945
|
return;
|
|
1867
1946
|
}
|
|
1868
1947
|
if (declarativeRules) {
|
|
1869
1948
|
this.parseDeclarativeRules(declarativeRules);
|
|
1870
1949
|
}
|
|
1871
|
-
this.rules = filterCMPs(this.rules,
|
|
1950
|
+
this.rules = filterCMPs(this.rules, normalizedConfig);
|
|
1872
1951
|
if (config.enablePrehide) {
|
|
1873
1952
|
if (document.documentElement) {
|
|
1874
1953
|
this.prehideElements();
|
|
@@ -1919,12 +1998,13 @@ var AutoConsent = class {
|
|
|
1919
1998
|
}
|
|
1920
1999
|
}
|
|
1921
2000
|
async _start() {
|
|
1922
|
-
|
|
2001
|
+
const logsConfig = this.config.logs;
|
|
2002
|
+
logsConfig.lifecycle && console.log(`Detecting CMPs on ${window.location.href}`);
|
|
1923
2003
|
this.updateState({ lifecycle: "started" });
|
|
1924
2004
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
1925
2005
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
1926
2006
|
if (foundCmps.length === 0) {
|
|
1927
|
-
|
|
2007
|
+
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
1928
2008
|
if (this.config.enablePrehide) {
|
|
1929
2009
|
this.undoPrehide();
|
|
1930
2010
|
}
|
|
@@ -1937,7 +2017,7 @@ var AutoConsent = class {
|
|
|
1937
2017
|
foundPopups = await this.detectPopups(foundCmps.filter((r) => r.isCosmetic));
|
|
1938
2018
|
}
|
|
1939
2019
|
if (foundPopups.length === 0) {
|
|
1940
|
-
|
|
2020
|
+
logsConfig.lifecycle && console.log("no popup found");
|
|
1941
2021
|
if (this.config.enablePrehide) {
|
|
1942
2022
|
this.undoPrehide();
|
|
1943
2023
|
}
|
|
@@ -1952,7 +2032,7 @@ var AutoConsent = class {
|
|
|
1952
2032
|
msg: `Found multiple CMPs, check the detection rules.`,
|
|
1953
2033
|
cmps: foundPopups.map((cmp) => cmp.name)
|
|
1954
2034
|
};
|
|
1955
|
-
|
|
2035
|
+
logsConfig.errors && console.warn(errorDetails.msg, errorDetails.cmps);
|
|
1956
2036
|
this.sendContentMessage({
|
|
1957
2037
|
type: "autoconsentError",
|
|
1958
2038
|
details: errorDetails
|
|
@@ -1964,11 +2044,12 @@ var AutoConsent = class {
|
|
|
1964
2044
|
} else if (this.config.autoAction === "optIn") {
|
|
1965
2045
|
return await this.doOptIn();
|
|
1966
2046
|
} else {
|
|
1967
|
-
|
|
2047
|
+
logsConfig.lifecycle && console.log("waiting for opt-out signal...", location.href);
|
|
1968
2048
|
return true;
|
|
1969
2049
|
}
|
|
1970
2050
|
}
|
|
1971
2051
|
async findCmp(retries) {
|
|
2052
|
+
const logsConfig = this.config.logs;
|
|
1972
2053
|
this.updateState({ findCmpAttempts: this.state.findCmpAttempts + 1 });
|
|
1973
2054
|
const foundCMPs = [];
|
|
1974
2055
|
for (const cmp of this.rules) {
|
|
@@ -1978,7 +2059,7 @@ var AutoConsent = class {
|
|
|
1978
2059
|
}
|
|
1979
2060
|
const result = await cmp.detectCmp();
|
|
1980
2061
|
if (result) {
|
|
1981
|
-
|
|
2062
|
+
logsConfig.lifecycle && console.log(`Found CMP: ${cmp.name} ${window.location.href}`);
|
|
1982
2063
|
this.sendContentMessage({
|
|
1983
2064
|
type: "cmpDetected",
|
|
1984
2065
|
url: location.href,
|
|
@@ -1987,16 +2068,17 @@ var AutoConsent = class {
|
|
|
1987
2068
|
foundCMPs.push(cmp);
|
|
1988
2069
|
}
|
|
1989
2070
|
} catch (e) {
|
|
1990
|
-
|
|
2071
|
+
logsConfig.errors && console.warn(`error detecting ${cmp.name}`, e);
|
|
1991
2072
|
}
|
|
1992
2073
|
}
|
|
1993
2074
|
if (foundCMPs.length === 0 && retries > 0) {
|
|
1994
|
-
await wait(500);
|
|
2075
|
+
await this.domActions.wait(500);
|
|
1995
2076
|
return this.findCmp(retries - 1);
|
|
1996
2077
|
}
|
|
1997
2078
|
return foundCMPs;
|
|
1998
2079
|
}
|
|
1999
2080
|
async detectPopups(cmps) {
|
|
2081
|
+
const logsConfig = this.config.logs;
|
|
2000
2082
|
const result = [];
|
|
2001
2083
|
const popupLookups = cmps.map((cmp) => this.waitForPopup(cmp).then((isOpen) => {
|
|
2002
2084
|
if (isOpen) {
|
|
@@ -2009,22 +2091,23 @@ var AutoConsent = class {
|
|
|
2009
2091
|
result.push(cmp);
|
|
2010
2092
|
}
|
|
2011
2093
|
}).catch((e) => {
|
|
2012
|
-
|
|
2094
|
+
logsConfig.errors && console.warn(`error waiting for a popup for ${cmp.name}`, e);
|
|
2013
2095
|
return null;
|
|
2014
2096
|
}));
|
|
2015
2097
|
await Promise.all(popupLookups);
|
|
2016
2098
|
return result;
|
|
2017
2099
|
}
|
|
2018
2100
|
async doOptOut() {
|
|
2101
|
+
const logsConfig = this.config.logs;
|
|
2019
2102
|
this.updateState({ lifecycle: "runningOptOut" });
|
|
2020
2103
|
let optOutResult;
|
|
2021
2104
|
if (!this.foundCmp) {
|
|
2022
|
-
|
|
2105
|
+
logsConfig.errors && console.log("no CMP to opt out");
|
|
2023
2106
|
optOutResult = false;
|
|
2024
2107
|
} else {
|
|
2025
|
-
|
|
2108
|
+
logsConfig.lifecycle && console.log(`CMP ${this.foundCmp.name}: opt out on ${window.location.href}`);
|
|
2026
2109
|
optOutResult = await this.foundCmp.optOut();
|
|
2027
|
-
|
|
2110
|
+
logsConfig.lifecycle && console.log(`${this.foundCmp.name}: opt out result ${optOutResult}`);
|
|
2028
2111
|
}
|
|
2029
2112
|
if (this.config.enablePrehide) {
|
|
2030
2113
|
this.undoPrehide();
|
|
@@ -2050,15 +2133,16 @@ var AutoConsent = class {
|
|
|
2050
2133
|
return optOutResult;
|
|
2051
2134
|
}
|
|
2052
2135
|
async doOptIn() {
|
|
2136
|
+
const logsConfig = this.config.logs;
|
|
2053
2137
|
this.updateState({ lifecycle: "runningOptIn" });
|
|
2054
2138
|
let optInResult;
|
|
2055
2139
|
if (!this.foundCmp) {
|
|
2056
|
-
|
|
2140
|
+
logsConfig.errors && console.log("no CMP to opt in");
|
|
2057
2141
|
optInResult = false;
|
|
2058
2142
|
} else {
|
|
2059
|
-
|
|
2143
|
+
logsConfig.lifecycle && console.log(`CMP ${this.foundCmp.name}: opt in on ${window.location.href}`);
|
|
2060
2144
|
optInResult = await this.foundCmp.optIn();
|
|
2061
|
-
|
|
2145
|
+
logsConfig.lifecycle && console.log(`${this.foundCmp.name}: opt in result ${optInResult}`);
|
|
2062
2146
|
}
|
|
2063
2147
|
if (this.config.enablePrehide) {
|
|
2064
2148
|
this.undoPrehide();
|
|
@@ -2085,12 +2169,13 @@ var AutoConsent = class {
|
|
|
2085
2169
|
return optInResult;
|
|
2086
2170
|
}
|
|
2087
2171
|
async doSelfTest() {
|
|
2172
|
+
const logsConfig = this.config.logs;
|
|
2088
2173
|
let selfTestResult;
|
|
2089
2174
|
if (!this.foundCmp) {
|
|
2090
|
-
|
|
2175
|
+
logsConfig.errors && console.log("no CMP to self test");
|
|
2091
2176
|
selfTestResult = false;
|
|
2092
2177
|
} else {
|
|
2093
|
-
|
|
2178
|
+
logsConfig.lifecycle && console.log(`CMP ${this.foundCmp.name}: self-test on ${window.location.href}`);
|
|
2094
2179
|
selfTestResult = await this.foundCmp.test();
|
|
2095
2180
|
}
|
|
2096
2181
|
this.sendContentMessage({
|
|
@@ -2103,19 +2188,21 @@ var AutoConsent = class {
|
|
|
2103
2188
|
return selfTestResult;
|
|
2104
2189
|
}
|
|
2105
2190
|
async waitForPopup(cmp, retries = 5, interval = 500) {
|
|
2106
|
-
|
|
2191
|
+
const logsConfig = this.config.logs;
|
|
2192
|
+
logsConfig.lifecycle && console.log("checking if popup is open...", cmp.name);
|
|
2107
2193
|
const isOpen = await cmp.detectPopup().catch((e) => {
|
|
2108
|
-
|
|
2194
|
+
logsConfig.errors && console.warn(`error detecting popup for ${cmp.name}`, e);
|
|
2109
2195
|
return false;
|
|
2110
2196
|
});
|
|
2111
2197
|
if (!isOpen && retries > 0) {
|
|
2112
|
-
await wait(interval);
|
|
2198
|
+
await this.domActions.wait(interval);
|
|
2113
2199
|
return this.waitForPopup(cmp, retries - 1, interval);
|
|
2114
2200
|
}
|
|
2115
|
-
|
|
2201
|
+
logsConfig.lifecycle && console.log(cmp.name, `popup is ${isOpen ? "open" : "not open"}`);
|
|
2116
2202
|
return isOpen;
|
|
2117
2203
|
}
|
|
2118
2204
|
prehideElements() {
|
|
2205
|
+
const logsConfig = this.config.logs;
|
|
2119
2206
|
const globalHidden = [
|
|
2120
2207
|
"#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"
|
|
2121
2208
|
];
|
|
@@ -2128,15 +2215,15 @@ var AutoConsent = class {
|
|
|
2128
2215
|
this.updateState({ prehideOn: true });
|
|
2129
2216
|
setTimeout(() => {
|
|
2130
2217
|
if (this.config.enablePrehide && this.state.prehideOn && !["runningOptOut", "runningOptIn"].includes(this.state.lifecycle)) {
|
|
2131
|
-
|
|
2218
|
+
logsConfig.lifecycle && console.log("Process is taking too long, unhiding elements");
|
|
2132
2219
|
this.undoPrehide();
|
|
2133
2220
|
}
|
|
2134
2221
|
}, this.config.prehideTimeout || 2e3);
|
|
2135
|
-
return prehide(selectors.join(","));
|
|
2222
|
+
return this.domActions.prehide(selectors.join(","));
|
|
2136
2223
|
}
|
|
2137
2224
|
undoPrehide() {
|
|
2138
2225
|
this.updateState({ prehideOn: false });
|
|
2139
|
-
return undoPrehide();
|
|
2226
|
+
return this.domActions.undoPrehide();
|
|
2140
2227
|
}
|
|
2141
2228
|
updateState(change) {
|
|
2142
2229
|
Object.assign(this.state, change);
|
|
@@ -2149,7 +2236,8 @@ var AutoConsent = class {
|
|
|
2149
2236
|
});
|
|
2150
2237
|
}
|
|
2151
2238
|
async receiveMessageCallback(message) {
|
|
2152
|
-
|
|
2239
|
+
const logsConfig = this.config?.logs;
|
|
2240
|
+
if (logsConfig?.messages) {
|
|
2153
2241
|
console.log("received from background", message, window.location.href);
|
|
2154
2242
|
}
|
|
2155
2243
|
switch (message.type) {
|