@duckduckgo/autoconsent 15.0.0 → 15.1.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.
@@ -441,6 +441,9 @@
441
441
  sendContentMessage: null
442
442
  };
443
443
  function requestEval(code, snippetId) {
444
+ if (!evalState.sendContentMessage) {
445
+ return Promise.reject(new Error("AutoConsent is not initialized yet"));
446
+ }
444
447
  const id = getRandomID();
445
448
  evalState.sendContentMessage({
446
449
  type: "eval",
@@ -743,12 +746,13 @@
743
746
  }
744
747
  }
745
748
  function highlightNode(node) {
749
+ const highlightedNode = node;
746
750
  if (!node.style) return;
747
- if (node.__oldStyles !== void 0) {
751
+ if (highlightedNode.__oldStyles !== void 0) {
748
752
  return;
749
753
  }
750
754
  if (node.hasAttribute("style")) {
751
- node.__oldStyles = node.style.cssText;
755
+ highlightedNode.__oldStyles = node.style.cssText;
752
756
  }
753
757
  node.style.animation = "pulsate .5s infinite";
754
758
  node.style.outline = "solid red";
@@ -776,10 +780,11 @@
776
780
  document.head.appendChild(styleTag);
777
781
  }
778
782
  function unhighlightNode(node) {
783
+ const highlightedNode = node;
779
784
  if (!node.style || !node.hasAttribute("style")) return;
780
- if (node.__oldStyles !== void 0) {
781
- node.style.cssText = node.__oldStyles;
782
- delete node.__oldStyles;
785
+ if (highlightedNode.__oldStyles !== void 0) {
786
+ node.style.cssText = highlightedNode.__oldStyles;
787
+ delete highlightedNode.__oldStyles;
783
788
  } else {
784
789
  node.removeAttribute("style");
785
790
  }
@@ -2825,7 +2830,7 @@
2825
2830
  async optOut() {
2826
2831
  await this.waitForElement(".unic button", 1e3);
2827
2832
  document.querySelectorAll(".unic button").forEach((button) => {
2828
- const text = button.textContent;
2833
+ const text = button.textContent || "";
2829
2834
  if (text.includes("Manage Options") || text.includes("Optionen verwalten")) {
2830
2835
  button.click();
2831
2836
  }
@@ -2838,7 +2843,7 @@
2838
2843
  }
2839
2844
  });
2840
2845
  for (const b of document.querySelectorAll(".unic button")) {
2841
- const text = b.textContent;
2846
+ const text = b.textContent || "";
2842
2847
  for (const pattern of ["Confirm Choices", "Save Choices", "Auswahl speichern"]) {
2843
2848
  if (text.includes(pattern)) {
2844
2849
  b.click();
@@ -2895,6 +2900,9 @@
2895
2900
  item.querySelector(".cmp-accordion-item-title").click();
2896
2901
  await waitFor(() => !!item.querySelector(".cmp-accordion-item-content.cmp-active"), 10, 50);
2897
2902
  const content = item.querySelector(".cmp-accordion-item-content.cmp-active");
2903
+ if (!content) {
2904
+ return false;
2905
+ }
2898
2906
  content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((e) => e.click());
2899
2907
  content.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((e) => e.click());
2900
2908
  }