mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2025-06-11 00:03:02 -04:00
parent
8c9542264f
commit
b70af4899f
23 changed files with 70 additions and 31 deletions
|
@ -66,6 +66,24 @@ function changeColorScheme() {
|
|||
document.querySelector("#dark-css").removeAttribute("media");
|
||||
localStorage.setItem("colorScheme", "dark");
|
||||
}
|
||||
fixThemeImages();
|
||||
}
|
||||
|
||||
|
||||
// Fix images in dark theme
|
||||
function fixThemeImages() {
|
||||
document.querySelectorAll('[data-theme-src]').forEach(function(image) {
|
||||
tempSrc = image.src;
|
||||
image.src = image.getAttribute("data-theme-src");
|
||||
image.setAttribute("data-theme-src", tempSrc);
|
||||
});
|
||||
}
|
||||
if (
|
||||
(localStorage.getItem("colorScheme") === "dark") ||
|
||||
(window.matchMedia("(prefers-color-scheme: dark)").matches ^
|
||||
localStorage.getItem("colorScheme") === "light")
|
||||
) {
|
||||
fixThemeImages();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue