n0x.io/public/js/coder.min.235666b114443867d43eeb5799d51f6252965e5163f338285e113fa381d3d27e.js

1 line
1005 B
JavaScript
Raw Normal View History

2021-05-26 00:06:52 +02:00
const body=document.body,darkModeToggle=document.getElementById('dark-mode-toggle'),darkModeMediaQuery=window.matchMedia('(prefers-color-scheme: dark)');localStorage.getItem("colorscheme")?setTheme(localStorage.getItem("colorscheme")):body.classList.contains('colorscheme-light')||body.classList.contains('colorscheme-dark')?setTheme(body.classList.contains("colorscheme-dark")?"dark":"light"):setTheme(darkModeMediaQuery.matches?"dark":"light"),darkModeToggle.addEventListener('click',()=>{setTheme(body.classList.contains("colorscheme-dark")?"light":"dark")}),darkModeMediaQuery.addListener(a=>{setTheme(a.matches?"dark":"light")}),document.addEventListener("DOMContentLoaded",function(){let a=document.querySelector('.preload-transitions');a.classList.remove('preload-transitions')});function setTheme(a){body.classList.remove('colorscheme-auto'),inverse=a==='dark'?'light':'dark',localStorage.setItem('colorscheme',a),body.classList.remove('colorscheme-'+inverse),body.classList.add('colorscheme-'+a)}