diff options
author | ManeraKai <manerakai@protonmail.com> | 2022-03-05 11:44:59 +0300 |
---|---|---|
committer | ManeraKai <manerakai@protonmail.com> | 2022-03-05 11:44:59 +0300 |
commit | 5619a96b4a6cecc199291009d53367d9c955e391 (patch) | |
tree | 343428c6b29602efa5967dd60941b6b0422b3b83 /src/pages/options/init.js | |
parent | update instances (diff) | |
download | libredirect-5619a96b4a6cecc199291009d53367d9c955e391.zip |
Adding more settings and combining theme in the general page #80
Diffstat (limited to 'src/pages/options/init.js')
-rw-r--r-- | src/pages/options/init.js | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/pages/options/init.js b/src/pages/options/init.js index 6b196bfa..60958682 100644 --- a/src/pages/options/init.js +++ b/src/pages/options/init.js @@ -1,27 +1,30 @@ window.browser = window.browser || window.chrome; function changeTheme() { - browser.storage.local.get("theme", (result) => { - switch (result.theme) { - case "dark-theme": - document.body.classList.add("dark-theme"); - document.body.classList.remove("light-theme"); - break; - case "light-theme": - document.body.classList.add("light-theme"); - document.body.classList.remove("dark-theme"); - break; - default: - if (matchMedia("(prefers-color-scheme: light)").matches) { - document.body.classList.add("light-theme"); - document.body.classList.remove("dark-theme"); - } else { + browser.storage.local.get( + "theme", + result => { + switch (result.theme) { + case "dark": document.body.classList.add("dark-theme"); document.body.classList.remove("light-theme"); - } + break; + case "light": + document.body.classList.add("light-theme"); + document.body.classList.remove("dark-theme"); + break; + default: + if (matchMedia("(prefers-color-scheme: light)").matches) { + document.body.classList.add("light-theme"); + document.body.classList.remove("dark-theme"); + } else { + document.body.classList.add("dark-theme"); + document.body.classList.remove("light-theme"); + } + } } - }) + ) } changeTheme() |