vitalso78,
так сделайте
document.addEventListener("DOMContentLoaded", function() {
const styleElement = document.querySelector("#theme-css-file");
const button = document.querySelector("#SuperButton");
let CssFilePath = localStorage.getItem("CssFilePath");
if (CssFilePath) {
if (CssFilePath.indexOf("dark.css") !==-1) button.classList.add("switch-on");
else button.classList.remove("switch-on");
styleElement.href = CssFilePath;
}
button.addEventListener("click", function() {
let href = "https://delivery.foodsonic.ru/light.css";
button.classList.toggle("switch-on");
if (button.classList.contains("switch-on")) href = "https://delivery.foodsonic.ru/dark.css";
styleElement.href = href;
localStorage.setItem("CssFilePath", href);
})
});