congo/js/appearance.min.12e98742cd28...

1 line
1.0 KiB
JavaScript
Raw Normal View History

const sitePreference=document.documentElement.getAttribute("data-default-appearance"),userPreference=localStorage.getItem("appearance");(sitePreference==="dark"&&userPreference===null||userPreference==="dark")&&document.documentElement.classList.add("dark"),document.documentElement.getAttribute("data-auto-appearance")==="true"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&userPreference!=="light"&&document.documentElement.classList.add("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{e.matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")})),window.addEventListener("DOMContentLoaded",t=>{const e=document.getElementById("appearance-switcher");e&&(e.addEventListener("click",()=>{document.documentElement.classList.toggle("dark"),localStorage.setItem("appearance",document.documentElement.classList.contains("dark")?"dark":"light")}),e.addEventListener("contextmenu",e=>{e.preventDefault(),localStorage.removeItem("appearance")}))})