diff --git a/index.js b/index.js index 43e1b13..ba8dacb 100644 --- a/index.js +++ b/index.js @@ -8,8 +8,6 @@ const DEFAULT_TAB = "about:newtab"; const SHOW_MENU_TIMEOUT = 100; const HIDE_MENU_TIMEOUT = 300; -const MAJOR_VERSIONS = ["2.2.1"]; - const INCOMPATIBLE_ADDON_IDS = [ "pulse@mozilla.com", "snoozetabs@mozilla.com", @@ -258,9 +256,6 @@ const ContainerService = { webExtension.startup().then(api => { api.browser.runtime.onMessage.addListener((message, sender, sendReply) => { - if (message.method === "checkForMajorUpgrade") { - sendReply(reason === "upgrade" && MAJOR_VERSIONS.indexOf(self.version) > -1); - } if ("method" in message && methods.indexOf(message.method) !== -1) { sendReply(this[message.method](message)); } diff --git a/webextension/background.js b/webextension/background.js index 4f547c5..d1036c0 100644 --- a/webextension/background.js +++ b/webextension/background.js @@ -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(); diff --git a/webextension/js/popup.js b/webextension/js/popup.js index a8fcf99..11e90ed 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -55,6 +55,13 @@ function escaped(strings, ...values) { return result.join(""); } +async function getExtensionInfo() { + const manifestPath = browser.extension.getURL("manifest.json"); + const response = await fetch(manifestPath); + const extensionInfo = await response.json(); + return extensionInfo; +} + // This object controls all the panels, identities and many other things. const Logic = { _identities: [], @@ -92,8 +99,14 @@ const Logic = { }, clearBrowserActionBadge() { - browser.browserAction.setBadgeBackgroundColor({color: ""}); - browser.browserAction.setBadgeText({text: ""}); + getExtensionInfo().then(extensionInfo=>{ + const storage = browser.storage.local.get({browserActionBadgesClicked: []}).then(storage=>{ + browser.browserAction.setBadgeBackgroundColor({color: ""}); + browser.browserAction.setBadgeText({text: ""}); + storage.browserActionBadgesClicked.push(extensionInfo.version); + browser.storage.local.set({browserActionBadgesClicked: storage.browserActionBadgesClicked}); + }); + }); }, refreshIdentities() {