display percentage completion in the extension icon

This commit is contained in:
buzz-lightsnack-2007 2024-05-13 16:02:09 +08:00
parent 7d20170c25
commit b8c0bf39e9

View file

@ -39,13 +39,19 @@ class IconIndicator {
"BadgeBackgroundColor": ICON_COLORS[`error`] "BadgeBackgroundColor": ICON_COLORS[`error`]
}, {"tabId": ID}) : false; }, {"tabId": ID}) : false;
if ((STATUS[`done`] && (typeof STATUS[`done`]).includes(`num`)) ? STATUS[`done`] >= 1 : false) { if (STATUS[`done`] && (typeof STATUS[`done`]).includes(`num`)) {
global.read([`sites`, LOCATION, `analysis`, `Rating`, `Trust`]).then(async (RESULTS) => { (STATUS[`done`] >= 1)
? global.read([`sites`, LOCATION, `analysis`, `Rating`, `Trust`]).then(async (RESULTS) => {
(RESULTS) ? BrowserIcon.set({ (RESULTS) ? BrowserIcon.set({
"BadgeText": await (new texts(`extensionIcon_product_`.concat(RESULTS))).symbol, "BadgeText": await (new texts(`extensionIcon_product_`.concat(RESULTS))).symbol,
"BadgeBackgroundColor": ICON_COLORS[`product_`.concat(RESULTS)] "BadgeBackgroundColor": ICON_COLORS[`product_`.concat(RESULTS)]
}, {"tabId": ID}) : false; }, {"tabId": ID}) : false;
}) })
: ((STATUS[`done`] > 0)
? BrowserIcon.set({
"BadgeText": String(parseFloat(STATUS[`done`] * 100)).concat(`%`),
"BadgeBackgroundColor": ICON_COLORS[`loading`]})
: false);
}; };
}; };
}); });