From 6711ae5729cdd46ebb64bc03fa5f00f96c5e432b Mon Sep 17 00:00:00 2001 From: saturn Date: Sun, 14 Jul 2019 20:33:43 -0500 Subject: [PATCH] Optimize killSticky to only call getComputedStyle once per element --- src/contentScript.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/contentScript.js b/src/contentScript.js index de0c853..2f82677 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -60,8 +60,8 @@ function checkForShouldKillSticky(result) { function killSticky(root) { root = root || document.querySelector("body"); root.querySelectorAll('*').forEach(element => { - if (getComputedStyle(element).position === 'fixed' || - getComputedStyle(element).position === 'sticky') { + let position = getComputedStyle(element).position; + if (position === 'fixed' || position === 'sticky') { // uBlock exception. if (element.tagName == "IFRAME" && element.parentElement.tagName == "HTML") @@ -139,4 +139,4 @@ function initialize() { } }); } -initialize(); \ No newline at end of file +initialize();