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__");
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;
});
}
}