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 {
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("<plaintext>");
}
notifyPage() || addEventListener("pageshow", notifyPage);
notifyPage();
addEventListener("pageshow", notifyPage);
}