aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/options/init.js
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2024-05-21 02:05:37 +0300
committerManeraKai <manerakai@protonmail.com>2024-05-21 02:05:37 +0300
commit462011d2c30b1e0b6d60295c85216545c41a4a22 (patch)
tree8332736d16662d5715a8620b3affc66d05fa9af3 /src/pages/options/init.js
parentAdded LightTube https://github.com/libredirect/browser_extension/issues/913 (diff)
downloadlibredirect-462011d2c30b1e0b6d60295c85216545c41a4a22.zip
Cleaning code
Diffstat (limited to 'src/pages/options/init.js')
-rw-r--r--src/pages/options/init.js53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/pages/options/init.js b/src/pages/options/init.js
index f88c9ef9..baf3eebe 100644
--- a/src/pages/options/init.js
+++ b/src/pages/options/init.js
@@ -8,40 +8,37 @@ if (!(await utils.getOptions())) {
await servicesHelper.initDefaults()
}
-function changeTheme() {
- return new Promise(async resolve => {
- switch ((await utils.getOptions()).theme) {
- case "dark":
- document.body.classList.add("dark-theme")
- document.body.classList.remove("light-theme")
- for (const element of document.body.getElementsByClassName('dark')) {
- element.style.display = 'none';
- }
- break
- case "light":
+async function changeTheme() {
+ switch ((await utils.getOptions()).theme) {
+ case "dark":
+ document.body.classList.add("dark-theme")
+ document.body.classList.remove("light-theme")
+ for (const element of document.body.getElementsByClassName('dark')) {
+ element.style.display = 'none';
+ }
+ break
+ case "light":
+ document.body.classList.add("light-theme")
+ document.body.classList.remove("dark-theme")
+ for (const element of document.body.getElementsByClassName('light')) {
+ element.style.display = 'none';
+ }
+ break
+ default:
+ if (matchMedia("(prefers-color-scheme: light)").matches) {
document.body.classList.add("light-theme")
document.body.classList.remove("dark-theme")
for (const element of document.body.getElementsByClassName('light')) {
element.style.display = 'none';
}
- break
- default:
- if (matchMedia("(prefers-color-scheme: light)").matches) {
- document.body.classList.add("light-theme")
- document.body.classList.remove("dark-theme")
- for (const element of document.body.getElementsByClassName('light')) {
- element.style.display = 'none';
- }
- } else {
- document.body.classList.add("dark-theme")
- document.body.classList.remove("light-theme")
- for (const element of document.body.getElementsByClassName('dark')) {
- element.style.display = 'none';
- }
+ } else {
+ document.body.classList.add("dark-theme")
+ document.body.classList.remove("light-theme")
+ for (const element of document.body.getElementsByClassName('dark')) {
+ element.style.display = 'none';
}
- }
- resolve()
- })
+ }
+ }
}
changeTheme()