Compare commits

..

3 Commits

Author SHA1 Message Date
achmizs
c98ca80bbf Incremented version to 1.3.1 2020-01-17 21:46:06 -05:00
saturn
0b3b0a2c58 Added timeouts to requestIdleCallbacks to deal with sites that run JS continuously 2020-01-17 19:51:13 -06:00
saturn
36951432cf Added workaround for Firefox performance bug 2020-01-17 19:19:13 -06:00
3 changed files with 23 additions and 13 deletions

View File

@ -166,20 +166,30 @@ function restoreScrollability() {
*/ */
function startConstantVigilance() { function startConstantVigilance() {
// console.log("startConstantVigilance"); // console.log("startConstantVigilance");
var observer = new MutationObserver((mutationsList, observer) => { var observer;
window.requestIdleCallback(() => { var starter = function() {
for (var mutation of mutationsList) { observer.observe(document.querySelector("html"), {
killSticky(mutation.target); attributes: true,
} childList: true,
subtree: true
}); });
};
observer = new MutationObserver((mutationsList, observer) => {
// Workaround for Firefox performance bug. Firefox does not properly
// coalesce mutations into the mutationsList, instead calling the
// callback potentially thousands of times. Therefore we must
// disconnect the observer, wait for the main thread to become idle,
// and then restart it.
observer.disconnect();
window.requestIdleCallback(() => {
killSticky();
starter();
}, {timeout: 1000});
}); });
console.log("Commencing vigilance for stickies!"); console.log("Commencing vigilance for stickies!");
observer.observe(document.querySelector("html"), { starter();
attributes: true,
childList: true,
subtree: true
});
} }
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
@ -192,7 +202,7 @@ function beginKillingStickies() {
window.requestIdleCallback(() => { window.requestIdleCallback(() => {
killSticky(); killSticky();
startConstantVigilance(); startConstantVigilance();
}); }, {timeout: 1000});
} }
/******************/ /******************/

View File

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

View File

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