move all badge logic into WebExtension code

This commit is contained in:
groovecoder
2017-05-16 12:20:10 -05:00
parent 3805f12e17
commit d8fd47a353
3 changed files with 36 additions and 14 deletions
+21 -7
View File
@@ -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();