From 2a0596f08fb54e2faef4bcb4548a28f5837fc067 Mon Sep 17 00:00:00 2001 From: BobIsMyManager Date: Tue, 26 Jul 2022 22:28:50 +0100 Subject: Many things Made all instances updateable Added hyperpipe Closes https://github.com/libredirect/libredirect/issues/398 Added cloudtube Closes https://github.com/libredirect/libredirect/issues/397 Start using prettier --- src/pages/options/init.js | 61 ++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'src/pages/options/init.js') 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) -- cgit 1.4.1