Compare commits
No commits in common. "68884dcd031edf5ee42d31befb7017b0939d998d" and "deb03b4cdcd9e0296ea3e038aada8d76fe82c37e" have entirely different histories.
68884dcd03
...
deb03b4cdc
@ -17,7 +17,6 @@
|
||||
zero exclusion matters match the URL of the current page)
|
||||
*/
|
||||
function checkForShouldKillSticky(result) {
|
||||
// console.log("checkForShouldKillSticky");
|
||||
var shouldKillSticky = false;
|
||||
|
||||
/* If whitelist mode is active, then the matching patterns list is treated
|
||||
@ -55,25 +54,13 @@ function checkForShouldKillSticky(result) {
|
||||
|
||||
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
/* 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) {
|
||||
// console.log("killSticky");
|
||||
root = root || document.querySelector("body");
|
||||
if (killStickyIfNeeded(root) == false) {
|
||||
root.querySelectorAll('*').forEach(element => {
|
||||
killStickyIfNeeded(element)
|
||||
});
|
||||
}
|
||||
|
||||
// Compensate for full-screen paywalls.
|
||||
restoreScrollability();
|
||||
}
|
||||
|
||||
function killStickyIfNeeded(element) {
|
||||
// console.log("killStickyIfNeeded");
|
||||
var position = getComputedStyle(element).position;
|
||||
let position = getComputedStyle(element).position;
|
||||
if (position === 'fixed' || position === 'sticky') {
|
||||
// uBlock exception.
|
||||
if (element.tagName == "IFRAME" &&
|
||||
@ -85,61 +72,13 @@ function killStickyIfNeeded(element) {
|
||||
element.remove();
|
||||
|
||||
// Increment the stickies killed count, and update icon badge.
|
||||
incrementKilledStickiesCount();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
var didKillSticky = false;
|
||||
|
||||
// The ::before pseudo-element might be sticky on its own.
|
||||
position = getComputedStyle(element, "::before").position;
|
||||
if (position === 'fixed' || position === 'sticky') {
|
||||
// Kill the sticky.
|
||||
console.log("Killing sticky!");
|
||||
killStickyPseudoElement(element, true);
|
||||
|
||||
// Increment the stickies killed count, and update icon badge.
|
||||
incrementKilledStickiesCount();
|
||||
|
||||
didKillSticky = true;
|
||||
}
|
||||
|
||||
// The ::after pseudo-element, too, might be sticky on its own.
|
||||
position = getComputedStyle(element, "::after").position;
|
||||
if (position === 'fixed' || position === 'sticky') {
|
||||
// Kill the sticky.
|
||||
console.log("Killing sticky!");
|
||||
killStickyPseudoElement(element, false);
|
||||
|
||||
// Increment the stickies killed count, and update icon badge.
|
||||
incrementKilledStickiesCount();
|
||||
|
||||
didKillSticky = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function killStickyPseudoElement(element, before) {
|
||||
// console.log("killStickyPseudoElement");
|
||||
if (!AKS.pseudoElementKillingStyleBlock) {
|
||||
document.querySelector("head").insertAdjacentHTML("beforeend", "<style id='always-kill-sticky'></style>");
|
||||
AKS.pseudoElementKillingStyleBlock = document.querySelector("style#always-kill-sticky");
|
||||
}
|
||||
|
||||
var id = element.id;
|
||||
if (id == "")
|
||||
element.id = "always-kill-sticky-killed-element-" + (++AKS.stickyElementIDs);
|
||||
|
||||
let selector = `${element.tagName}#${element.id}::${(before ? 'before' : 'after')}`;
|
||||
AKS.pseudoElementKillingStyleBlock.innerHTML = AKS.pseudoElementKillingStyleBlock.innerHTML + `${selector} { content: none; }\n`;
|
||||
}
|
||||
|
||||
function incrementKilledStickiesCount() {
|
||||
// console.log("incrementKilledStickiesCount");
|
||||
AKS.stickiesKilled++;
|
||||
chrome.runtime.sendMessage({ newBadgeText: "" + AKS.stickiesKilled });
|
||||
}
|
||||
});
|
||||
|
||||
// Compensate for full-screen paywalls.
|
||||
restoreScrollability();
|
||||
}
|
||||
|
||||
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
@ -147,7 +86,6 @@ function incrementKilledStickiesCount() {
|
||||
the page un-scrollable. This ensures that the page remains scrollable.
|
||||
*/
|
||||
function restoreScrollability() {
|
||||
// console.log("restoreScrollability");
|
||||
document.querySelectorAll("html, body").forEach(container => {
|
||||
container.style.setProperty("overflow-y", "auto", "important");
|
||||
});
|
||||
@ -160,7 +98,6 @@ function restoreScrollability() {
|
||||
necessary, killing any newly-formed stickies.
|
||||
*/
|
||||
function startConstantVigilance() {
|
||||
// console.log("startConstantVigilance");
|
||||
var observer = new MutationObserver((mutationsList, observer) => {
|
||||
window.requestIdleCallback(() => {
|
||||
for (var mutation of mutationsList) {
|
||||
@ -181,7 +118,6 @@ function startConstantVigilance() {
|
||||
/* Immediately kill all stickies, then commence constant vigilance.
|
||||
*/
|
||||
function beginKillingStickies() {
|
||||
// console.log("beginKillingStickies");
|
||||
if (!window.AKS) window.AKS = { stickiesKilled: 0 };
|
||||
|
||||
window.requestIdleCallback(() => {
|
||||
@ -195,7 +131,6 @@ function beginKillingStickies() {
|
||||
/******************/
|
||||
|
||||
function initialize() {
|
||||
// console.log("initialize");
|
||||
chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
let shouldKillSticky = checkForShouldKillSticky(result);
|
||||
updateIcon(shouldKillSticky);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "AlwaysKillSticky",
|
||||
"version": "1.2.9",
|
||||
"version": "1.2.7",
|
||||
"description": "Get rid of sticky elements on websites - permanently!",
|
||||
"author": "Said Achmiz",
|
||||
"homepage_url": "https://git.sr.ht/~achmizs/AlwaysKillSticky.git",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "AlwaysKillSticky",
|
||||
"version": "1.2.9",
|
||||
"version": "1.2.7",
|
||||
"description": "Get rid of sticky elements on websites - permanently!",
|
||||
"author": "Said Achmiz",
|
||||
"browser_specific_settings": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user