Refactors badge.displayBrowserActionBadge
This commit is contained in:
parent
3d1dcd33d1
commit
b2e6d5bcae
3 changed files with 5 additions and 17 deletions
|
@ -10,14 +10,14 @@ const badge = {
|
|||
browser.browserAction.setTitle({ tabId, title: "Containers disabled in Private Browsing Mode" });
|
||||
},
|
||||
|
||||
async displayBrowserActionBadge() {
|
||||
async displayBrowserActionBadge(rgba_values,text) {
|
||||
const extensionInfo = await backgroundLogic.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"});
|
||||
browser.browserAction.setBadgeBackgroundColor({color: rgba_values});
|
||||
browser.browserAction.setBadgeText({text: text});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -176,9 +176,7 @@ const messageHandler = {
|
|||
storage.achievements.push({"name": "manyContainersOpened", "done": false});
|
||||
// use set and spread to create a unique array
|
||||
const achievements = [...new Set(storage.achievements)];
|
||||
browser.storage.local.set({achievements});
|
||||
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
|
||||
browser.browserAction.setBadgeText({text: "NEW"});
|
||||
badge.displayBrowserActionBadge("rgba(0,217,0,255)","NEW");
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -60,13 +60,6 @@ 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: [],
|
||||
|
@ -160,10 +153,7 @@ const Logic = {
|
|||
},
|
||||
|
||||
async clearBrowserActionBadge() {
|
||||
const extensionInfo = await getExtensionInfo();
|
||||
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
||||
browser.browserAction.setBadgeBackgroundColor({color: ""});
|
||||
browser.browserAction.setBadgeText({text: ""});
|
||||
background.badge.displayBrowserActionBadge("","");
|
||||
storage.browserActionBadgesClicked.push(extensionInfo.version);
|
||||
// use set and spread to create a unique array
|
||||
const browserActionBadgesClicked = [...new Set(storage.browserActionBadgesClicked)];
|
||||
|
|
Loading…
Add table
Reference in a new issue