Fixed UI in private windows always inheriting the fallback browser color scheme until explicitly set (thanks @mumboking for report).

This commit is contained in:
hackademix 2022-03-22 16:02:53 +01:00
parent eafa04772d
commit 5a53a9127f
1 changed files with 5 additions and 9 deletions

View File

@ -57,11 +57,6 @@
root.classList.add("__NoScript_Theme__"); root.classList.add("__NoScript_Theme__");
const VINTAGE = "vintageTheme"; const VINTAGE = "vintageTheme";
(async () => {
const key = "vintageTheme";
})();
let update = toTheme => { let update = toTheme => {
return root.dataset.theme = toTheme; return root.dataset.theme = toTheme;
@ -98,16 +93,17 @@
} }
} else { } else {
if (localStorage) { if (localStorage) {
theme = localStorage.getItem("theme") || "auto"; theme = localStorage.getItem("theme");
} }
if (!theme && browser && browser.storage) { if (!theme && browser && browser.storage) {
if (document.readyState === "loading") { if (document.readyState === "loading") {
document.documentElement.style.visibility = "hidden"; document.documentElement.style.visibility = "hidden";
} }
return browser.storage.local.get(["theme"]).then(r => { return browser.storage.local.get(["theme"]).then(({theme}) => {
update(r.theme); update(theme);
document.documentElement.style.visibility = ""; document.documentElement.style.visibility = "";
return r.theme; if (localStorage) localStorage.setItem("theme", theme)
return theme;
}); });
} }
} }