From 34709c9eab5cc4485463e94919e60732b66871fa Mon Sep 17 00:00:00 2001 From: Said Achmiz Date: Mon, 4 Feb 2019 01:29:08 -0500 Subject: [PATCH] Fixed bug with load event timing --- src/contentScript.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/contentScript.js b/src/contentScript.js index 22a729d..639f4f0 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -70,6 +70,7 @@ function startConstantVigilance() { } }); + console.log("Commencing vigilance for stickies!"); observer.observe(document.querySelector("html"), { attributes: true, childList: true, @@ -82,13 +83,16 @@ function startConstantVigilance() { /******************/ function initialize() { - chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], - (result) => { + chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => { let shouldKillSticky = checkForShouldKillSticky(result); updateIcon(shouldKillSticky); if (shouldKillSticky) { startConstantVigilance(); - window.onload = () => { + if (document.readyState == "loading") { + document.addEventListener("DOMContentLoaded", () => { + killSticky(); + }); + } else { killSticky(); } }