Thank you for this extension! I just tried it and when I click Dark Mode on a page it works just fine. However, when moving to another wiki page, the Dark Mode is lost, and I have to click again. MW 1.31, Timeless theme.
Topic on Extension talk:DarkMode
Jump to navigation Jump to search
Dark mode is lost when navigating to a different page
Fixed for logged in users. Issue still stands for logged out users, but depending on the setup they might have to experience a "flash" on every page load anyway.
Same for me. Any resolution?
The script should either hook into server/php state or set some css or something. Edit: Cookies were sufficient.
Alright, I just forked their extension and implemented persistent dark-mode support. I'll clean it up and toss it on Github. If I forget to come back to link it, feel free to ping me or comment on my talk page.
Same here, ping @Cantaloa
See if this works: Topic:Vqoyyfiw18jjd5sh -- I made various changes to it, the primary change being to set/unset a darkmode=1 cookie. The benefit of a cookie is that it works for anonymous users (rather than using MediaWiki's state). Feel free to continue the discussion at the topic link.
@Cantaloa Sorry for the late reply; I wasn't actually watching this page until now. DarkMode was basically a WMF built extension that was abandoned very early on. As you've noticed it is very much incomplete.
It's awesome you got some of the more essential features figured out! Is there any reason why you forked it instead of submitting patches to the original extension?
Yeah, publishing my hasty quickfix was all I had time for.
Hehe, okay. I just wanted to give you an opportunity to get credit for your work, if you want it! I will need to make the same kind of changes. I have been putting off finishing this extension for so long now, but I would have happily reviewed/merged any patches :) That said, if you don't have Gerrit set up and all that, I can certainly sympathize with avoiding the learning curve.
I certainly don't need credit as 99.9% of the work is pushing a release, not the trivial tweak I came up with; work I'm very generously offering you ;) As a final note, iirc, I found out through people asking for help with theme breakage that applying the CSS `filter` (like the invert() rule) to `<body>` will make downstream `position: fixed` dom nodes base their position off `<body>` instead of `:root` (`<html>`). The simplest fix is to move the `darkmode` class toggle from `<body>` to `<html>` which has a nice API through an unstable feature only available since one of the MW releases since I posted in this thread, so look out for that (https://doc.wikimedia.org/mediawiki-core/master/php/classOutputPage.html#a6a34e78b9018c807dc53e13b4c4111e5). Quick, obvious reminder of what that fix would look like: https://github.com/danneu/MediaWiki-DarkMode/issues/1#issuecomment-772003944 -- Good luck. This is all I had time for. I may have time in the coming weeks to field test this on my own at least.
Indeed, OutputPage::addHtmlClasses() was added by yours truly in preparation for finishing DarkMode :) See the discussion there for why it's marked as unstable (basically dark mode is the only use case for it). That was the tiny bit of work I actually did do in my free time after the project was abandoned by WMF. I didn't realize DarkMode was being used by so many people, much less people who had forked and "finished" it. But so long as you're okay with me copying your code, I will! I hope to get to this soon, but please don't ever hesitate to contribute directly either should you want to.