From 2ecd4edcb7df6c145f896a73f53d5dabb3a2e531 Mon Sep 17 00:00:00 2001 From: achmizs <1874748+achmizs@users.noreply.github.com> Date: Mon, 6 Jan 2020 23:48:37 -0500 Subject: [PATCH] Added support for killing stickies within shadow DOMs --- src/contentScript.js | 17 +++++++++++------ src/platform/chrome/manifest.json | 2 +- src/platform/firefox/manifest.json | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/contentScript.js b/src/contentScript.js index e4b061a..0a3e34d 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -61,14 +61,19 @@ function checkForShouldKillSticky(result) { function killSticky(root) { // console.log("killSticky"); root = root || document.querySelector("body"); - if (killStickyIfNeeded(root) == false) { - root.querySelectorAll('*').forEach(element => { - killStickyIfNeeded(element) - }); - } + if (killStickyIfNeeded(root) == false) + killAllStickiesWithin(root); // Compensate for full-screen paywalls. - restoreScrollability(); + if (root == document.body) + restoreScrollability(); +} + +function killAllStickiesWithin(root) { + root.querySelectorAll('*').forEach(element => { + if (killStickyIfNeeded(element) == false && element.shadowRoot != null) + killAllStickiesWithin(element.shadowRoot); + }); } function killStickyIfNeeded(element) { diff --git a/src/platform/chrome/manifest.json b/src/platform/chrome/manifest.json index cdf0255..92dbcfa 100644 --- a/src/platform/chrome/manifest.json +++ b/src/platform/chrome/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "AlwaysKillSticky", - "version": "1.2.9", + "version": "1.3.0", "description": "Get rid of sticky elements on websites - permanently!", "author": "Said Achmiz", "homepage_url": "https://git.sr.ht/~achmizs/AlwaysKillSticky.git", diff --git a/src/platform/firefox/manifest.json b/src/platform/firefox/manifest.json index 4c63210..01e65f0 100644 --- a/src/platform/firefox/manifest.json +++ b/src/platform/firefox/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "AlwaysKillSticky", - "version": "1.2.9", + "version": "1.3.0", "description": "Get rid of sticky elements on websites - permanently!", "author": "Said Achmiz", "browser_specific_settings": {