This is for Firefox. I know there are extensions for dark themes, but I don't want to use it because it messes up certain websites and doesn't get back to normal even after removing the extension.
What I want to do:
Instead, I want to create a script which can be run with GreaseMonkey or an equivalent.
On Google's search page, there's a gear icon for "Quick Settings". On clicking it, these options are shown:
Instead of having to manually click it, I want a script to auto-detect that I opened a Google page, and automatically click that "Dark theme" radio button.
What I tried:
Found the div:
<label class="GZcH3e LZTko" jsname="I7WXBf" style="display:flex" data-ved="2ahUKEwiY_7-G9ZCAAxWT-jgGHdrgDFoQ9ZsIegQIIBAN">
<div class="UCGAnb">Dark theme</div>
<img class="UCAEse" src="https://www.gstatic.com/ui/v1/menu/dark_thumbnail2.png" alt="">
</label>
Assuming that clicking the radio button invokes a JavaScript function, I searched for I7WXBf
and found this:
class\x3d\x22GZcH3e LZTko\x22 jsname\x3d\x22I7WXBf\x22 style\x3d\x22display:flex\x22 data-ved\x3d\x222ahUKEwiY_7-G9ZCAAxWT-jgGHdrgDFoQ9ZsIegQIIBAN\x22\x3e\x3cdiv class\x3d\x22UCGAnb\x22\x3eDark theme\x3c/div\x3e\x3cimg
But I find it hard to figure out how it'd get invoked.
I also asked ChatGPT to create a GreaseMonkey script based on the class names from the relevant HTML, but the script didn't work.