Fixed browser action icon not being updated on BF cache navigation.

This commit is contained in:
hackademix 2018-07-28 12:50:30 +02:00
parent ce9644bed3
commit f82b1e376c
1 changed files with 10 additions and 4 deletions

View File

@ -78,10 +78,15 @@ if (document.readyState !== "complete") {
} else { } else {
init(true); init(true);
} }
let notifyPage = () => { let notifyPage = async () => {
debug("Page %s shown, %s", document.URL, document.readyState);
if (document.readyState === "complete") { if (document.readyState === "complete") {
browser.runtime.sendMessage({type: "pageshow", seen, canScript}); try {
return true; await browser.runtime.sendMessage({type: "pageshow", seen: seen.list, canScript});
return true;
} catch (e) {
debug(e);
}
} }
return false; return false;
} }
@ -166,5 +171,6 @@ async function init(oldPage = false) {
}, true); }, true);
// document.write("<plaintext>"); // document.write("<plaintext>");
} }
notifyPage() || addEventListener("pageshow", notifyPage); notifyPage();
addEventListener("pageshow", notifyPage);
} }