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" });
|
browser.browserAction.setTitle({ tabId, title: "Containers disabled in Private Browsing Mode" });
|
||||||
},
|
},
|
||||||
|
|
||||||
async displayBrowserActionBadge() {
|
async displayBrowserActionBadge(rgba_values,text) {
|
||||||
const extensionInfo = await backgroundLogic.getExtensionInfo();
|
const extensionInfo = await backgroundLogic.getExtensionInfo();
|
||||||
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
||||||
|
|
||||||
if (MAJOR_VERSIONS.indexOf(extensionInfo.version) > -1 &&
|
if (MAJOR_VERSIONS.indexOf(extensionInfo.version) > -1 &&
|
||||||
storage.browserActionBadgesClicked.indexOf(extensionInfo.version) < 0) {
|
storage.browserActionBadgesClicked.indexOf(extensionInfo.version) < 0) {
|
||||||
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
|
browser.browserAction.setBadgeBackgroundColor({color: rgba_values});
|
||||||
browser.browserAction.setBadgeText({text: "NEW"});
|
browser.browserAction.setBadgeText({text: text});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -176,9 +176,7 @@ const messageHandler = {
|
||||||
storage.achievements.push({"name": "manyContainersOpened", "done": false});
|
storage.achievements.push({"name": "manyContainersOpened", "done": false});
|
||||||
// use set and spread to create a unique array
|
// use set and spread to create a unique array
|
||||||
const achievements = [...new Set(storage.achievements)];
|
const achievements = [...new Set(storage.achievements)];
|
||||||
browser.storage.local.set({achievements});
|
badge.displayBrowserActionBadge("rgba(0,217,0,255)","NEW");
|
||||||
browser.browserAction.setBadgeBackgroundColor({color: "rgba(0,217,0,255)"});
|
|
||||||
browser.browserAction.setBadgeText({text: "NEW"});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -60,13 +60,6 @@ function escaped(strings, ...values) {
|
||||||
return result.join("");
|
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.
|
// This object controls all the panels, identities and many other things.
|
||||||
const Logic = {
|
const Logic = {
|
||||||
_identities: [],
|
_identities: [],
|
||||||
|
@ -160,10 +153,7 @@ const Logic = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async clearBrowserActionBadge() {
|
async clearBrowserActionBadge() {
|
||||||
const extensionInfo = await getExtensionInfo();
|
background.badge.displayBrowserActionBadge("","");
|
||||||
const storage = await browser.storage.local.get({browserActionBadgesClicked: []});
|
|
||||||
browser.browserAction.setBadgeBackgroundColor({color: ""});
|
|
||||||
browser.browserAction.setBadgeText({text: ""});
|
|
||||||
storage.browserActionBadgesClicked.push(extensionInfo.version);
|
storage.browserActionBadgesClicked.push(extensionInfo.version);
|
||||||
// use set and spread to create a unique array
|
// use set and spread to create a unique array
|
||||||
const browserActionBadgesClicked = [...new Set(storage.browserActionBadgesClicked)];
|
const browserActionBadgesClicked = [...new Set(storage.browserActionBadgesClicked)];
|
||||||
|
|
Loading…
Add table
Reference in a new issue