9 ms·
This line of JS will make the text in every paragraph become black: document.querySelectorAll('p').forEach(elem => {elem.style.color = '#000'}) You can turn t
by roosgit 5y ago
This line of JS will make the text in every paragraph become black:
document.querySelectorAll('p').forEach(elem => {elem.style.color = '#000'})
You can turn this into a bookmarklet or run it from the console(necessary on sites like github.com which do not allow code running from bookmarklets).
Of course, it will not fix all your text color problems. To cover more elements like lists and headings, you'll need to add them to `querySelectorAll`.
document.querySelectorAll('p, ul, ol, h1, h2, h3, h4').forEach(elem => {elem.style.color = '#333'})
`#333` is what Firefox Reader Mode uses because it's less heavy than full black (#000).
- wolpoli 5y agoThis is a very handy script. Thank you!
- deleted 5y ago[deleted]
- gabrielsroka 5y ago> sites like github.com which do not allow code running from bookmarklets I tried a variant of it on GitHub.com. It worked fine. This one turns text red, but you can change it back to black. You can select the text below and drag it to the bookmark toolbar to create the bookmarklet--at least on Chrome/Firefox on Windows. If that doesn't work, you can copy/paste. javascript:document.querySelectorAll('*').forEach(elem => elem.style.color = 'red') This one uses a different approach, it adds a dark mode style sheet. javascript:/* /Dark Mode# */(function () {document.head.appendChild(document.createElement('style')).innerHTML = '* {background-color: #121212 !important; color: #888 !important;}';})();
- roosgit 5y agoYou are correct, it does work. My mistake was basing my statement on past experiences using an older Firefox ESR version which would give "Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”)." when clicking on a bookmarklet for sites like Twitter or Github.
- gabrielsroka 5y agoThat's what I figured you meant. I used to load scripts from other domains, but now some sites use CSP to block them.
- brudgers 5y agoUsing TamperMonkey, GreaseMonkey, or another user scripting tool allows running Javascript on any web page automatically without opening the console or any other manual requirement.