1 line
967 B
JavaScript
1 line
967 B
JavaScript
(()=>{var d="giscus",a="sand",r="🌝",m="🌚",c=a==="system"?"light":a,f="dark",s,n,i;function l(e){s||(s=document.getElementById(e)),s.innerHTML=localStorage.theme===c?r:m,s.addEventListener("click",g)}function g(){let e=localStorage.getItem("theme"),t=e===c?f:c;switch(_(e,t),d){case"utterances":p(`github-${t}`);break;case"giscus":w(t);break;default:}}function _(e,t){let{classList:o}=document.documentElement,h=t===c?r:m;o.remove(e),o.add(t),localStorage.setItem("theme",t),s.innerHTML=h}function p(e){e!=="dark"&&(e="light"),n=n||document.querySelector("iframe.utterances-frame"),!!n&&n.contentWindow.postMessage({type:"set-theme",theme:e},"https://utteranc.es")}function w(e){e!=="dark"&&(e="light_protanopia"),i=i||document.querySelector("iframe.giscus-frame"),!!i&&i.contentWindow.postMessage({giscus:{setConfig:{theme:e}}},"https://giscus.app")}function u(){"true"==="false"&&(document.documentElement.style="user-select:none")}l("theme-switch");u();})();
|