From 4f07cb5b5d9b5b5ca8f3d51d7a6e7967388b80d0 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 12 May 2024 19:30:45 +0800 Subject: [PATCH] remind the user to restart the browser when disabling icon show --- _locales/en/messages.json | 7 +++++++ scripts/pages/settings.js | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index be93788..5762a8b 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -189,6 +189,13 @@ "settings_filters_target": { "message": "Injection Target" }, + "settings_restartToApply": { + "message": "Restart the extension or the browser to apply the changes." + }, + "settings_restartToApply_iconChange": { + "message": "The icon change doesn't happen automatically." + }, + "saving_current": { "message": "Saving…" }, diff --git a/scripts/pages/settings.js b/scripts/pages/settings.js index 77a77be..2c4cf52 100644 --- a/scripts/pages/settings.js +++ b/scripts/pages/settings.js @@ -86,10 +86,19 @@ class Page_Settings extends Page { }); } - if (document.querySelector(`[data-action="storage,clear"]`)) { - document - .querySelector(`[data-action="storage,clear"]`) - .addEventListener(`click`, async () => { + // The extension icon cache doesn't clear by itself. + (document.querySelector(`[data-store="settings,general,showApplicable"]`)) + ? document.querySelectorAll(`[data-store="settings,general,showApplicable"]`).forEach((ELEMENT) => { + ELEMENT.addEventListener(`change`, () => { + !(ELEMENT.checked) + ? new logging(texts.localized(`settings_restartToApply`), texts.localized(`settings_restartToApply_iconChange`), true) + : false; + }) + }) + : false; + + (document.querySelector(`[data-action="storage,clear"]`)) + ? document.querySelector(`[data-action="storage,clear"]`).addEventListener(`click`, async () => { await global.forget(`sites`); console.log(await global.read(null, 1), await global.read(null, -1)); });