Show HN: HN dark mode in 2 lines of code
Paste this in the developer tools console of your browser
document.documentElement.style.filter = "invert()"
document.documentElement.style.background = '#fff'
Edit: you can also create a bookmark with the code below in the URL field
javascript: (() => { document.documentElement.style.filter = "invert()";document.documentElement.style.background = '#fff' })();
Then just click on the bookmark for instant dark mode
10 comments
[ 2.7 ms ] story [ 37.6 ms ] thread// ==UserScript==
// @name HN dark mode
// @namespace http://tampermonkey.net/
// @version 0.1
// @description HN dark mode
// @author You
// @match https://news.ycombinator.com/\\*
// @icon https://www.google.com /s2/favicons?sz=64&domain=ycombinator.com
// @grant none
// ==/UserScript==
(function() {
})();[0] https://userstyles.org/styles/113994
Took me a moment to realize how to apply this (here for others benefit):
1. Right click > Block element
2. Click anywhere
3. Change the rule to:
4. Click preview and create if happyjavascript:(function() { var tag = document.createElement('style'); tag.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(tag); tag[ (typeof document.body.style.WebkitAppearance=='string') ? 'innerText' : 'innerHTML'] = '* { background-color: white !important; color: #444 !important; } html { filter: invert(100%) grayscale(100%); }'; })();