From 0bd6797358c1aabf7647521712f8f17c476600a3 Mon Sep 17 00:00:00 2001 From: saturn Date: Sun, 14 Jul 2019 20:34:01 -0500 Subject: [PATCH] Do sticky killing in an idle callback --- src/contentScript.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/contentScript.js b/src/contentScript.js index 2f82677..604386c 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -99,9 +99,11 @@ function restoreScrollability() { */ function startConstantVigilance() { var observer = new MutationObserver((mutationsList, observer) => { - for (var mutation of mutationsList) { - killSticky(mutation.target); - } + window.requestIdleCallback(() => { + for (var mutation of mutationsList) { + killSticky(mutation.target); + } + }); }); console.log("Commencing vigilance for stickies!"); @@ -118,8 +120,10 @@ function startConstantVigilance() { function beginKillingStickies() { if (!window.AKS) window.AKS = { stickiesKilled: 0 }; - killSticky(); - startConstantVigilance(); + window.requestIdleCallback(() => { + killSticky(); + startConstantVigilance(); + }); } /******************/