From aafc0ac1fda5feb6a97a3ad7e9ceb031e86b8419 Mon Sep 17 00:00:00 2001 From: Fahad Bin Hussain Date: Wed, 19 Apr 2023 05:24:51 +0600 Subject: [PATCH] Update autoApply status and update toggle-auto-noranic command checked status accordingly --- src/background.js | 8 +++++++- src/popup/popup.js | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/background.js b/src/background.js index 8257dc8..1ece296 100644 --- a/src/background.js +++ b/src/background.js @@ -35,7 +35,13 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => { chrome.commands.onCommand.addListener(async (command) => { if (command === "toggle-auto-noranic") { chrome.storage.sync.get(["autoApply"], (data) => { - chrome.storage.sync.set({ autoApply: !data.autoApply }); + let autoApply = !data.autoApply; + chrome.storage.sync.set({ autoApply: autoApply }, () => { + chrome.commands.update({ + name: "toggle-auto-noranic", + checked: autoApply, + }); + }); }); } if (command === "toggle-noranic") { diff --git a/src/popup/popup.js b/src/popup/popup.js index 471da14..e359b10 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -87,6 +87,10 @@ autoButton.addEventListener("click", async () => { }); }); +chrome.storage.sync.get("autoApply", (data) => { + updateAutoApplyText(data.autoApply); +}); + function onHighlightInputChange() { let fontWeightValue = highlightSheetInput.value; let highlightSheetValue = `font-weight: ${fontWeightValue};`;