@duckduckgo/autoconsent 16.42.0 → 16.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -410,6 +410,24 @@ var snippets = {
410
410
  });
411
411
  return true;
412
412
  },
413
+ EVAL_SOURCEPOINT_RESTORE_SCROLL: () => {
414
+ const root = document.documentElement;
415
+ const saved = root.dataset.previousScrollY;
416
+ if (saved && saved !== "null") {
417
+ root.dataset.previousScrollY = "null";
418
+ const y = -parseInt(saved, 10);
419
+ if (y > 0 && window.scrollY === 0) {
420
+ const behavior = root.style.scrollBehavior;
421
+ root.style.scrollBehavior = "auto";
422
+ window.scrollTo(0, y);
423
+ root.style.scrollBehavior = behavior;
424
+ }
425
+ }
426
+ window.addEventListener("pagehide", () => {
427
+ if (root.dataset.previousScrollY) root.dataset.previousScrollY = "null";
428
+ });
429
+ return true;
430
+ },
413
431
  EVAL_STEAMPOWERED_0: () => JSON.parse(
414
432
  decodeURIComponent(
415
433
  document.cookie.split(";").find((s) => s.trim().startsWith("cookieSettings")).split("=")[1]
@@ -2705,7 +2723,7 @@ var DomActions = class {
2705
2723
  if (selector.startsWith("xpath/")) {
2706
2724
  const xpath = selector.slice(6);
2707
2725
  const result = document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null);
2708
- let node = null;
2726
+ let node;
2709
2727
  const elements = [];
2710
2728
  while (node = result.iterateNext()) {
2711
2729
  elements.push(node);
@@ -380,6 +380,24 @@ var snippets = {
380
380
  });
381
381
  return true;
382
382
  },
383
+ EVAL_SOURCEPOINT_RESTORE_SCROLL: () => {
384
+ const root = document.documentElement;
385
+ const saved = root.dataset.previousScrollY;
386
+ if (saved && saved !== "null") {
387
+ root.dataset.previousScrollY = "null";
388
+ const y = -parseInt(saved, 10);
389
+ if (y > 0 && window.scrollY === 0) {
390
+ const behavior = root.style.scrollBehavior;
391
+ root.style.scrollBehavior = "auto";
392
+ window.scrollTo(0, y);
393
+ root.style.scrollBehavior = behavior;
394
+ }
395
+ }
396
+ window.addEventListener("pagehide", () => {
397
+ if (root.dataset.previousScrollY) root.dataset.previousScrollY = "null";
398
+ });
399
+ return true;
400
+ },
383
401
  EVAL_STEAMPOWERED_0: () => JSON.parse(
384
402
  decodeURIComponent(
385
403
  document.cookie.split(";").find((s) => s.trim().startsWith("cookieSettings")).split("=")[1]
@@ -2675,7 +2693,7 @@ var DomActions = class {
2675
2693
  if (selector.startsWith("xpath/")) {
2676
2694
  const xpath = selector.slice(6);
2677
2695
  const result = document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null);
2678
- let node = null;
2696
+ let node;
2679
2697
  const elements = [];
2680
2698
  while (node = result.iterateNext()) {
2681
2699
  elements.push(node);
@@ -382,6 +382,24 @@
382
382
  });
383
383
  return true;
384
384
  },
385
+ EVAL_SOURCEPOINT_RESTORE_SCROLL: () => {
386
+ const root = document.documentElement;
387
+ const saved = root.dataset.previousScrollY;
388
+ if (saved && saved !== "null") {
389
+ root.dataset.previousScrollY = "null";
390
+ const y = -parseInt(saved, 10);
391
+ if (y > 0 && window.scrollY === 0) {
392
+ const behavior = root.style.scrollBehavior;
393
+ root.style.scrollBehavior = "auto";
394
+ window.scrollTo(0, y);
395
+ root.style.scrollBehavior = behavior;
396
+ }
397
+ }
398
+ window.addEventListener("pagehide", () => {
399
+ if (root.dataset.previousScrollY) root.dataset.previousScrollY = "null";
400
+ });
401
+ return true;
402
+ },
385
403
  EVAL_STEAMPOWERED_0: () => JSON.parse(
386
404
  decodeURIComponent(
387
405
  document.cookie.split(";").find((s) => s.trim().startsWith("cookieSettings")).split("=")[1]
@@ -2677,7 +2695,7 @@
2677
2695
  if (selector.startsWith("xpath/")) {
2678
2696
  const xpath = selector.slice(6);
2679
2697
  const result = document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null);
2680
- let node = null;
2698
+ let node;
2681
2699
  const elements = [];
2682
2700
  while (node = result.iterateNext()) {
2683
2701
  elements.push(node);