From 093511e738acb5c1a2a07684be562b79a6dc5636 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:00:36 +0800 Subject: [PATCH] add function to pass the creation of the callback made in EntryManager --- scripts/GUI/entrypoints/icons.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/scripts/GUI/entrypoints/icons.js b/scripts/GUI/entrypoints/icons.js index bff4f24..9445e66 100644 --- a/scripts/GUI/entrypoints/icons.js +++ b/scripts/GUI/entrypoints/icons.js @@ -4,19 +4,42 @@ import Tabs from '/scripts/GUI/tabs.js'; import texts from "/scripts/mapping/read.js"; import {session} from '/scripts/secretariat.js'; +const CONFIG = chrome.runtime.getURL("styles/colors/icon.json"); + class IconIndicator { /* Indicate that the website is supported through icon change. */ - static async enable() { - BrowserIcon.set({"BadgeText": await (new texts(`extensionIcon_website_loading`)).symbol}); + static enable() { + BrowserIcon.enable(); + (Tabs.query(null, 0)).then(async (TAB) => { + BrowserIcon.set({ + "BadgeText": await (new texts(`extensionIcon_website_loading`)).symbol, + "BadgeBackgroundColor": await fetch(CONFIG).then((response) => response.json()).then((jsonData) => {return (jsonData[`loading`]);}) + }, {"tabId": TAB.id}); + }) } /* Indicate that the website isn't supported through icon change. */ static async disable() { - BrowserIcon.set({"BadgeText": await (new texts(`extensionIcon_website_unsupported`)).symbol}); + BrowserIcon.disable(); + (Tabs.query(null, 0)).then(async (TAB) => { + BrowserIcon.set({ + "BadgeText": await (new texts(`extensionIcon_website_unsupported`)).symbol, + "BadgeBackgroundColor": await fetch(CONFIG).then((response) => response.json()).then((jsonData) => {return (jsonData[`N/A`]);}) + }, {"tabId": TAB.id}); + }) + } + + /* + Set the function. + + @param {function} callback the function to run. + */ + static set(callback) { + BrowserIcon.addEventListener("onClicked", callback); } }