Fixed element selection bug
This commit is contained in:
parent
e62ec717c8
commit
30036443b7
@ -59,14 +59,7 @@ function checkForShouldKillSticky(result) {
|
||||
function startConstantVigilance() {
|
||||
var observer = new MutationObserver((mutationsList, observer) => {
|
||||
for (var mutation of mutationsList) {
|
||||
if (getComputedStyle(mutation.target).position == 'fixed' ||
|
||||
getComputedStyle(mutation.target).position == 'sticky') {
|
||||
mutation.target.remove();
|
||||
console.log("Killing a sticky!");
|
||||
|
||||
// Compensate for fullscreen paywalls.
|
||||
restoreScrollability();
|
||||
}
|
||||
killSticky(mutation.target);
|
||||
}
|
||||
});
|
||||
|
||||
@ -87,13 +80,14 @@ function initialize() {
|
||||
let shouldKillSticky = checkForShouldKillSticky(result);
|
||||
updateIcon(shouldKillSticky);
|
||||
if (shouldKillSticky) {
|
||||
startConstantVigilance();
|
||||
if (document.readyState == "loading") {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
killSticky();
|
||||
});
|
||||
} else {
|
||||
function beginKillingStickies() {
|
||||
killSticky();
|
||||
startConstantVigilance();
|
||||
}
|
||||
if (document.readyState == "loading") {
|
||||
document.addEventListener("DOMContentLoaded", beginKillingStickies);
|
||||
} else {
|
||||
beginKillingStickies();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -46,14 +46,18 @@ function updateIcon(shouldKillSticky, tabID) {
|
||||
all elements whose 'position' CSS property has a computed value of either
|
||||
'sticky' or 'fixed', and removes those elements.
|
||||
*/
|
||||
function killSticky() {
|
||||
console.log("Killing all stickies!");
|
||||
document.querySelectorAll('body *').forEach(element => {
|
||||
function killSticky(root) {
|
||||
var message = root ? "Killing all stickies!" : "Killing more stickies!";
|
||||
console.log(message);
|
||||
|
||||
root = root || document.querySelector("body");
|
||||
root.querySelectorAll('*').forEach(element => {
|
||||
if (getComputedStyle(element).position === 'fixed' ||
|
||||
getComputedStyle(element).position === 'sticky') {
|
||||
element.remove();
|
||||
}
|
||||
});
|
||||
|
||||
// Compensate for full-screen paywalls.
|
||||
restoreScrollability();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user