aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/options/init.js
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-07-27 17:44:04 +0200
committerManeraKai <manerakai@protonmail.com>2022-07-27 17:44:04 +0200
commita9a7dba5a329eb17e23ba08802406a4e2e2cb836 (patch)
tree2cb69c855b36e82128a00e5895d5f5409d5e0a5e /src/pages/options/init.js
parentMerge branch 'BobIsMyManager-librex' (diff)
parent, (diff)
downloadlibredirect-a9a7dba5a329eb17e23ba08802406a4e2e2cb836.zip
Merge pull request 'Squashed a few bugs' (#10) from BobIsMyManager/libredirect:master into master
Reviewed-on: https://codeberg.org/LibRedirect/libredirect/pulls/10
Diffstat (limited to 'src/pages/options/init.js')
-rw-r--r--src/pages/options/init.js61
1 files changed, 29 insertions, 32 deletions
diff --git a/src/pages/options/init.js b/src/pages/options/init.js
index daea2963..5b679da4 100644
--- a/src/pages/options/init.js
+++ b/src/pages/options/init.js
@@ -1,38 +1,35 @@
-window.browser = window.browser || window.chrome;
+window.browser = window.browser || window.chrome
-import localise from "../../assets/javascripts/localise.js";
+import localise from "../../assets/javascripts/localise.js"
function changeTheme() {
- return new Promise(resolve => {
- browser.storage.local.get(
- "theme",
- r => {
- switch (r.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");
- }
- }
- resolve();
- }
- )
- })
+ return new Promise(resolve => {
+ browser.storage.local.get("theme", r => {
+ switch (r.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")
+ }
+ }
+ resolve()
+ })
+ })
}
-changeTheme();
-if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl");
-localise.localisePage();
+changeTheme()
+if (["ar", "iw", "ku", "fa", "ur"].includes(browser.i18n.getUILanguage())) document.getElementsByTagName("body")[0].classList.add("rtl")
+localise.localisePage()
-window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme) \ No newline at end of file
+window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", changeTheme)