Hi! I just tried out your fix. Still works! Thanks!
However, I've found the following bug. Dark mode button, both in your version and original, works only for English interface of MediaWiki, whereas I also tried Ukrainian MediaWiki and nothing happens there when I press the button.
I don't expect you to fix it, of course, but if you happen to see the cause, I would be grateful.
P.S. I also tested Russian, Spanish and French interfaces. It doesn't work in those that translate "Dark mode" (Ukrainian, Spanish, French), and works in those that don't (English, Russian).
P.P.S. I've been using UniversalLanguageSelector extension to change interfaces quickly, and after I pressed the English version button, it confusingly started working in any other language now.
P.P.P.S. Yeah, now it works even when I'm accessing Ukrainian MediaWiki via TOR. Not sure whether it was a misreport, but if it was, sorry to bother.