use texts.symbols to modify the extension icon

This commit is contained in:
buzz-lightsnack-2007 2024-04-28 14:21:43 +08:00
parent 007435683d
commit 2e9ddc7f0c

View file

@ -1,34 +1,22 @@
import BrowserIcon from '/scripts/GUI/extensionIcon.js';
import Image from '/scripts/mapping/image.js';
import Tabs from '/scripts/GUI/tabs.js';
import texts from "/scripts/mapping/read.js";
import {session} from '/scripts/secretariat.js';
class IconIndicator {
/*
Update the icon.
@param {string} state The state to update the icon to.
*/
static update(state = false) {
(Image.get(((state) ? `default` : 'disabled'))).then((ICON) => {
(Tabs.query(null, 0)).then((DATA) => {
BrowserIcon.set({"Icon": ICON});
});
})
}
/*
Indicate that the website is supported through icon change.
*/
static async enable() {
IconIndicator.update(true);
BrowserIcon.set({"BadgeText": await (new texts(`extensionIcon_website_loading`)).symbol});
}
/*
Indicate that the website isn't supported through icon change.
*/
static async disable() {
IconIndicator.update(false);
BrowserIcon.set({"BadgeText": await (new texts(`extensionIcon_website_unsupported`)).symbol});
}
}