move all badge logic into WebExtension code
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const MAJOR_VERSIONS = ["2.3.0"];
|
||||
|
||||
const assignManager = {
|
||||
CLOSEABLE_WINDOWS: new Set([
|
||||
"about:startpage",
|
||||
@@ -467,14 +469,26 @@ browser.runtime.sendMessage({
|
||||
}
|
||||
}).catch(() => {});
|
||||
|
||||
browser.runtime.sendMessage({method: "checkForMajorUpgrade"}).then(upgrading=> {
|
||||
if (upgrading) {
|
||||
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
|
||||
browser.browserAction.setBadgeText({text: "NEW"});
|
||||
}
|
||||
}).catch((e) => { throw e;});
|
||||
|
||||
function disableAddon(tabId) {
|
||||
browser.browserAction.disable(tabId);
|
||||
browser.browserAction.setTitle({ tabId, title: "Containers disabled in Private Browsing Mode" });
|
||||
}
|
||||
|
||||
async function getExtensionInfo() {
|
||||
const manifestPath = browser.extension.getURL("manifest.json");
|
||||
const response = await fetch(manifestPath);
|
||||
const extensionInfo = await response.json();
|
||||
return extensionInfo;
|
||||
}
|
||||
|
||||
async function displayBrowserActionBadge() {
|
||||
const extensionInfo = await getExtensionInfo();
|
||||
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
||||
|
||||
if (MAJOR_VERSIONS.indexOf(extensionInfo.version) > -1 &&
|
||||
storage.browserActionBadgesClicked.indexOf(extensionInfo.version) < 0) {
|
||||
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
|
||||
browser.browserAction.setBadgeText({text: "NEW"});
|
||||
}
|
||||
}
|
||||
displayBrowserActionBadge();
|
||||
|
||||
Reference in New Issue
Block a user