Alto theme, can you help me set dark mode as default?

I like this theme a lot, but I would like dark mode to be the default.

Not sure how to do that.

Any help would be greatly appreciated.

You might like this solution: Disable Dark Mode completely in Casper with code injection - #16 by minimaluminium

Hey @shodandad, you can add this script in Code injection > Site Header to make the dark theme default. Alto uses a localStorage item with the key alto_dark to toggle the dark mode, and this script sets the value true by default.

<script>
    localStorage.setItem('alto_dark', 'true');
</script>

Thanks, seems to be a bit hit and miss on whether or not it applies on first page load though.

Always applies on a reload.

@sfkpmr

the script @minimaluminium provided has problems with the first load and reload. Here is a better solution that works on the first load and will not interfere with the theme toggle.

<script>
var html = document.querySelector("html");
if (localStorage.getItem('alto_dark') === null) {
    localStorage.setItem('alto_dark', true);
    html.classList.add('dark-mode');
}
</script>

Excellent, thanks a lot!