From 5a53a9127f629e6546d55aa0d5d9b9972dcfe37f Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 22 Mar 2022 16:02:53 +0100 Subject: [PATCH] Fixed UI in private windows always inheriting the fallback browser color scheme until explicitly set (thanks @mumboking for report). --- src/common/themes.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/common/themes.js b/src/common/themes.js index 35b0852..5638d68 100644 --- a/src/common/themes.js +++ b/src/common/themes.js @@ -57,11 +57,6 @@ root.classList.add("__NoScript_Theme__"); const VINTAGE = "vintageTheme"; - (async () => { - const key = "vintageTheme"; - - - })(); let update = toTheme => { return root.dataset.theme = toTheme; @@ -98,16 +93,17 @@ } } else { if (localStorage) { - theme = localStorage.getItem("theme") || "auto"; + theme = localStorage.getItem("theme"); } if (!theme && browser && browser.storage) { if (document.readyState === "loading") { document.documentElement.style.visibility = "hidden"; } - return browser.storage.local.get(["theme"]).then(r => { - update(r.theme); + return browser.storage.local.get(["theme"]).then(({theme}) => { + update(theme); document.documentElement.style.visibility = ""; - return r.theme; + if (localStorage) localStorage.setItem("theme", theme) + return theme; }); } }