Explorar el Código

Fixed bug with observed changes to specified element; version to 1.2.8

master
achmizs hace 6 años
padre
commit
a56cb18a89
Se han modificado 3 ficheros con 30 adiciones y 21 borrados
  1. 28
    19
      src/contentScript.js
  2. 1
    1
      src/platform/chrome/manifest.json
  3. 1
    1
      src/platform/firefox/manifest.json

+ 28
- 19
src/contentScript.js Ver fichero

@@ -54,32 +54,41 @@ 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) {
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.
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

+ 1
- 1
src/platform/chrome/manifest.json Ver fichero

@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "AlwaysKillSticky",
"version": "1.2.7",
"version": "1.2.8",
"description": "Get rid of sticky elements on websites - permanently!",
"author": "Said Achmiz",
"homepage_url": "https://git.sr.ht/~achmizs/AlwaysKillSticky.git",

+ 1
- 1
src/platform/firefox/manifest.json Ver fichero

@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "AlwaysKillSticky",
"version": "1.2.7",
"version": "1.2.8",
"description": "Get rid of sticky elements on websites - permanently!",
"author": "Said Achmiz",
"browser_specific_settings": {

Cargando…
Cancelar
Guardar