@duckduckgo/autoconsent 8.1.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 +29 -0
- package/build.sh +1 -0
- package/dist/addon-firefox/background.bundle.js +60 -43
- package/dist/addon-firefox/content.bundle.js +484 -382
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-mv3/background.bundle.js +60 -43
- package/dist/addon-mv3/content.bundle.js +484 -382
- 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 +484 -382
- package/dist/autoconsent.esm.js +484 -382
- 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/eval-snippets.ts +17 -2
- 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/tests/klaro.spec.ts +1 -0
- 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") {
|
|
@@ -658,7 +483,21 @@ var snippets = {
|
|
|
658
483
|
EVAL_COOKIEBOT_3: () => window.Cookiebot.withdraw() || true,
|
|
659
484
|
EVAL_COOKIEBOT_4: () => window.Cookiebot.hide() || true,
|
|
660
485
|
EVAL_COOKIEBOT_5: () => window.Cookiebot.declined === true,
|
|
661
|
-
EVAL_KLARO_1: () =>
|
|
486
|
+
EVAL_KLARO_1: () => {
|
|
487
|
+
const config = globalThis.klaroConfig || globalThis.klaro?.getManager && globalThis.klaro.getManager().config;
|
|
488
|
+
if (!config) {
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
const optionalServices = (config.services || config.apps).filter((s) => !s.required).map((s) => s.name);
|
|
492
|
+
if (klaro && klaro.getManager) {
|
|
493
|
+
const manager = klaro.getManager();
|
|
494
|
+
return optionalServices.every((name) => !manager.consents[name]);
|
|
495
|
+
} else if (klaroConfig && klaroConfig.storageMethod === "cookie") {
|
|
496
|
+
const cookieName = klaroConfig.cookieName || klaroConfig.storageName;
|
|
497
|
+
const consents = JSON.parse(decodeURIComponent(document.cookie.split(";").find((c) => c.trim().startsWith(cookieName)).split("=")[1]));
|
|
498
|
+
return Object.keys(consents).filter((k) => optionalServices.includes(k)).every((k) => consents[k] === false);
|
|
499
|
+
}
|
|
500
|
+
},
|
|
662
501
|
EVAL_ONETRUST_1: () => window.OnetrustActiveGroups.split(",").filter((s) => s.length > 0).length <= 1,
|
|
663
502
|
EVAL_TRUSTARC_TOP: () => window && window.truste && window.truste.eu.bindMap.prefCookie === "0",
|
|
664
503
|
// declarative rules
|
|
@@ -762,7 +601,7 @@ var snippets = {
|
|
|
762
601
|
};
|
|
763
602
|
function getFunctionBody(snippetFunc) {
|
|
764
603
|
const snippetStr = snippetFunc.toString();
|
|
765
|
-
return
|
|
604
|
+
return `(${snippetStr})()`;
|
|
766
605
|
}
|
|
767
606
|
|
|
768
607
|
// lib/cmps/base.ts
|
|
@@ -791,20 +630,21 @@ var AutoConsentCMPBase = class {
|
|
|
791
630
|
console.warn("Snippet not found", snippetId);
|
|
792
631
|
return Promise.resolve(false);
|
|
793
632
|
}
|
|
633
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
794
634
|
if (this.autoconsent.config.isMainWorld) {
|
|
795
|
-
|
|
635
|
+
logsConfig.evals && console.log("inline eval:", snippetId, snippet);
|
|
796
636
|
let result = false;
|
|
797
637
|
try {
|
|
798
638
|
result = !!snippet.call(globalThis);
|
|
799
639
|
} catch (e) {
|
|
800
|
-
|
|
640
|
+
logsConfig.evals && console.error("error evaluating rule", snippetId, e);
|
|
801
641
|
}
|
|
802
642
|
return Promise.resolve(result);
|
|
803
643
|
}
|
|
804
644
|
const snippetSrc = getFunctionBody(snippet);
|
|
805
|
-
|
|
645
|
+
logsConfig.evals && console.log("async eval:", snippetId, snippetSrc);
|
|
806
646
|
return requestEval(snippetSrc, snippetId).catch((e) => {
|
|
807
|
-
|
|
647
|
+
logsConfig.evals && console.error("error evaluating rule", snippetId, e);
|
|
808
648
|
return false;
|
|
809
649
|
});
|
|
810
650
|
}
|
|
@@ -843,93 +683,136 @@ var AutoConsentCMPBase = class {
|
|
|
843
683
|
async test() {
|
|
844
684
|
return Promise.resolve(true);
|
|
845
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
|
+
}
|
|
846
726
|
};
|
|
847
727
|
var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
848
|
-
constructor(
|
|
728
|
+
constructor(rule, autoconsentInstance) {
|
|
849
729
|
super(autoconsentInstance);
|
|
850
|
-
this.
|
|
851
|
-
this.name =
|
|
852
|
-
this.runContext =
|
|
730
|
+
this.rule = rule;
|
|
731
|
+
this.name = rule.name;
|
|
732
|
+
this.runContext = rule.runContext || defaultRunContext;
|
|
853
733
|
}
|
|
854
734
|
get hasSelfTest() {
|
|
855
|
-
return !!this.
|
|
735
|
+
return !!this.rule.test;
|
|
856
736
|
}
|
|
857
737
|
get isIntermediate() {
|
|
858
|
-
return !!this.
|
|
738
|
+
return !!this.rule.intermediate;
|
|
859
739
|
}
|
|
860
740
|
get isCosmetic() {
|
|
861
|
-
return !!this.
|
|
741
|
+
return !!this.rule.cosmetic;
|
|
862
742
|
}
|
|
863
743
|
get prehideSelectors() {
|
|
864
|
-
return this.
|
|
744
|
+
return this.rule.prehideSelectors;
|
|
865
745
|
}
|
|
866
746
|
async detectCmp() {
|
|
867
|
-
if (this.
|
|
868
|
-
return this._runRulesParallel(this.
|
|
747
|
+
if (this.rule.detectCmp) {
|
|
748
|
+
return this._runRulesParallel(this.rule.detectCmp);
|
|
869
749
|
}
|
|
870
750
|
return false;
|
|
871
751
|
}
|
|
872
752
|
async detectPopup() {
|
|
873
|
-
if (this.
|
|
874
|
-
return this._runRulesSequentially(this.
|
|
753
|
+
if (this.rule.detectPopup) {
|
|
754
|
+
return this._runRulesSequentially(this.rule.detectPopup);
|
|
875
755
|
}
|
|
876
756
|
return false;
|
|
877
757
|
}
|
|
878
758
|
async optOut() {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
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);
|
|
882
763
|
}
|
|
883
764
|
return false;
|
|
884
765
|
}
|
|
885
766
|
async optIn() {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
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);
|
|
889
771
|
}
|
|
890
772
|
return false;
|
|
891
773
|
}
|
|
892
774
|
async openCmp() {
|
|
893
|
-
if (this.
|
|
894
|
-
return this._runRulesSequentially(this.
|
|
775
|
+
if (this.rule.openCmp) {
|
|
776
|
+
return this._runRulesSequentially(this.rule.openCmp);
|
|
895
777
|
}
|
|
896
778
|
return false;
|
|
897
779
|
}
|
|
898
780
|
async test() {
|
|
899
781
|
if (this.hasSelfTest) {
|
|
900
|
-
return this._runRulesSequentially(this.
|
|
782
|
+
return this._runRulesSequentially(this.rule.test);
|
|
901
783
|
}
|
|
902
784
|
return super.test();
|
|
903
785
|
}
|
|
904
786
|
async evaluateRuleStep(rule) {
|
|
905
787
|
const results = [];
|
|
788
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
906
789
|
if (rule.exists) {
|
|
907
|
-
results.push(elementExists(rule.exists));
|
|
790
|
+
results.push(this.elementExists(rule.exists));
|
|
908
791
|
}
|
|
909
792
|
if (rule.visible) {
|
|
910
|
-
results.push(elementVisible(rule.visible, rule.check));
|
|
793
|
+
results.push(this.elementVisible(rule.visible, rule.check));
|
|
911
794
|
}
|
|
912
795
|
if (rule.eval) {
|
|
913
796
|
const res = this.mainWorldEval(rule.eval);
|
|
914
797
|
results.push(res);
|
|
915
798
|
}
|
|
916
799
|
if (rule.waitFor) {
|
|
917
|
-
results.push(waitForElement(rule.waitFor, rule.timeout));
|
|
800
|
+
results.push(this.waitForElement(rule.waitFor, rule.timeout));
|
|
918
801
|
}
|
|
919
802
|
if (rule.waitForVisible) {
|
|
920
|
-
results.push(waitForVisible(rule.waitForVisible, rule.timeout, rule.check));
|
|
803
|
+
results.push(this.waitForVisible(rule.waitForVisible, rule.timeout, rule.check));
|
|
921
804
|
}
|
|
922
805
|
if (rule.click) {
|
|
923
|
-
results.push(click(rule.click, rule.all));
|
|
806
|
+
results.push(this.click(rule.click, rule.all));
|
|
924
807
|
}
|
|
925
808
|
if (rule.waitForThenClick) {
|
|
926
|
-
results.push(
|
|
809
|
+
results.push(this.waitForThenClick(rule.waitForThenClick, rule.timeout, rule.all));
|
|
927
810
|
}
|
|
928
811
|
if (rule.wait) {
|
|
929
|
-
results.push(wait(rule.wait));
|
|
812
|
+
results.push(this.wait(rule.wait));
|
|
930
813
|
}
|
|
931
814
|
if (rule.hide) {
|
|
932
|
-
results.push(hide(rule.hide, rule.method));
|
|
815
|
+
results.push(this.hide(rule.hide, rule.method));
|
|
933
816
|
}
|
|
934
817
|
if (rule.if) {
|
|
935
818
|
if (!rule.if.exists && !rule.if.visible) {
|
|
@@ -937,7 +820,7 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
937
820
|
return false;
|
|
938
821
|
}
|
|
939
822
|
const condition = await this.evaluateRuleStep(rule.if);
|
|
940
|
-
|
|
823
|
+
logsConfig.rulesteps && console.log("Condition is", condition);
|
|
941
824
|
if (condition) {
|
|
942
825
|
results.push(this._runRulesSequentially(rule.then));
|
|
943
826
|
} else if (rule.else) {
|
|
@@ -953,7 +836,7 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
953
836
|
return false;
|
|
954
837
|
}
|
|
955
838
|
if (results.length === 0) {
|
|
956
|
-
|
|
839
|
+
logsConfig.errors && console.warn("Unrecognized rule", rule);
|
|
957
840
|
return false;
|
|
958
841
|
}
|
|
959
842
|
const all = await Promise.all(results);
|
|
@@ -965,10 +848,11 @@ var AutoConsentCMP = class extends AutoConsentCMPBase {
|
|
|
965
848
|
return detections.every((r) => !!r);
|
|
966
849
|
}
|
|
967
850
|
async _runRulesSequentially(rules) {
|
|
851
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
968
852
|
for (const rule of rules) {
|
|
969
|
-
|
|
853
|
+
logsConfig.rulesteps && console.log("Running rule...", rule);
|
|
970
854
|
const result = await this.evaluateRuleStep(rule);
|
|
971
|
-
|
|
855
|
+
logsConfig.rulesteps && console.log("...rule result", result);
|
|
972
856
|
if (!result && !rule.optional) {
|
|
973
857
|
return false;
|
|
974
858
|
}
|
|
@@ -1042,6 +926,82 @@ var ConsentOMaticCMP = class {
|
|
|
1042
926
|
}
|
|
1043
927
|
};
|
|
1044
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
|
+
|
|
1045
1005
|
// lib/cmps/trustarc-top.ts
|
|
1046
1006
|
var cookieSettingsButton = "#truste-show-consent";
|
|
1047
1007
|
var shortcutOptOut = "#truste-consent-required";
|
|
@@ -1077,17 +1037,17 @@ var TrustArcTop = class extends AutoConsentCMPBase {
|
|
|
1077
1037
|
return false;
|
|
1078
1038
|
}
|
|
1079
1039
|
async detectCmp() {
|
|
1080
|
-
const result = elementExists(`${cookieSettingsButton},${bannerContainer}`);
|
|
1040
|
+
const result = this.elementExists(`${cookieSettingsButton},${bannerContainer}`);
|
|
1081
1041
|
if (result) {
|
|
1082
1042
|
this._shortcutButton = document.querySelector(shortcutOptOut);
|
|
1083
1043
|
}
|
|
1084
1044
|
return result;
|
|
1085
1045
|
}
|
|
1086
1046
|
async detectPopup() {
|
|
1087
|
-
return elementVisible(`${popupContent},${bannerOverlay},${bannerContainer}`, "all");
|
|
1047
|
+
return this.elementVisible(`${popupContent},${bannerOverlay},${bannerContainer}`, "all");
|
|
1088
1048
|
}
|
|
1089
1049
|
openFrame() {
|
|
1090
|
-
click(cookieSettingsButton);
|
|
1050
|
+
this.click(cookieSettingsButton);
|
|
1091
1051
|
}
|
|
1092
1052
|
async optOut() {
|
|
1093
1053
|
if (this._shortcutButton) {
|
|
@@ -1098,7 +1058,7 @@ var TrustArcTop = class extends AutoConsentCMPBase {
|
|
|
1098
1058
|
getStyleElement(),
|
|
1099
1059
|
`.truste_popframe, .truste_overlay, .truste_box_overlay, ${bannerContainer}`
|
|
1100
1060
|
);
|
|
1101
|
-
click(cookieSettingsButton);
|
|
1061
|
+
this.click(cookieSettingsButton);
|
|
1102
1062
|
setTimeout(() => {
|
|
1103
1063
|
getStyleElement().remove();
|
|
1104
1064
|
}, 1e4);
|
|
@@ -1106,7 +1066,7 @@ var TrustArcTop = class extends AutoConsentCMPBase {
|
|
|
1106
1066
|
}
|
|
1107
1067
|
async optIn() {
|
|
1108
1068
|
this._optInDone = true;
|
|
1109
|
-
return click(shortcutOptIn);
|
|
1069
|
+
return this.click(shortcutOptIn);
|
|
1110
1070
|
}
|
|
1111
1071
|
async openCmp() {
|
|
1112
1072
|
return true;
|
|
@@ -1140,62 +1100,62 @@ var TrustArcFrame = class extends AutoConsentCMPBase {
|
|
|
1140
1100
|
return true;
|
|
1141
1101
|
}
|
|
1142
1102
|
async detectPopup() {
|
|
1143
|
-
return elementVisible("#defaultpreferencemanager", "any") && elementVisible(".mainContent", "any");
|
|
1103
|
+
return this.elementVisible("#defaultpreferencemanager", "any") && this.elementVisible(".mainContent", "any");
|
|
1144
1104
|
}
|
|
1145
1105
|
async navigateToSettings() {
|
|
1146
1106
|
await waitFor(
|
|
1147
1107
|
async () => {
|
|
1148
|
-
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");
|
|
1149
1109
|
},
|
|
1150
1110
|
10,
|
|
1151
1111
|
500
|
|
1152
1112
|
);
|
|
1153
|
-
if (elementExists(".shp")) {
|
|
1154
|
-
click(".shp");
|
|
1113
|
+
if (this.elementExists(".shp")) {
|
|
1114
|
+
this.click(".shp");
|
|
1155
1115
|
}
|
|
1156
|
-
await waitForElement(".prefPanel", 5e3);
|
|
1157
|
-
if (elementVisible(".advance", "any")) {
|
|
1158
|
-
click(".advance");
|
|
1116
|
+
await this.waitForElement(".prefPanel", 5e3);
|
|
1117
|
+
if (this.elementVisible(".advance", "any")) {
|
|
1118
|
+
this.click(".advance");
|
|
1159
1119
|
}
|
|
1160
1120
|
return await waitFor(
|
|
1161
|
-
() => elementVisible(".switch span:first-child", "any"),
|
|
1121
|
+
() => this.elementVisible(".switch span:first-child", "any"),
|
|
1162
1122
|
5,
|
|
1163
1123
|
1e3
|
|
1164
1124
|
);
|
|
1165
1125
|
}
|
|
1166
1126
|
async optOut() {
|
|
1167
1127
|
await waitFor(() => document.readyState === "complete", 20, 100);
|
|
1168
|
-
await waitForElement(".mainContent[aria-hidden=false]", 5e3);
|
|
1169
|
-
if (click(".rejectAll")) {
|
|
1128
|
+
await this.waitForElement(".mainContent[aria-hidden=false]", 5e3);
|
|
1129
|
+
if (this.click(".rejectAll")) {
|
|
1170
1130
|
return true;
|
|
1171
1131
|
}
|
|
1172
|
-
if (elementExists(".prefPanel")) {
|
|
1173
|
-
await waitForElement('.prefPanel[style="visibility: visible;"]', 3e3);
|
|
1132
|
+
if (this.elementExists(".prefPanel")) {
|
|
1133
|
+
await this.waitForElement('.prefPanel[style="visibility: visible;"]', 3e3);
|
|
1174
1134
|
}
|
|
1175
|
-
if (click("#catDetails0")) {
|
|
1176
|
-
click(".submit");
|
|
1177
|
-
waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1135
|
+
if (this.click("#catDetails0")) {
|
|
1136
|
+
this.click(".submit");
|
|
1137
|
+
this.waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1178
1138
|
return true;
|
|
1179
1139
|
}
|
|
1180
|
-
if (click(".required")) {
|
|
1181
|
-
waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1140
|
+
if (this.click(".required")) {
|
|
1141
|
+
this.waitForThenClick("#gwt-debug-close_id", 5e3);
|
|
1182
1142
|
return true;
|
|
1183
1143
|
}
|
|
1184
1144
|
await this.navigateToSettings();
|
|
1185
|
-
click(".switch span:nth-child(1):not(.active)", true);
|
|
1186
|
-
click(".submit");
|
|
1187
|
-
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);
|
|
1188
1148
|
return true;
|
|
1189
1149
|
}
|
|
1190
1150
|
async optIn() {
|
|
1191
|
-
if (click(".call")) {
|
|
1151
|
+
if (this.click(".call")) {
|
|
1192
1152
|
return true;
|
|
1193
1153
|
}
|
|
1194
1154
|
await this.navigateToSettings();
|
|
1195
|
-
click(".switch span:nth-child(2)", true);
|
|
1196
|
-
click(".submit");
|
|
1197
|
-
waitForElement("#gwt-debug-close_id", 3e5).then(() => {
|
|
1198
|
-
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");
|
|
1199
1159
|
});
|
|
1200
1160
|
return true;
|
|
1201
1161
|
}
|
|
@@ -1224,23 +1184,23 @@ var Cookiebot = class extends AutoConsentCMPBase {
|
|
|
1224
1184
|
return this.mainWorldEval("EVAL_COOKIEBOT_2");
|
|
1225
1185
|
}
|
|
1226
1186
|
async optOut() {
|
|
1227
|
-
await wait(500);
|
|
1187
|
+
await this.wait(500);
|
|
1228
1188
|
let res = await this.mainWorldEval("EVAL_COOKIEBOT_3");
|
|
1229
|
-
await wait(500);
|
|
1189
|
+
await this.wait(500);
|
|
1230
1190
|
res = res && await this.mainWorldEval("EVAL_COOKIEBOT_4");
|
|
1231
1191
|
return res;
|
|
1232
1192
|
}
|
|
1233
1193
|
async optIn() {
|
|
1234
|
-
if (elementExists("#dtcookie-container")) {
|
|
1235
|
-
return click(".h-dtcookie-accept");
|
|
1194
|
+
if (this.elementExists("#dtcookie-container")) {
|
|
1195
|
+
return this.click(".h-dtcookie-accept");
|
|
1236
1196
|
}
|
|
1237
|
-
click(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled", true);
|
|
1238
|
-
click("#CybotCookiebotDialogBodyLevelButtonAccept");
|
|
1239
|
-
click("#CybotCookiebotDialogBodyButtonAccept");
|
|
1197
|
+
this.click(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled", true);
|
|
1198
|
+
this.click("#CybotCookiebotDialogBodyLevelButtonAccept");
|
|
1199
|
+
this.click("#CybotCookiebotDialogBodyButtonAccept");
|
|
1240
1200
|
return true;
|
|
1241
1201
|
}
|
|
1242
1202
|
async test() {
|
|
1243
|
-
await wait(500);
|
|
1203
|
+
await this.wait(500);
|
|
1244
1204
|
return await this.mainWorldEval("EVAL_COOKIEBOT_5");
|
|
1245
1205
|
}
|
|
1246
1206
|
};
|
|
@@ -1284,17 +1244,17 @@ var SourcePoint = class extends AutoConsentCMPBase {
|
|
|
1284
1244
|
return true;
|
|
1285
1245
|
}
|
|
1286
1246
|
if (this.ccpaPopup) {
|
|
1287
|
-
return await waitForElement(".priv-save-btn", 2e3);
|
|
1247
|
+
return await this.waitForElement(".priv-save-btn", 2e3);
|
|
1288
1248
|
}
|
|
1289
|
-
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);
|
|
1290
|
-
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");
|
|
1291
1251
|
}
|
|
1292
1252
|
async optIn() {
|
|
1293
|
-
await waitForElement(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL", 2e3);
|
|
1294
|
-
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")) {
|
|
1295
1255
|
return true;
|
|
1296
1256
|
}
|
|
1297
|
-
if (click(".sp_choice_type_ACCEPT_ALL")) {
|
|
1257
|
+
if (this.click(".sp_choice_type_ACCEPT_ALL")) {
|
|
1298
1258
|
return true;
|
|
1299
1259
|
}
|
|
1300
1260
|
return false;
|
|
@@ -1303,6 +1263,7 @@ var SourcePoint = class extends AutoConsentCMPBase {
|
|
|
1303
1263
|
return location.pathname === "/privacy-manager/index.html" || location.pathname === "/ccpa_pm/index.html";
|
|
1304
1264
|
}
|
|
1305
1265
|
async optOut() {
|
|
1266
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
1306
1267
|
if (this.ccpaPopup) {
|
|
1307
1268
|
const toggles = document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");
|
|
1308
1269
|
for (const t of toggles) {
|
|
@@ -1312,47 +1273,47 @@ var SourcePoint = class extends AutoConsentCMPBase {
|
|
|
1312
1273
|
for (const t of switches) {
|
|
1313
1274
|
t.click();
|
|
1314
1275
|
}
|
|
1315
|
-
return click(".priv-save-btn");
|
|
1276
|
+
return this.click(".priv-save-btn");
|
|
1316
1277
|
}
|
|
1317
1278
|
if (!this.isManagerOpen()) {
|
|
1318
|
-
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");
|
|
1319
1280
|
if (!actionable) {
|
|
1320
1281
|
return false;
|
|
1321
1282
|
}
|
|
1322
|
-
if (!elementExists(".sp_choice_type_12")) {
|
|
1323
|
-
return click(".sp_choice_type_13");
|
|
1283
|
+
if (!this.elementExists(".sp_choice_type_12")) {
|
|
1284
|
+
return this.click(".sp_choice_type_13");
|
|
1324
1285
|
}
|
|
1325
|
-
click(".sp_choice_type_12");
|
|
1286
|
+
this.click(".sp_choice_type_12");
|
|
1326
1287
|
await waitFor(
|
|
1327
1288
|
() => this.isManagerOpen(),
|
|
1328
1289
|
200,
|
|
1329
1290
|
100
|
|
1330
1291
|
);
|
|
1331
1292
|
}
|
|
1332
|
-
await waitForElement(".type-modal", 2e4);
|
|
1333
|
-
|
|
1293
|
+
await this.waitForElement(".type-modal", 2e4);
|
|
1294
|
+
this.waitForThenClick(".ccpa-stack .pm-switch[aria-checked=true] .slider", 500, true);
|
|
1334
1295
|
try {
|
|
1335
1296
|
const rejectSelector1 = ".sp_choice_type_REJECT_ALL";
|
|
1336
1297
|
const rejectSelector2 = ".reject-toggle";
|
|
1337
1298
|
const path = await Promise.race([
|
|
1338
|
-
waitForElement(rejectSelector1, 2e3).then((success) => success ? 0 : -1),
|
|
1339
|
-
waitForElement(rejectSelector2, 2e3).then((success) => success ? 1 : -1),
|
|
1340
|
-
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)
|
|
1341
1302
|
]);
|
|
1342
1303
|
if (path === 0) {
|
|
1343
|
-
await wait(1e3);
|
|
1344
|
-
return click(rejectSelector1);
|
|
1304
|
+
await this.wait(1e3);
|
|
1305
|
+
return this.click(rejectSelector1);
|
|
1345
1306
|
} else if (path === 1) {
|
|
1346
|
-
click(rejectSelector2);
|
|
1307
|
+
this.click(rejectSelector2);
|
|
1347
1308
|
} else if (path === 2) {
|
|
1348
|
-
await waitForElement(".pm-features", 1e4);
|
|
1349
|
-
click(".checked > span", true);
|
|
1350
|
-
click(".chevron");
|
|
1309
|
+
await this.waitForElement(".pm-features", 1e4);
|
|
1310
|
+
this.click(".checked > span", true);
|
|
1311
|
+
this.click(".chevron");
|
|
1351
1312
|
}
|
|
1352
1313
|
} catch (e) {
|
|
1353
|
-
|
|
1314
|
+
logsConfig.errors && console.warn(e);
|
|
1354
1315
|
}
|
|
1355
|
-
return click(".sp_choice_type_SAVE_AND_EXIT");
|
|
1316
|
+
return this.click(".sp_choice_type_SAVE_AND_EXIT");
|
|
1356
1317
|
}
|
|
1357
1318
|
};
|
|
1358
1319
|
|
|
@@ -1376,42 +1337,42 @@ var ConsentManager = class extends AutoConsentCMPBase {
|
|
|
1376
1337
|
async detectCmp() {
|
|
1377
1338
|
this.apiAvailable = await this.mainWorldEval("EVAL_CONSENTMANAGER_1");
|
|
1378
1339
|
if (!this.apiAvailable) {
|
|
1379
|
-
return elementExists("#cmpbox");
|
|
1340
|
+
return this.elementExists("#cmpbox");
|
|
1380
1341
|
} else {
|
|
1381
1342
|
return true;
|
|
1382
1343
|
}
|
|
1383
1344
|
}
|
|
1384
1345
|
async detectPopup() {
|
|
1385
1346
|
if (this.apiAvailable) {
|
|
1386
|
-
await wait(500);
|
|
1347
|
+
await this.wait(500);
|
|
1387
1348
|
return await this.mainWorldEval("EVAL_CONSENTMANAGER_2");
|
|
1388
1349
|
}
|
|
1389
|
-
return elementVisible("#cmpbox .cmpmore", "any");
|
|
1350
|
+
return this.elementVisible("#cmpbox .cmpmore", "any");
|
|
1390
1351
|
}
|
|
1391
1352
|
async optOut() {
|
|
1392
|
-
await wait(500);
|
|
1353
|
+
await this.wait(500);
|
|
1393
1354
|
if (this.apiAvailable) {
|
|
1394
1355
|
return await this.mainWorldEval("EVAL_CONSENTMANAGER_3");
|
|
1395
1356
|
}
|
|
1396
|
-
if (click(".cmpboxbtnno")) {
|
|
1357
|
+
if (this.click(".cmpboxbtnno")) {
|
|
1397
1358
|
return true;
|
|
1398
1359
|
}
|
|
1399
|
-
if (elementExists(".cmpwelcomeprpsbtn")) {
|
|
1400
|
-
click(".cmpwelcomeprpsbtn > a[aria-checked=true]", true);
|
|
1401
|
-
click(".cmpboxbtnsave");
|
|
1360
|
+
if (this.elementExists(".cmpwelcomeprpsbtn")) {
|
|
1361
|
+
this.click(".cmpwelcomeprpsbtn > a[aria-checked=true]", true);
|
|
1362
|
+
this.click(".cmpboxbtnsave");
|
|
1402
1363
|
return true;
|
|
1403
1364
|
}
|
|
1404
|
-
click(".cmpboxbtncustom");
|
|
1405
|
-
await waitForElement(".cmptblbox", 2e3);
|
|
1406
|
-
click(".cmptdchoice > a[aria-checked=true]", true);
|
|
1407
|
-
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");
|
|
1408
1369
|
return true;
|
|
1409
1370
|
}
|
|
1410
1371
|
async optIn() {
|
|
1411
1372
|
if (this.apiAvailable) {
|
|
1412
1373
|
return await this.mainWorldEval("EVAL_CONSENTMANAGER_4");
|
|
1413
1374
|
}
|
|
1414
|
-
return click(".cmpboxbtnyes");
|
|
1375
|
+
return this.click(".cmpboxbtnyes");
|
|
1415
1376
|
}
|
|
1416
1377
|
async test() {
|
|
1417
1378
|
if (this.apiAvailable) {
|
|
@@ -1436,23 +1397,23 @@ var Evidon = class extends AutoConsentCMPBase {
|
|
|
1436
1397
|
return false;
|
|
1437
1398
|
}
|
|
1438
1399
|
async detectCmp() {
|
|
1439
|
-
return elementExists("#_evidon_banner");
|
|
1400
|
+
return this.elementExists("#_evidon_banner");
|
|
1440
1401
|
}
|
|
1441
1402
|
async detectPopup() {
|
|
1442
|
-
return elementVisible("#_evidon_banner", "any");
|
|
1403
|
+
return this.elementVisible("#_evidon_banner", "any");
|
|
1443
1404
|
}
|
|
1444
1405
|
async optOut() {
|
|
1445
|
-
if (click("#_evidon-decline-button")) {
|
|
1406
|
+
if (this.click("#_evidon-decline-button")) {
|
|
1446
1407
|
return true;
|
|
1447
1408
|
}
|
|
1448
1409
|
hideElements(getStyleElement(), "#evidon-prefdiag-overlay,#evidon-prefdiag-background");
|
|
1449
|
-
click("#_evidon-option-button");
|
|
1450
|
-
await waitForElement("#evidon-prefdiag-overlay", 5e3);
|
|
1451
|
-
click("#evidon-prefdiag-decline");
|
|
1410
|
+
this.click("#_evidon-option-button");
|
|
1411
|
+
await this.waitForElement("#evidon-prefdiag-overlay", 5e3);
|
|
1412
|
+
this.click("#evidon-prefdiag-decline");
|
|
1452
1413
|
return true;
|
|
1453
1414
|
}
|
|
1454
1415
|
async optIn() {
|
|
1455
|
-
return click("#_evidon-accept-button");
|
|
1416
|
+
return this.click("#_evidon-accept-button");
|
|
1456
1417
|
}
|
|
1457
1418
|
};
|
|
1458
1419
|
|
|
@@ -1476,31 +1437,31 @@ var Onetrust = class extends AutoConsentCMPBase {
|
|
|
1476
1437
|
return false;
|
|
1477
1438
|
}
|
|
1478
1439
|
async detectCmp() {
|
|
1479
|
-
return elementExists("#onetrust-banner-sdk");
|
|
1440
|
+
return this.elementExists("#onetrust-banner-sdk");
|
|
1480
1441
|
}
|
|
1481
1442
|
async detectPopup() {
|
|
1482
|
-
return elementVisible("#onetrust-banner-sdk", "all");
|
|
1443
|
+
return this.elementVisible("#onetrust-banner-sdk", "all");
|
|
1483
1444
|
}
|
|
1484
1445
|
async optOut() {
|
|
1485
|
-
if (elementVisible("#onetrust-reject-all-handler,.js-reject-cookies", "any")) {
|
|
1486
|
-
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");
|
|
1487
1448
|
}
|
|
1488
|
-
if (elementExists("#onetrust-pc-btn-handler")) {
|
|
1489
|
-
click("#onetrust-pc-btn-handler");
|
|
1449
|
+
if (this.elementExists("#onetrust-pc-btn-handler")) {
|
|
1450
|
+
this.click("#onetrust-pc-btn-handler");
|
|
1490
1451
|
} else {
|
|
1491
|
-
click(".ot-sdk-show-settings,button.js-cookie-settings");
|
|
1492
|
-
}
|
|
1493
|
-
await waitForElement("#onetrust-consent-sdk", 2e3);
|
|
1494
|
-
await wait(1e3);
|
|
1495
|
-
click("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked", true);
|
|
1496
|
-
await wait(1e3);
|
|
1497
|
-
await waitForElement(".save-preference-btn-handler,.js-consent-save", 2e3);
|
|
1498
|
-
click(".save-preference-btn-handler,.js-consent-save");
|
|
1499
|
-
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");
|
|
1500
1461
|
return true;
|
|
1501
1462
|
}
|
|
1502
1463
|
async optIn() {
|
|
1503
|
-
return click("#onetrust-accept-btn-handler,.js-accept-cookies");
|
|
1464
|
+
return this.click("#onetrust-accept-btn-handler,.js-accept-cookies");
|
|
1504
1465
|
}
|
|
1505
1466
|
async test() {
|
|
1506
1467
|
return await waitFor(
|
|
@@ -1529,39 +1490,39 @@ var Klaro = class extends AutoConsentCMPBase {
|
|
|
1529
1490
|
return false;
|
|
1530
1491
|
}
|
|
1531
1492
|
async detectCmp() {
|
|
1532
|
-
if (elementExists(".klaro > .cookie-modal")) {
|
|
1493
|
+
if (this.elementExists(".klaro > .cookie-modal")) {
|
|
1533
1494
|
this.settingsOpen = true;
|
|
1534
1495
|
return true;
|
|
1535
1496
|
}
|
|
1536
|
-
return elementExists(".klaro > .cookie-notice");
|
|
1497
|
+
return this.elementExists(".klaro > .cookie-notice");
|
|
1537
1498
|
}
|
|
1538
1499
|
async detectPopup() {
|
|
1539
|
-
return elementVisible(".klaro > .cookie-notice,.klaro > .cookie-modal", "any");
|
|
1500
|
+
return this.elementVisible(".klaro > .cookie-notice,.klaro > .cookie-modal", "any");
|
|
1540
1501
|
}
|
|
1541
1502
|
async optOut() {
|
|
1542
|
-
if (click(".klaro .cn-decline")) {
|
|
1503
|
+
if (this.click(".klaro .cn-decline")) {
|
|
1543
1504
|
return true;
|
|
1544
1505
|
}
|
|
1545
1506
|
if (!this.settingsOpen) {
|
|
1546
|
-
click(".klaro .cn-learn-more");
|
|
1547
|
-
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);
|
|
1548
1509
|
this.settingsOpen = true;
|
|
1549
1510
|
}
|
|
1550
|
-
if (click(".klaro .cn-decline")) {
|
|
1511
|
+
if (this.click(".klaro .cn-decline")) {
|
|
1551
1512
|
return true;
|
|
1552
1513
|
}
|
|
1553
|
-
click(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)", true);
|
|
1554
|
-
return click(".cm-btn-accept");
|
|
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");
|
|
1555
1516
|
}
|
|
1556
1517
|
async optIn() {
|
|
1557
|
-
if (click(".klaro .cm-btn-accept-all")) {
|
|
1518
|
+
if (this.click(".klaro .cm-btn-accept-all")) {
|
|
1558
1519
|
return true;
|
|
1559
1520
|
}
|
|
1560
1521
|
if (this.settingsOpen) {
|
|
1561
|
-
click(".cm-purpose:not(.cm-toggle-all) > input.half-checked", true);
|
|
1562
|
-
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");
|
|
1563
1524
|
}
|
|
1564
|
-
return click(".klaro .cookie-notice .cm-btn-success");
|
|
1525
|
+
return this.click(".klaro .cookie-notice .cm-btn-success");
|
|
1565
1526
|
}
|
|
1566
1527
|
async test() {
|
|
1567
1528
|
return await this.mainWorldEval("EVAL_KLARO_1");
|
|
@@ -1587,21 +1548,21 @@ var Uniconsent = class extends AutoConsentCMPBase {
|
|
|
1587
1548
|
return false;
|
|
1588
1549
|
}
|
|
1589
1550
|
async detectCmp() {
|
|
1590
|
-
return elementExists(".unic .unic-box,.unic .unic-bar");
|
|
1551
|
+
return this.elementExists(".unic .unic-box,.unic .unic-bar");
|
|
1591
1552
|
}
|
|
1592
1553
|
async detectPopup() {
|
|
1593
|
-
return elementVisible(".unic .unic-box,.unic .unic-bar", "any");
|
|
1554
|
+
return this.elementVisible(".unic .unic-box,.unic .unic-bar", "any");
|
|
1594
1555
|
}
|
|
1595
1556
|
async optOut() {
|
|
1596
|
-
await waitForElement(".unic button", 1e3);
|
|
1557
|
+
await this.waitForElement(".unic button", 1e3);
|
|
1597
1558
|
document.querySelectorAll(".unic button").forEach((button) => {
|
|
1598
1559
|
const text = button.textContent;
|
|
1599
1560
|
if (text.includes("Manage Options") || text.includes("Optionen verwalten")) {
|
|
1600
1561
|
button.click();
|
|
1601
1562
|
}
|
|
1602
1563
|
});
|
|
1603
|
-
if (await waitForElement(".unic input[type=checkbox]", 1e3)) {
|
|
1604
|
-
await waitForElement(".unic button", 1e3);
|
|
1564
|
+
if (await this.waitForElement(".unic input[type=checkbox]", 1e3)) {
|
|
1565
|
+
await this.waitForElement(".unic button", 1e3);
|
|
1605
1566
|
document.querySelectorAll(".unic input[type=checkbox]").forEach((c) => {
|
|
1606
1567
|
if (c.checked) {
|
|
1607
1568
|
c.click();
|
|
@@ -1612,7 +1573,7 @@ var Uniconsent = class extends AutoConsentCMPBase {
|
|
|
1612
1573
|
for (const pattern of ["Confirm Choices", "Save Choices", "Auswahl speichern"]) {
|
|
1613
1574
|
if (text.includes(pattern)) {
|
|
1614
1575
|
b.click();
|
|
1615
|
-
await wait(500);
|
|
1576
|
+
await this.wait(500);
|
|
1616
1577
|
return true;
|
|
1617
1578
|
}
|
|
1618
1579
|
}
|
|
@@ -1621,11 +1582,11 @@ var Uniconsent = class extends AutoConsentCMPBase {
|
|
|
1621
1582
|
return false;
|
|
1622
1583
|
}
|
|
1623
1584
|
async optIn() {
|
|
1624
|
-
return
|
|
1585
|
+
return this.waitForThenClick(".unic #unic-agree");
|
|
1625
1586
|
}
|
|
1626
1587
|
async test() {
|
|
1627
|
-
await wait(1e3);
|
|
1628
|
-
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");
|
|
1629
1590
|
return !res;
|
|
1630
1591
|
}
|
|
1631
1592
|
};
|
|
@@ -1647,20 +1608,20 @@ var Conversant = class extends AutoConsentCMPBase {
|
|
|
1647
1608
|
return false;
|
|
1648
1609
|
}
|
|
1649
1610
|
async detectCmp() {
|
|
1650
|
-
return elementExists(".cmp-root .cmp-receptacle");
|
|
1611
|
+
return this.elementExists(".cmp-root .cmp-receptacle");
|
|
1651
1612
|
}
|
|
1652
1613
|
async detectPopup() {
|
|
1653
|
-
return elementVisible(".cmp-root .cmp-receptacle", "any");
|
|
1614
|
+
return this.elementVisible(".cmp-root .cmp-receptacle", "any");
|
|
1654
1615
|
}
|
|
1655
1616
|
async optOut() {
|
|
1656
|
-
if (!await
|
|
1617
|
+
if (!await this.waitForThenClick(".cmp-main-button:not(.cmp-main-button--primary)")) {
|
|
1657
1618
|
return false;
|
|
1658
1619
|
}
|
|
1659
|
-
if (!await waitForElement(".cmp-view-tab-tabs")) {
|
|
1620
|
+
if (!await this.waitForElement(".cmp-view-tab-tabs")) {
|
|
1660
1621
|
return false;
|
|
1661
1622
|
}
|
|
1662
|
-
await
|
|
1663
|
-
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");
|
|
1664
1625
|
for (const item of Array.from(document.querySelectorAll(".cmp-accordion-item"))) {
|
|
1665
1626
|
item.querySelector(".cmp-accordion-item-title").click();
|
|
1666
1627
|
await waitFor(() => !!item.querySelector(".cmp-accordion-item-content.cmp-active"), 10, 50);
|
|
@@ -1668,11 +1629,11 @@ var Conversant = class extends AutoConsentCMPBase {
|
|
|
1668
1629
|
content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((e) => e.click());
|
|
1669
1630
|
content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((e) => e.click());
|
|
1670
1631
|
}
|
|
1671
|
-
await click(".cmp-main-button:not(.cmp-main-button--primary)");
|
|
1632
|
+
await this.click(".cmp-main-button:not(.cmp-main-button--primary)");
|
|
1672
1633
|
return true;
|
|
1673
1634
|
}
|
|
1674
1635
|
async optIn() {
|
|
1675
|
-
return
|
|
1636
|
+
return this.waitForThenClick(".cmp-main-button.cmp-main-button--primary");
|
|
1676
1637
|
}
|
|
1677
1638
|
async test() {
|
|
1678
1639
|
return document.cookie.includes("cmp-data=0");
|
|
@@ -1705,31 +1666,33 @@ var Tiktok = class extends AutoConsentCMPBase {
|
|
|
1705
1666
|
return container.shadowRoot;
|
|
1706
1667
|
}
|
|
1707
1668
|
async detectCmp() {
|
|
1708
|
-
return elementExists("tiktok-cookie-banner");
|
|
1669
|
+
return this.elementExists("tiktok-cookie-banner");
|
|
1709
1670
|
}
|
|
1710
1671
|
async detectPopup() {
|
|
1711
1672
|
const banner = this.getShadowRoot().querySelector(".tiktok-cookie-banner");
|
|
1712
1673
|
return isElementVisible(banner);
|
|
1713
1674
|
}
|
|
1714
1675
|
async optOut() {
|
|
1676
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
1715
1677
|
const declineButton = this.getShadowRoot().querySelector(".button-wrapper button:first-child");
|
|
1716
1678
|
if (declineButton) {
|
|
1717
|
-
|
|
1679
|
+
logsConfig.rulesteps && console.log("[clicking]", declineButton);
|
|
1718
1680
|
declineButton.click();
|
|
1719
1681
|
return true;
|
|
1720
1682
|
} else {
|
|
1721
|
-
|
|
1683
|
+
logsConfig.errors && console.log("no decline button found");
|
|
1722
1684
|
return false;
|
|
1723
1685
|
}
|
|
1724
1686
|
}
|
|
1725
1687
|
async optIn() {
|
|
1688
|
+
const logsConfig = this.autoconsent.config.logs;
|
|
1726
1689
|
const acceptButton = this.getShadowRoot().querySelector(".button-wrapper button:last-child");
|
|
1727
1690
|
if (acceptButton) {
|
|
1728
|
-
|
|
1691
|
+
logsConfig.rulesteps && console.log("[clicking]", acceptButton);
|
|
1729
1692
|
acceptButton.click();
|
|
1730
1693
|
return true;
|
|
1731
1694
|
} else {
|
|
1732
|
-
|
|
1695
|
+
logsConfig.errors && console.log("no accept button found");
|
|
1733
1696
|
return false;
|
|
1734
1697
|
}
|
|
1735
1698
|
}
|
|
@@ -1765,21 +1728,21 @@ var Airbnb = class extends AutoConsentCMPBase {
|
|
|
1765
1728
|
return false;
|
|
1766
1729
|
}
|
|
1767
1730
|
async detectCmp() {
|
|
1768
|
-
return elementExists("div[data-testid=main-cookies-banner-container]");
|
|
1731
|
+
return this.elementExists("div[data-testid=main-cookies-banner-container]");
|
|
1769
1732
|
}
|
|
1770
1733
|
async detectPopup() {
|
|
1771
|
-
return elementVisible("div[data-testid=main-cookies-banner-container", "any");
|
|
1734
|
+
return this.elementVisible("div[data-testid=main-cookies-banner-container", "any");
|
|
1772
1735
|
}
|
|
1773
1736
|
async optOut() {
|
|
1774
|
-
await
|
|
1737
|
+
await this.waitForThenClick("div[data-testid=main-cookies-banner-container] button._snbhip0");
|
|
1775
1738
|
let check;
|
|
1776
1739
|
while (check = document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])")) {
|
|
1777
1740
|
check.click();
|
|
1778
1741
|
}
|
|
1779
|
-
return
|
|
1742
|
+
return this.waitForThenClick("button[data-testid=save-btn]");
|
|
1780
1743
|
}
|
|
1781
1744
|
async optIn() {
|
|
1782
|
-
return
|
|
1745
|
+
return this.waitForThenClick("div[data-testid=main-cookies-banner-container] button._148dgdpk");
|
|
1783
1746
|
}
|
|
1784
1747
|
async test() {
|
|
1785
1748
|
return await waitFor(
|
|
@@ -1806,6 +1769,134 @@ var dynamicCMPs = [
|
|
|
1806
1769
|
Airbnb
|
|
1807
1770
|
];
|
|
1808
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
|
+
|
|
1809
1900
|
// lib/web.ts
|
|
1810
1901
|
function filterCMPs(rules, config) {
|
|
1811
1902
|
return rules.filter((cmp) => {
|
|
@@ -1828,7 +1919,6 @@ var AutoConsent = class {
|
|
|
1828
1919
|
evalState.sendContentMessage = sendContentMessage;
|
|
1829
1920
|
this.sendContentMessage = sendContentMessage;
|
|
1830
1921
|
this.rules = [];
|
|
1831
|
-
enableLogs && console.log("autoconsent init", window.location.href);
|
|
1832
1922
|
this.updateState({ lifecycle: "loading" });
|
|
1833
1923
|
this.addDynamicRules();
|
|
1834
1924
|
if (config) {
|
|
@@ -1844,17 +1934,20 @@ var AutoConsent = class {
|
|
|
1844
1934
|
sendContentMessage(initMsg);
|
|
1845
1935
|
this.updateState({ lifecycle: "waitingForInitResponse" });
|
|
1846
1936
|
}
|
|
1937
|
+
this.domActions = new DomActions(this);
|
|
1847
1938
|
}
|
|
1848
1939
|
initialize(config, declarativeRules) {
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
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");
|
|
1852
1945
|
return;
|
|
1853
1946
|
}
|
|
1854
1947
|
if (declarativeRules) {
|
|
1855
1948
|
this.parseDeclarativeRules(declarativeRules);
|
|
1856
1949
|
}
|
|
1857
|
-
this.rules = filterCMPs(this.rules,
|
|
1950
|
+
this.rules = filterCMPs(this.rules, normalizedConfig);
|
|
1858
1951
|
if (config.enablePrehide) {
|
|
1859
1952
|
if (document.documentElement) {
|
|
1860
1953
|
this.prehideElements();
|
|
@@ -1905,12 +1998,13 @@ var AutoConsent = class {
|
|
|
1905
1998
|
}
|
|
1906
1999
|
}
|
|
1907
2000
|
async _start() {
|
|
1908
|
-
|
|
2001
|
+
const logsConfig = this.config.logs;
|
|
2002
|
+
logsConfig.lifecycle && console.log(`Detecting CMPs on ${window.location.href}`);
|
|
1909
2003
|
this.updateState({ lifecycle: "started" });
|
|
1910
2004
|
const foundCmps = await this.findCmp(this.config.detectRetries);
|
|
1911
2005
|
this.updateState({ detectedCmps: foundCmps.map((c) => c.name) });
|
|
1912
2006
|
if (foundCmps.length === 0) {
|
|
1913
|
-
|
|
2007
|
+
logsConfig.lifecycle && console.log("no CMP found", location.href);
|
|
1914
2008
|
if (this.config.enablePrehide) {
|
|
1915
2009
|
this.undoPrehide();
|
|
1916
2010
|
}
|
|
@@ -1923,7 +2017,7 @@ var AutoConsent = class {
|
|
|
1923
2017
|
foundPopups = await this.detectPopups(foundCmps.filter((r) => r.isCosmetic));
|
|
1924
2018
|
}
|
|
1925
2019
|
if (foundPopups.length === 0) {
|
|
1926
|
-
|
|
2020
|
+
logsConfig.lifecycle && console.log("no popup found");
|
|
1927
2021
|
if (this.config.enablePrehide) {
|
|
1928
2022
|
this.undoPrehide();
|
|
1929
2023
|
}
|
|
@@ -1938,7 +2032,7 @@ var AutoConsent = class {
|
|
|
1938
2032
|
msg: `Found multiple CMPs, check the detection rules.`,
|
|
1939
2033
|
cmps: foundPopups.map((cmp) => cmp.name)
|
|
1940
2034
|
};
|
|
1941
|
-
|
|
2035
|
+
logsConfig.errors && console.warn(errorDetails.msg, errorDetails.cmps);
|
|
1942
2036
|
this.sendContentMessage({
|
|
1943
2037
|
type: "autoconsentError",
|
|
1944
2038
|
details: errorDetails
|
|
@@ -1950,11 +2044,12 @@ var AutoConsent = class {
|
|
|
1950
2044
|
} else if (this.config.autoAction === "optIn") {
|
|
1951
2045
|
return await this.doOptIn();
|
|
1952
2046
|
} else {
|
|
1953
|
-
|
|
2047
|
+
logsConfig.lifecycle && console.log("waiting for opt-out signal...", location.href);
|
|
1954
2048
|
return true;
|
|
1955
2049
|
}
|
|
1956
2050
|
}
|
|
1957
2051
|
async findCmp(retries) {
|
|
2052
|
+
const logsConfig = this.config.logs;
|
|
1958
2053
|
this.updateState({ findCmpAttempts: this.state.findCmpAttempts + 1 });
|
|
1959
2054
|
const foundCMPs = [];
|
|
1960
2055
|
for (const cmp of this.rules) {
|
|
@@ -1964,7 +2059,7 @@ var AutoConsent = class {
|
|
|
1964
2059
|
}
|
|
1965
2060
|
const result = await cmp.detectCmp();
|
|
1966
2061
|
if (result) {
|
|
1967
|
-
|
|
2062
|
+
logsConfig.lifecycle && console.log(`Found CMP: ${cmp.name} ${window.location.href}`);
|
|
1968
2063
|
this.sendContentMessage({
|
|
1969
2064
|
type: "cmpDetected",
|
|
1970
2065
|
url: location.href,
|
|
@@ -1973,16 +2068,17 @@ var AutoConsent = class {
|
|
|
1973
2068
|
foundCMPs.push(cmp);
|
|
1974
2069
|
}
|
|
1975
2070
|
} catch (e) {
|
|
1976
|
-
|
|
2071
|
+
logsConfig.errors && console.warn(`error detecting ${cmp.name}`, e);
|
|
1977
2072
|
}
|
|
1978
2073
|
}
|
|
1979
2074
|
if (foundCMPs.length === 0 && retries > 0) {
|
|
1980
|
-
await wait(500);
|
|
2075
|
+
await this.domActions.wait(500);
|
|
1981
2076
|
return this.findCmp(retries - 1);
|
|
1982
2077
|
}
|
|
1983
2078
|
return foundCMPs;
|
|
1984
2079
|
}
|
|
1985
2080
|
async detectPopups(cmps) {
|
|
2081
|
+
const logsConfig = this.config.logs;
|
|
1986
2082
|
const result = [];
|
|
1987
2083
|
const popupLookups = cmps.map((cmp) => this.waitForPopup(cmp).then((isOpen) => {
|
|
1988
2084
|
if (isOpen) {
|
|
@@ -1995,22 +2091,23 @@ var AutoConsent = class {
|
|
|
1995
2091
|
result.push(cmp);
|
|
1996
2092
|
}
|
|
1997
2093
|
}).catch((e) => {
|
|
1998
|
-
|
|
2094
|
+
logsConfig.errors && console.warn(`error waiting for a popup for ${cmp.name}`, e);
|
|
1999
2095
|
return null;
|
|
2000
2096
|
}));
|
|
2001
2097
|
await Promise.all(popupLookups);
|
|
2002
2098
|
return result;
|
|
2003
2099
|
}
|
|
2004
2100
|
async doOptOut() {
|
|
2101
|
+
const logsConfig = this.config.logs;
|
|
2005
2102
|
this.updateState({ lifecycle: "runningOptOut" });
|
|
2006
2103
|
let optOutResult;
|
|
2007
2104
|
if (!this.foundCmp) {
|
|
2008
|
-
|
|
2105
|
+
logsConfig.errors && console.log("no CMP to opt out");
|
|
2009
2106
|
optOutResult = false;
|
|
2010
2107
|
} else {
|
|
2011
|
-
|
|
2108
|
+
logsConfig.lifecycle && console.log(`CMP ${this.foundCmp.name}: opt out on ${window.location.href}`);
|
|
2012
2109
|
optOutResult = await this.foundCmp.optOut();
|
|
2013
|
-
|
|
2110
|
+
logsConfig.lifecycle && console.log(`${this.foundCmp.name}: opt out result ${optOutResult}`);
|
|
2014
2111
|
}
|
|
2015
2112
|
if (this.config.enablePrehide) {
|
|
2016
2113
|
this.undoPrehide();
|
|
@@ -2036,15 +2133,16 @@ var AutoConsent = class {
|
|
|
2036
2133
|
return optOutResult;
|
|
2037
2134
|
}
|
|
2038
2135
|
async doOptIn() {
|
|
2136
|
+
const logsConfig = this.config.logs;
|
|
2039
2137
|
this.updateState({ lifecycle: "runningOptIn" });
|
|
2040
2138
|
let optInResult;
|
|
2041
2139
|
if (!this.foundCmp) {
|
|
2042
|
-
|
|
2140
|
+
logsConfig.errors && console.log("no CMP to opt in");
|
|
2043
2141
|
optInResult = false;
|
|
2044
2142
|
} else {
|
|
2045
|
-
|
|
2143
|
+
logsConfig.lifecycle && console.log(`CMP ${this.foundCmp.name}: opt in on ${window.location.href}`);
|
|
2046
2144
|
optInResult = await this.foundCmp.optIn();
|
|
2047
|
-
|
|
2145
|
+
logsConfig.lifecycle && console.log(`${this.foundCmp.name}: opt in result ${optInResult}`);
|
|
2048
2146
|
}
|
|
2049
2147
|
if (this.config.enablePrehide) {
|
|
2050
2148
|
this.undoPrehide();
|
|
@@ -2071,12 +2169,13 @@ var AutoConsent = class {
|
|
|
2071
2169
|
return optInResult;
|
|
2072
2170
|
}
|
|
2073
2171
|
async doSelfTest() {
|
|
2172
|
+
const logsConfig = this.config.logs;
|
|
2074
2173
|
let selfTestResult;
|
|
2075
2174
|
if (!this.foundCmp) {
|
|
2076
|
-
|
|
2175
|
+
logsConfig.errors && console.log("no CMP to self test");
|
|
2077
2176
|
selfTestResult = false;
|
|
2078
2177
|
} else {
|
|
2079
|
-
|
|
2178
|
+
logsConfig.lifecycle && console.log(`CMP ${this.foundCmp.name}: self-test on ${window.location.href}`);
|
|
2080
2179
|
selfTestResult = await this.foundCmp.test();
|
|
2081
2180
|
}
|
|
2082
2181
|
this.sendContentMessage({
|
|
@@ -2089,19 +2188,21 @@ var AutoConsent = class {
|
|
|
2089
2188
|
return selfTestResult;
|
|
2090
2189
|
}
|
|
2091
2190
|
async waitForPopup(cmp, retries = 5, interval = 500) {
|
|
2092
|
-
|
|
2191
|
+
const logsConfig = this.config.logs;
|
|
2192
|
+
logsConfig.lifecycle && console.log("checking if popup is open...", cmp.name);
|
|
2093
2193
|
const isOpen = await cmp.detectPopup().catch((e) => {
|
|
2094
|
-
|
|
2194
|
+
logsConfig.errors && console.warn(`error detecting popup for ${cmp.name}`, e);
|
|
2095
2195
|
return false;
|
|
2096
2196
|
});
|
|
2097
2197
|
if (!isOpen && retries > 0) {
|
|
2098
|
-
await wait(interval);
|
|
2198
|
+
await this.domActions.wait(interval);
|
|
2099
2199
|
return this.waitForPopup(cmp, retries - 1, interval);
|
|
2100
2200
|
}
|
|
2101
|
-
|
|
2201
|
+
logsConfig.lifecycle && console.log(cmp.name, `popup is ${isOpen ? "open" : "not open"}`);
|
|
2102
2202
|
return isOpen;
|
|
2103
2203
|
}
|
|
2104
2204
|
prehideElements() {
|
|
2205
|
+
const logsConfig = this.config.logs;
|
|
2105
2206
|
const globalHidden = [
|
|
2106
2207
|
"#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"
|
|
2107
2208
|
];
|
|
@@ -2114,15 +2215,15 @@ var AutoConsent = class {
|
|
|
2114
2215
|
this.updateState({ prehideOn: true });
|
|
2115
2216
|
setTimeout(() => {
|
|
2116
2217
|
if (this.config.enablePrehide && this.state.prehideOn && !["runningOptOut", "runningOptIn"].includes(this.state.lifecycle)) {
|
|
2117
|
-
|
|
2218
|
+
logsConfig.lifecycle && console.log("Process is taking too long, unhiding elements");
|
|
2118
2219
|
this.undoPrehide();
|
|
2119
2220
|
}
|
|
2120
2221
|
}, this.config.prehideTimeout || 2e3);
|
|
2121
|
-
return prehide(selectors.join(","));
|
|
2222
|
+
return this.domActions.prehide(selectors.join(","));
|
|
2122
2223
|
}
|
|
2123
2224
|
undoPrehide() {
|
|
2124
2225
|
this.updateState({ prehideOn: false });
|
|
2125
|
-
return undoPrehide();
|
|
2226
|
+
return this.domActions.undoPrehide();
|
|
2126
2227
|
}
|
|
2127
2228
|
updateState(change) {
|
|
2128
2229
|
Object.assign(this.state, change);
|
|
@@ -2135,7 +2236,8 @@ var AutoConsent = class {
|
|
|
2135
2236
|
});
|
|
2136
2237
|
}
|
|
2137
2238
|
async receiveMessageCallback(message) {
|
|
2138
|
-
|
|
2239
|
+
const logsConfig = this.config?.logs;
|
|
2240
|
+
if (logsConfig?.messages) {
|
|
2139
2241
|
console.log("received from background", message, window.location.href);
|
|
2140
2242
|
}
|
|
2141
2243
|
switch (message.type) {
|