I would like to change the body class="" of a website, in this case it's WhatsApp Web, if you go to inspect element and change body class="web" to body class="web dark" the page becomes dark. How can I save this so I don't have to do this every time I load the page? Thanks!
-
I'm assuming you can't modify the code directly? What kind of browser are you using, Chrome? – Danny Bullis May 17 '20 at 20:45
-
Yes. I just want to not have to change the code every time I load the page, so the web stays dark all the time. – Adrian Sierra May 17 '20 at 20:50
-
1Try using `greasemonkey` or `tampermonkey`. BTW, be prepared to get your question downvoted or closed as it is to generic and not within 'SO rules'. [reprex] – Rene van der Lende May 17 '20 at 20:50
2 Answers
You'll likely need to use a Chrome Extension for this. Here is a helpful link to a similar use-case where the person was attempting to create their own extension, if you're interested in creating your own solution. Here's a reference from the Google Chrome team on creating your own Chrome extension.
If you're looking for something a little more out-of-the-box, check out this Chrome Plugin, Page Manipulator. There are several other plugins such as TaperMonkey.
The idea is to have some extension in Chrome that will automatically apply the changes you attempting to do directly to the DOM of the page.

- 3,043
- 2
- 29
- 35
what you are trying to do is not possible because each time you reload the page the code will get updated(By updated i mean the orignal code).
But there is a way you can do the same by creating your own add-ons in mozilla or extensions for chrome what this extension will do is whenever they will see a "tag" or "class" matching the constraint will get replace by the value you want.
like in your case from "web" to "web dark".

- 126
- 1
- 6