From f82b1e376cf99154e7ecbeaa1b5837a59e3a6098 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sat, 28 Jul 2018 12:50:30 +0200 Subject: Fixed browser action icon not being updated on BF cache navigation. --- src/content/content.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/content/content.js b/src/content/content.js index 3560e57..9f89a65 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -78,10 +78,15 @@ if (document.readyState !== "complete") { } else { init(true); } -let notifyPage = () => { +let notifyPage = async () => { + debug("Page %s shown, %s", document.URL, document.readyState); if (document.readyState === "complete") { - browser.runtime.sendMessage({type: "pageshow", seen, canScript}); - return true; + try { + await browser.runtime.sendMessage({type: "pageshow", seen: seen.list, canScript}); + return true; + } catch (e) { + debug(e); + } } return false; } @@ -166,5 +171,6 @@ async function init(oldPage = false) { }, true); // document.write(""); } - notifyPage() || addEventListener("pageshow", notifyPage); + notifyPage(); + addEventListener("pageshow", notifyPage); } -- cgit v1.2.3