|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
|
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
|
|
/* This is the code that actually does the sticky killing! It simply selects |
|
|
/* This is the code that actually does the sticky killing! It simply selects |
|
|
all elements whose 'position' CSS property has a computed value of either |
|
|
|
|
|
'sticky' or 'fixed', and removes those elements. |
|
|
|
|
|
|
|
|
all elements whose ‘position’ CSS property has a computed value of either |
|
|
|
|
|
‘sticky’ or ‘fixed’, and removes those elements. |
|
|
*/ |
|
|
*/ |
|
|
function killSticky(root) { |
|
|
function killSticky(root) { |
|
|
root = root || document.querySelector("body"); |
|
|
root = root || document.querySelector("body"); |
|
|
root.querySelectorAll('*').forEach(element => { |
|
|
|
|
|
let position = getComputedStyle(element).position; |
|
|
|
|
|
if (position === 'fixed' || position === 'sticky') { |
|
|
|
|
|
// uBlock exception. |
|
|
|
|
|
if (element.tagName == "IFRAME" && |
|
|
|
|
|
element.parentElement.tagName == "HTML") |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// Kill the sticky. |
|
|
|
|
|
console.log("Killing sticky!"); |
|
|
|
|
|
element.remove(); |
|
|
|
|
|
|
|
|
|
|
|
// Increment the stickies killed count, and update icon badge. |
|
|
|
|
|
AKS.stickiesKilled++; |
|
|
|
|
|
chrome.runtime.sendMessage({ newBadgeText: "" + AKS.stickiesKilled }); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
if (killStickyIfNeeded(root) == false) { |
|
|
|
|
|
root.querySelectorAll('*').forEach(element => { |
|
|
|
|
|
killStickyIfNeeded(element) |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Compensate for full-screen paywalls. |
|
|
// Compensate for full-screen paywalls. |
|
|
restoreScrollability(); |
|
|
restoreScrollability(); |
|
|
} |
|
|
} |
|
|
|
|
|
function killStickyIfNeeded(element) { |
|
|
|
|
|
let position = getComputedStyle(element).position; |
|
|
|
|
|
if (position === 'fixed' || position === 'sticky') { |
|
|
|
|
|
// uBlock exception. |
|
|
|
|
|
if (element.tagName == "IFRAME" && |
|
|
|
|
|
element.parentElement.tagName == "HTML") |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// Kill the sticky. |
|
|
|
|
|
console.log("Killing sticky!"); |
|
|
|
|
|
element.remove(); |
|
|
|
|
|
|
|
|
|
|
|
// Increment the stickies killed count, and update icon badge. |
|
|
|
|
|
AKS.stickiesKilled++; |
|
|
|
|
|
chrome.runtime.sendMessage({ newBadgeText: "" + AKS.stickiesKilled }); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} else { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
|
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
|
|
/* Full-screen paywalls not only bring up sticky elements, they also make |
|
|
/* Full-screen paywalls not only bring up sticky elements, they also make |