From b939c69eeaedff428a0ec1a1816895f7ef4fe87e Mon Sep 17 00:00:00 2001 From: hayao Date: Sun, 15 Oct 2023 03:51:57 +0900 Subject: [PATCH] Fix: Set extension badge --- src/scripts/background.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/scripts/background.ts b/src/scripts/background.ts index 3806fcf..9991c8b 100644 --- a/src/scripts/background.ts +++ b/src/scripts/background.ts @@ -15,3 +15,9 @@ chrome.action.onClicked.addListener(async (tab) => { if (tab.id === undefined) return; chrome.tabs.sendMessage(tab.id, "reload").catch((e) => console.error(e)); }); + +chrome.runtime.onStartup.addListener(async () => { + const isEnable = await getIsEnabled(); + chrome.action.setBadgeText({ text: isEnable ? "ON" : "OFF" }); + console.log("enabled:", isEnable); +});