Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var existingLink = document.querySelector('link[href="html5/data/css/output.min.css"][data-noprefix]');
- if (existingLink) {
- existingLink.setAttribute("id", "theme-stylesheet");
- }
- function setTheme() {
- const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
- const themeLink = document.getElementById("theme-stylesheet");
- if (prefersDark) {
- themeLink.href = "dark.css";
- } else {
- themeLink.href = "light.css";
- }
- }
- setTheme();
- window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", setTheme);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement