From 462011d2c30b1e0b6d60295c85216545c41a4a22 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Tue, 21 May 2024 02:05:37 +0300 Subject: Cleaning code --- src/pages/options/init.js | 53 ++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'src/pages/options/init.js') 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() -- cgit 1.4.1