Of all places, HN should be dark mode by default, without any of us using a plugin or specific browser. I don't want my eyes to burn when I'm browsing HN at night on my phone. Anyone?
This is lovely. Thank you.
PS... I just switched to FF after countless years with Chrome.
It was the container tabs that finally won me over, and the rest of the pros are icing on the cake. Wonderful.
pg told me that he wanted HN to look like the output of `top`. The older it gets, the more we approach that goal.
More seriously: I've never seen a proposed "spruce-up" that didn't either add too much whitespace or too little (well, always the former), which makes me think that the current design is in the ballpark of optimal, despite its being unfashionable. Also, HN is very much a text site, a fact that goes much deeper than look-and-feel. The first thing most "spruce-ups" do is toss this quality, which compromises the site at its essence and indicates a misunderstanding of what HN is. I'm reminded of Steve Jobs' famous line about how design is not how-it-looks but how-it-works.
If someone did a redesign of HN that preserved both its information density and its textiness, I'd be stoked to see it as an experiment. We probably wouldn't change the site much, because if there's one force stronger than user complaints about design, it's user complaints about design changes. Also, I think it's an advantage for HN to have an unfashionable design, and a huge advantage to have a stable design. Still, I'd be fascinated to see it, and there might be ideas we could use.
The textiness of the site likely scares off a lot of new/non-techy users. Reddit switched from being a text site to a modern UI a few years ago, in doing so they managed to gain a lot of new users. Which in turn ruins the sites community and discussion when users are focused on making cheap jokes and memes for upvotes.
I think I agree with your main point but some distinctions are important. We don't want to scare off new users—we love new users. We don't want to scare off "non-techy" users—they are completely welcome. The users we want, though, are the intellectually curious ones. And there I agree that HN's textual orientation is an asset.
That said, I've wanted this feature desperately for a long time. Browsing HN on my desktop monitor in the evening is blinding and gives me a headache. I find myself resizing the window to be phone-sized just so my eyes are assaulted with less light.
If you need a hand with the CSS, I'd be happy to write it myself (speaking of which; is HN open-source?)
I added themes to the Anarki forum a while ago[0], along with a quick and dirty dark theme. Please ignore the garbage quality of my PR and code, but if the HN devs want to rip it off they're welcome to.
Thanks, I'll look into that, and you're welcome to ping hn@ycombinator.com about it.
If it's simple to add and isn't going to break anything for anybody, we'd be happy to.
Edit: ok, as I understand it, it's simple enough to add except that you have to figure out what the color scheme for dark mode should actually be. Is that accurate?
I have to say - if your monitor is blinding you, you have it set to too high a brightness. You're doing yourself a disservice by not turning it down. It should only throw out as much light as a piece of pristine printer paper in the same orientation.
In the middle of the day my monitor tops out at about 30 of 100, and in the evenings I will occasionally turn it down to about 5 or 10. Many modern monitors will offer an option to save multiple settings, or they at least make brightness a top level configuration setting.
EDIT: Is saying "If your monitor is hurting your eyes, turn it down," really such a controversial statement?
I like having my display as bright as possible without it being uncomfortable; it helps with readability. On my laptop and phone I'll shift the brightness throughout the day to meet this heuristic, but alas, Windows does not make this trivial with an external monitor. Usually you have to fiddle with the monitor's physical buttons and navigate down into a menu. So I just don't bother.
Most desktop monitors have their brightness & other config exposed via the DDC (DDC?) protocol. This is a simple UI that exposes the brightness controls on Windows. Much easier than using the buttons.
You might need to go to the monitor's menu and enable DDC if it's disabled by default.
Windows has a brightness slider in the side bar, but it doesn't seem to work with external monitors. Probably because OS-level brightness controls were implemented when laptops became popular, and traditional PCs with external monitors became an afterthought.
Just realize when you use them as a justification for changing defaults which work fine for most everyone else, you're going to annoy people. Especially when your preferences tend to fly in the face of common sense.
In my experience, low contrast text is going to have a low contrast no matter how bright or dim your computer screen is. That is, turning up the brightness will only wash out the text as it overwhelms your eyes.
It’s also an accessibility issue, but that’s a comment for a different article.
Yep, came here to suggest exactly this. Especially because then it works for all sites, not just HN. I can also second Dark Reader specifically; it's nicely tunable, supports per-site toggles, and lets you set a schedule to automatically toggle dark mode in the evening. I think my only complaint is that it might be the reason why my Firefox on Android gets really slow / hangs occasionally, although that might be unrelated; haven't gotten around to testing (and it might also be the old-ish hardware and >>100 tabs, so grain of salt).
It makes FF on my high-end desktop slow too, sometimes.
In the dark reader popup window you can set the Mode; the default of Dynamic does an excellent job of making everything dark but is pretty slow. The other modes have basically no performance impact but you might see some visual bugs from time to time.
Yeah, the tab counter hit "∞" (>99 tabs) ages ago, but they're lazy-loaded so it's just a little slower and a lot more scrolling to get to older tabs. Moto G5 Plus (XT1687), 4 GB of RAM, crDroid 6.5 (Android 10) if it matters.
There may be third party solutions to this. The management around here is very conservative about changing things and explicitly has policies to "Move slow and preserve things" (as opposed to "Move fast and break things"). So, as a guess, the answer to that is probably "No" or, at best, "Not any time soon."
But the management is very tolerant of and even warmly welcomes the fact that the membership includes a lot of programmers and we tend to get a lot of third party solutions.
Off the top of my head, I don't know of an HN reader thingy in dark mode, but asking if those exist is much more likely to get you an immediately available solution than asking management to alter the appearance of HN in some specific way.
The thing is that this is a CSS change, which makes it declarative, which means it would almost certainly not "break" anything. Also, if it were made optional via a personal setting or by hooking into the user's system-level setting (https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...), it wouldn't even be a "change" for anyone who doesn't want it to be.
I understand and respect the general philosophy, but I fail to see how this particular request could be anything but a strict improvement.
I'm not in charge around here. My opinions about what I have observed over the last decade are just that: My opinions.
Feel free to prove me wrong and talk management into making such a change. But talking at me to convince me I'm wrong is probably not really the way to do that. I have zero decision-making authority in this matter.
Well, let's hope you win. I'm disinclined to use browser extensions and the like, but would likely use a dark mode setting on HN if it existed. I use dark mode on Twitter and they have a really, really nicely done dark mode.
Firefox didn't remove it. They just put it behind a new flag that is default off. Apparently it was because it affects performance for those not using the feature.
Other comments have good solutions but if you are accessing via mobile try out Octal. Dark theme by default, great UI/UX, complete with search, etc. I’ve been very happy with it and have tried out multiple third party clients and this has been my favorite
For context (and also protip if you weren't aware), there's already precedent for user-defined CSS in HN. I don't remember if everyone has access to it, but there's a topcolor setting in your profile that sets the color of the top bar. Maybe that could be extended to include other CSS properties? I wouldn't mind having to write hex color codes...
An open entry field for custom CSS would be a clunky but still welcome solution to this problem. It would also be extremely low-risk and low-effort on the maintainers' parts.
I wanted to do that but was told that Reddit encountered security issues with this, and so moved away from it in favor of a complex widget UI, which would not be a good fit for HN.
If you’re on iOS: I’ve been using the same YC reader app for over 6 years and it hasn’t been updated in over 2 years now but it still works and has had fully configurable colors schemes since as long as I can remember: https://apps.apple.com/us/app/hacker-news-yc/id713733435
Ok, you guys, this isn't the first time we've heard this request (https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...). I'm willing to do it (edit: not to change the default! just to add the option). It's just that any CSS issue that goes more than a quarter-inch deep is outside both my expertise and my interest.
We can add CSS to https://news.ycombinator.com/news.css for prefers-color-scheme: dark, but that leaves open the question of specifically what CSS to put in there. Anyone who wants to make a suggestion is welcome to. Post it in this thread so others can comment, or email it to hn@ycombinator.com. I've roped Zain, YC's designer, into helping with this, and we'll come up with something.
Ah, I'm glad you mentioned that; I took a look at it earlier, but I think what would be most helpful is just the most minimal set of CSS we could put in curly braces after prefers-color-scheme: dark. In other words, a patch to https://news.ycombinator.com/news.css that would strictly only add lines—and preferably the most minimal that would do the trick.
Right now, the profile has a single property "topcolor" where you can slightly customize HN. It seems that this could easily be extended with a few more similar properties, suitable values of which could produce a darkmode.
I'd love to do that just by offering people a CSS blob that we could inject into their CSS when they browse HN. Our original idea (actually kogir's idea from back in 2014—he's a forward-thinking guy) was that people could create skins this way, if that Winamp-era term isn't too obsolete by now, and share them.
However, someone who is plugged into Reddit told me that they used to allow user-defined CSS for customizing subreddits and had to roll it back because of security issues. They built an entire customization UI instead. That scared me off the idea.
My fear with a customization UI—the HN equivalent of which would be profile settings, as you indicate—is that it would get way too complicated too quickly. How many additional settings would we need?
If someone can define a not-too-complicated set of profile settings which, when filled in to taste, would solve people's dark-mode concerns, I'm all for it. We could even make a separate editor page for it and link to that from the profile. The other constraint is: for each setting, the input format would need to be simple to sanitize (e.g. 'valid hex color'). Otherwise we just create the security issue all over again, only with a shitty nonstandard application-level CSS editor instead of standard CSS.
>If someone can define a not-too-complicated set of profile settings which, when filled in to taste, would solve people's dark-mode concerns, I'm all for it
I posted a possible solution in another comment here[0]. You would have to write a separate dark theme, and there would be a single option to select it in the user panel. The data is literally just an integer pointing to an index in a whitelist of css filenames, and any errors would default to displaying the existing stylesheet.
Reddit's user CSS was different, mods could edit it on subreddits and all visitors would receive it. On HN you'd only get the CSS you've set yourself, so there shouldn't really be a security concern (except for CSRF attacks against the settings form I guess).
I would really like to see this: maybe release a "submit CSS blob" feature first and then, in a couple months, have a competition to pick the best style sheet?
Not so fast! Just because the CSS is only served to the authenticated account which installed it doesn't necessarily mean things are 100% okay.
There could be cross-site scripting attacks whereby the user clicks on something evil in a malicious site which attacks that user's HN authenticated session by installing some malicious CSS in their profile. The UI could require a confirmation of the account password for updating any security-sensitive properties.
Users could also shoot themselves in the foot with bad CSS. The obvious fix for that is that the profile settings page itself doesn't inject the CSS, or there is a safe variant of its URL which doesn't inject CSS.
I would love to be able to define my own CSS that simply replaced the site’s settings, not just for dark mode. It would let me make changes that would be extremely useful to me.
For example, I’d hide the “hide” links on the main page. I’m sure some people love that feature, but I’ve only ever used it accidentally (fatfingering on mobile).
I’d add a bunch of additional hiding CSS. I’ve long wanted a “helps-me-respect-my-time” version of HN, where voting buttons, flag links, reply boxes, and reply links are all hidden.
This was, in fact, the original point of css. You're supposed to be able to add your own user-defined styles to "the cascade". Unfortunately modern browsers don't really implement this right and you're stuck using weird 3rd party plugins to accomplish this.
I think background color and text color options with inverted voting arrows (as suggested elsewhere in this thread[0]) would be enough for most people.
What.cd used to let you put a url in your settings that was injected as the stylesheet while you were logged in. This approach would let people publish and share themes--though shared themes could be a (pretty visible) security concern.
I remember also running into issues trying to use non-https-served stylesheets since the site was https and browsers balked.
I previously customized HN a bit via my own CSS additions, with the Stylus browser extension. Personally I think that's a more feasible route for personalization than an interface for that on the site itself. However, there's a problem that HN's HTML layout doesn't lend itself to CSS work: you end up describing elements in terms of ‘a div two items down from the one embedded in that thing’, instead of just using classes. Sprinkling around some classes might be something to look at, for providing users the ability for customization. This should be pretty safe. I'd also say that the structure could be more semantic—but that may break browser extensions and similar existing customization.
P.S. I hurried to this thread because I noticed that the ‘collapse comment’ links became larger on my phone and I can finally hit them on the first try. Thanks to whoever did that, sincerely! Though personally I'd encourage you/them to make the link three times wider still, to take away even more effort. Dunno if it's much visual noise to others, but at least I don't think it encroaches on other elements.
Btw, another hopefully-not-controversial change that I would make is to have the post text black, not gray. It's a pretty important element, isn't it? So it should have high contrast and be readable.
The post text is light grey to discourage use of text-only posts, rather than links. HN is primarily a discussion forum centred around links to external content, and I think the site owners/maintainers want to keep it that way.
Please, for God's sake, don't screw it up. I can keep up with news on this site from a 15 kb/s shared satellite link when I'm out at sea. Except perhaps for the really big threads. I love the simple interface. It's text, it's simple, it's readable, and when I hit the spacebar, it scrolls down a page. No fancy fonts, no javascript, no nothing. I love HN for its simplicity and speed. Thanks for maintaining a good engineering philosophy.
Can we have a review before we merge the change? Make sure all issues are ironed out.
HN design is simply the best thing out there. "Moving slowly and preserving things" - I would get this engraved on my grave. This philosophy has died unfortunately and with it went robustness, simplicity, elegance, poise, beauty, accessibility, elegance, maintainability and practicality.
Thanks dang for your gandalf-like wisdom and your resilience. I like Alligators over goddamn mosquitos that have taken over the internet.
How can anyone even dare to think about indents? C'mon, I thought this was settled. Did you know that human fingers can detect roughness value down to N7? That's 1.6 micrometers. There is a bigger fish to fry than just think about indentations or bumps. Texture. Texture is everything and there is nothing else to talk about, although I am open for other ideas. Thoughts?
There are many ways for end users to force dark mode without any change on HN. "invert page colors" chrome extension, for example, does a nice job. Not ideal, but good enough.
I second the other commenter, don't do anything. Or get someone really good to help you!
There's a very solid Stylus theme for HN that I've been using as long as I can remember. Until just now I had honestly forgotten that this wasn't what HN looked like by default.
hmm. I just tried turning off JS and reloaded Firefox. Everything seems to still work fine on HN with the theme on. I don't know much about web dev so I'm not sure what could be causing it.
Midnight lizard (chrome) https://chrome.google.com/webstore/detail/midnight-lizard/pb... is a good extension that can create a dark theme by changing the contrast & things like that. It does it in a way that the same theme will work on a lot of sites. They do have more dark (& light) themes on their site & you can create your own by entering a few colors & it will create a theme based on that. Stylus is good (NOT stylish), but Midnight lizard creates themes in a way that are compatible with a lot more sites that Stylus.
Is there a non userstyles.org link for this? I've blocked cookies on userstyles.org (For obvious reasons) & when you black cookies on that site it gives you a blank page. If you enable cookies it comes back.
I tried various of dark mode plugins in Firefox and none of them seem to be able to do their job without obvious shortcomings. For example most of them don't check the original color of the website and just invert colors of dark pages as well. Or in some cases it doesn't invert all text colors, making hyperlinks hard to read.
None of the extensions I've tested can match the dead simple CSS override I used in qutebrowser.
I just started using Dark Reader yesterday, and for the most part, it's excellent.
old.reddit.com comments are mostly unreadable, and it cripples gmail, but I've learned to take advantage of Options-Shift-D to flip it on and off when needed.
An alternative is to "opt-in" sort of how you can change the top bar color with enough Karma. Maybe that CSS is not loaded for people who dont have that same Karma? I assume people asking for the feature post often enough.
Edit:
To clarify what I mean is maybe toggling which style sheet HN gives you in settings would be ideal for all. Web standards are nice but they dont help in the minimalist ideals of HN too much.
Also, not only should "dark mode" be the responsibility of the browser, it already is. There's plenty of plugins that do this and people that want it should use them.
chromium for android is open source ... that's where the solution should be and if you're really passionate about it, go do it. It shouldn't be the responsibility of every individual website to independently implement the feature.
Could you imagine if we entrusted every website to independently implement scroll bars and zoom? What a mess that'd be.
While I partially agree with you (that's why I upvoted) in that it's a waste of everyone's time having every website developer worry about dark mode I still think scrollbars and zoom are fundamentally different from a dark mode in that the latter cannot be detached from aesthetics.
The color pallete of a page is important, and maintaining a consistent look and feel across normal and dark mode can only be done reliably by each website's designer.
So I guess we need both the ability to have the browser auto-calculate a default dark mode, and a way for aestetically-conscious web designers to override it, and that's what we're moving towards.
but dark mode is an accessibility feature and used to be called high-contrast mode. This is a solved problem and has been for at least 30 years.
In fact it's already in chrome on android, no work needs to be done (other than enabling it). Here's an image gallery guide I made: https://imgur.com/a/njNTO6T
This is the right approach, it should be solved at the browser level. In fact, it already is.
The only responsibility of web developers should be to not go out of their way and do silly things that break this.
IMO it's two separate things. Both useful on their own right.
High contrast is very useful for people with visual difficulties, but might even be counter-productive for certain types of eye strain.
I'm under the impression people asking for dark mode are looking for something that will emit less light off their screens, not necessarily make it look nore contrast-y, and the two are more often than not opposite.
Dark mode is an accessibility and ergonomics feature that should be supported by websites through CSS whenever possible. Of course browsers need to support it in the first place for it to work, but that seems to be mostly the case:
I’m on land in a well populated city relatively near the Bay Area and I get about half a bar on my phone. So yes! Please don’t screw this up! Because not only I like reading HN but also because it’s the only thing I can do on my phone now and it’s really helping me kick all the bad habits of being on my phone!
Well, if we want HN to follow best modern web practices, I recommend rewriting the whole thing with React/Node.js using TypeScript. Then, we can get a proper CSS framework in place like Material that will really allow us to get everything looking really good. I can design a cool looking loading screen that says "HN" while the JS is loading in the background.
When you click on a link to the news.ycombinator.com domain, what should happen if you prefer dark mode? And vice versa?
In comparison, the pure-CSS ideas that some people are posting would work automatically if your browser supports dark mode, and would enlarge the (cached with long ttl) CSS file only very slightly.
Unfortunately, there are some of us who also like the solarized type light mode in HN more than dark mode, but we use dark mode at the system level because the OS light mode is awful.
Pure CSS would be quite cool, but we'd probably also need a snippet of JS to add a button allowing to switch between light and dark mode. (There's probably a way to do it without JS that someone will hopefully comment too.)
While I agree with most of your points, I disagree with
> Doesn't play nice with password managers.
Check your password manager settings. Most have options to match on domain, subdomain, port or have the ability to set equivalent domains either globally or per credential.
Ha, remember the first time they tried a mobile layout? That was quickly yanked (to much rejoicing). If the dark mode has some issues, we can always go back and try again. The main thing I care about is making sure it's still easy to read (good contrast).
Hah, HN's load speed actually makes it my go-to bookmark to test if everything is working okay. Internet connectivity lagging? Check HN. My own web app loading slowly? Check HN.
Honestly theres a lot of other sites that would benefit from that too. A well written and maintained scraper for a bunch of popular sites may be worth a subscription for some bandwidth limited people.
A court recently ruled [1] that LinkedIn had to allow scraping, but it has to be public data (i.e. you can't log into your Facebook account and then scrape all your friends' pages).
It's not the scraping itself that I would be worried about, it's using this data to create what could be seen as a competitor (especially if you make it commercial). For a lot of these websites, traffic is essentially money: diverting users to another website using their own content would be very badly received
I was more thinking about a local web-app that consumes the site and then outputs it in a nice mobile layout, without actually archiving or saving anything.
I think you guys overreact a bit, your reply alone occupies more bytes than the CSS needed to implement dark mode; it wouldn't affect anything related to scrolling with space-bar, or fonts, or JS functionality.
True, serving it to you was negligible, but that little extra being served millions of times, once for every request, in aggregate slows down servers, eats up peoples’ data, raises costs and generally quickens the heat death of the universe.
It's a KB of css, if that, probably much less. Cached, in a stylesheet request, not a style element. It's nothing. It amortized, not more data for every request. It's nothing.
True, but doesn't this even save bandwidth because it doesn't need to reload the whole page just to update that detail? Either way it still works without JS, which can't be said about most modern websites.
"... which can't be said about most modern websites."
While I understand and agree with your point, I have personally found this quoted portion to be a false assumption.
To me, "works" means I can retrieve the content of the page without using JS. If the websites we are discussing are ones where the primary purpose is reading, like HN, most will "work" for me without JS, so long as I do not rely on try using a "modern browser" to retrieve the content. In fact, I cannot even think of a single website meant for reading that I cannot read without a Javascript-enabled browser.
How can you keep up with the news when HN only records the headlines and the articles are stored elsewhere, usually on extremely heavyweight news sites?
Anyone who wants to make a suggestion is welcome to.
I'm not a programmer, so I'm probably saying something incredibly, fantastically stupid. Take this in the spirit of "Brainstorming" where you say even the stupid stuff because that sometimes leads to good things.
I am not a programmer, but I do know some HTML and CSS and studied it a bit and Blogger (aka Blogspot) let's you dig in the code of the theme if you want, but it also has a user-friendly section where you can change colors and stuff and it let's you "add CSS" there and I do add CSS snippets there to tweak my websites.
I have tried digging in the code a few times. It's never worked for me. But adding CSS snippets is something I can handle.
You already have a feature to select your top bar color. Would it be feasible to expand that feature a little to let people select dark mode colors? (Ie to change more colors than just the top bar.)
I don't think it's a good idea for HN to add this (a lot of work and potential downsides, for minimal returns), however you can do it using this extension!
My in-house tech support is opposed to me using browser extensions. I don't understand them and have never used them. I tried briefly to get one to work, then found out my tech support frowns on such, so I was happy to call it quits.
I have no plans at this time to go to a third party service for this or add an extension. Though I have been thinking since I wrote the above of changing my top bar color.
I'm fine with HN moving slow and preserving things. That works for me. But the only way I will go to dark mode on HN is if it is possible to somehow do that through HN.
Maybe someday I will change my mind about that. But not today.
This is true for Chrome/Safari, which are the most popular mobile browsers. But Kiwi can run some/many Chrome extensions, and Brave has this on the roadmap for 2020.
You already let us change the top bar color I preferences. Really, this is just a adding “text” and “background” colors - swapping white and black.
This could be a check in preferences, load from the DB the same time as the top bar, then insert into template or however HN is organized server side. Probably <10 lines of total code, If you include DB changes.
It would be all server side so we shouldn’t have an issue in terms of bandwidth.
Tested thoroughly on threads and the front-page, some notes:
Upvote arrows blend with white instead of transparent, giving a weird look.
The orange goes well with black.
Not all users might want #000, but for OLEDs it's gorgeous.
The @media selector requires a OS/Browser support, to extend that a simple way is programatically add a .dark class to <body> (edit: based on a checkbox in their profile), and add selectors with .dark.
Some colours on the site are hardcoded, like the orange asterisk on your own comments, and newbie green. They both go fine with #000 imo.
Edit: tested on the other pages, looks good imo. Login/logout don't have CSS, which'd be a bit jarring.
It's a bit sad there's no distinction between the #hnmain and the background anymore, I think if that were desirable I'd probably change <body> to #111 or so.
I think #000 is the way to go for OLEDs, though I'm not 100% sure. I imagine it'd be nice to configure it. #cf looks cute too for text, I guess it's not super important to be closer to #fff? Maybe we just have good eyes tho w.
Having contrast on the textarea with a different colour is definitely nice.
Any reason you're selecting on .admin td and .admin? I didn't dig into the DOM too much; I just went down news.css going through each selector with a color:, then inspected elements to make sure none got through.
The only new additions, similar to yours, is <body>, #hnmain, and textarea. input[type=text] could also be tackled, but I decided it was fine. Textarea is definitely a lot of bang for buck tho.
The .c5a, .c73, etc selectors are also important; those are for downvoted comments.
great point about #000. I didn't think about OLEDs.
I also followed the same recipe: I copied all things that changed `color` or `background` and tried as best as possible to change the minimum possible to get a dark mode.
Anyways, regardless of whether any solution makes it in the end, I found this whole exercise to be pretty interesting!
Whipped this up real quick... keeps the spirit of HN I think, and is pretty minimal. Not my best CSS but tables/current CSS make some selectors a little tricky and after all, it's less than 1kb added, no markup or stack changes needed, and this is 'Hacker News' right? :D
@media (prefers-color-scheme: dark) {
body { background-color: #1F2430; }
I just right clicked a few pages -> Save page as (static HTML/CSS/etc) then hack on the end of the news.css file. You can just append my css to that and you'll see exactly what I saw :)
I tweaked and combined two existing Stylus entries called "Hacker News Readable" and "Hacker News Readable Dark" to make a layout that changes from light to dark mode with the system settings. https://jsfiddle.net/DHepworth/e4kwpr9j/2/
to preview, folks can live edit this page in inspector and paste these styles into a style tag.
in firefox, F12 to open inspector, hit '+' in the style pane to insert a <style> tag (but don't add a rule), then right click the inserted tag in the inspector pane and "edit as html" to edit the html, and finally paste these styles inside the tag and click out of it.
Yes there is much better way.
Install Stylus plugin and copy and paste the same script (except meta tag) with rule on domain.
And it just works fine across all instances of domain.
For those who want something more traditional I've modified to have a slight orange tint on the title bar, and higher contrast for text. Seems to be better for a11y too.
Please don't. Strong contrast helps readability; grey-on-color is lower contrast than white-on-color.
Most HN threads linking to a site that has light-grey-on-dark-grey or dark-grey-on-light-grey text have at least one (off-topic) complaint about site style. Let's not make HN one of those sites.
HN is currently "black on very light background". The equivalent dark mode would be "white on very dark background". I hope we end up with either that, or even better, white on a black background (because that would be great for devices with OLED screens, including many phones).
For me strong contrasts, especially on dark backgrounds, give me retina burns and eyestrain. I find pastel shades more comfortable. That said the grey text on white fad that happened a few years ago was a very silly idea.
I guess everyone's mileages vary depending on their eyesight, my eye's are 53 years old now and aren't as spritely as they used to be.
Great point. Our environmental factors are so easy to forget. I do use a very high contrast monitor and definitely prefer pastel colors at night, so my eyes dont hurt, but now I can clearly see how someone with low contrast wont' see a damn thing.
There is a solution, but it's a bit more complicated and requires introducing additional user preferences. Supply two color options in the css, and allow user to choose high/low brightness.
HN already has some profile filters, so adding one more might not be a problem, but I can also see how it becomes a slipper-slope of new features.
Most modern monitors (and operating systems for that matter) have functions for day and night colour temperature schemes. I use it a lot since I love reading in bed but don't want to give night blindness to my other half.
If the OS has it, you can set it to gradually phase in and out of the temperature change at a particular time. The Radeon drivers go one step further by understanding that as the year progresses, "night" and "day" happen at different times.
I have three Dell 24" panels dating from 2005/7 ( 1 x 2405FPW and 2 x 2407FPW). They're not really what you'd call "high contrast" these days given their age.
I agree, that level of white usually gives me eye strain after several minutes, even in a well lit room. The readability mode of Firefox for example uses #eeeeee for the text and #333333 for the background [1], I'd suggest using the same tones which are still very high contrast but don't cause nearly as much strain.
Here's a version based on the one by ldd. Unlike the others I've seen posted, it maintains the original contrast, the orange header, and doesn't make the upvote button ugly.
awesome! yeah, the first couple of versions I posted had issues with dead links, and textareas.
Anyways, if @dang permits, we can start a github repo for this, until all the little issues are fixed. I just hope he sees that all of this can be done in just a few lines of code
This surprisingly works well. One thing, the background of body is still white for me on desktop this is what I have (combine with someone else who commented about the brightness):
Most solutions seem to be aiming for a quick fix. HN’s classes and HTML probably rarely change, but using css variables would lead to a more maintainable solution than duplicating all the selectors.
(I’d contribute a solution but currently moving across the country with only my phone available)
Are you ok with using CSS variables? Without them or some preprocessor, a dark theme would mean a lot of repeated selectors. https://caniuse.com/#feat=css-variables
Btw. TIL that you can use `comments > $x` in Algolia's search. That's a cool feature (didn't know about that) or use popular search engines' `:site` ...
I hadn’t heard this term before, and just read that an alligator can store up to 60% of the energy it gets from food as fat, mostly stored in the tail.
A large adult in average condition could survive two years or more without food!
Please, don't just force a dark mode to everyone with "prefers-color-scheme: dark".
Some are using OS in light mode, but would still like to use the dark mode. Sometimes, it might be useful to use the light version on dark systems. (e.g. if the dark css is not well made or looks bad on some monitors)
I agree. I think the default behaviour is good. prefers-color-scheme: dark should be the default, but be changeable browser wide (not sure if this is already the case) or per domain - just as it works with webcam access (storing the permission to view webcam for a given domain).
I get it, but at the end of the day it's up to a site owner, surely? Much like we get to choose our site design, we also get to choose whether it's dark or light. It has always been this way.
The CSS property is a good indicator that you prefer a dark color scheme. In my case by turning this on I want an all dark UI on everything I use - all the time. Do we really need to force toggles on every website we build now for a small number of users who want a dark browser UI, but light websites? I'd prefer to go with the assumption that they want the design dark too.
Firefox for iOS has an “Enable Night Mode” that does a great job with HN in dark mode. Maybe you can start with the Firefox iOS Night Mode CSS and minify from there...
If that works, we could also make a list of suggested color combos for people who want an easy solution and don't know much about design and don't want to spend a lot of time futzing with it.
And, I mean, the moderators don't have to make that list. The users could share what color combos work for them.
I've been using a "Hacker News Dark" userstyle [1] with Stylus for years, it's only ~30 lines of CSS with a permissive license (CC0). I'd love to see something like it integrated into HN itself.
It'd also be nice to have a way to enable the dark theme without logging in, alongside a persistent setting for logged-in users. A link in the header/footer to set a cookie is probably the simplest way to accomplish that.
Don't go the way of CSS filters. I tried some of the CSS people here pasted that used it and it is slow. When I scroll fast Firefox can't keep up and I see white background for a second or two before it renders.
Small request while you're at it: preformatted/code blocks don't display well on smartphones in portrait mode, as there's too much margin at the sides and scrolling becomes awkward. You can test it here:
text = '"The quick brown fox jumps over the lazy dog" is an English-language pangram—a sentence that contains all of the letters of the alphabet. It is commonly used for touch-typing practice, testing typewriters and computer keyboards, displaying examples of fonts, and other applications involving text where the use of all letters in the alphabet is desired. Owing to its brevity and coherence, it has become widely known.'
for i,c in enumerate(text):
print(i, ord(c))
Update: turns out that the margins problem also exists on desktop, but the problem doesn't cause as much problems there.
The CSS works well for me, but I understand presentation is highly subjective and some people may not like it.
Perhaps more important is that tiny bit of JavaScript in the readme.md so that anybody can rapidly experiment with CSS themes for Hacker News on live pages with just copy and paste.
This was my first time to do a deep dive into the front-end code of Hacker News and the HTML is archaic. If you would like I can help spruce it up to modern 2008ish HTML code that is fully semantic, accessible, and much better for SEO. Just let me know how I can help.
Still not a one step solution and its a bit different cross browser. Its not a one step solution because you have to either modify an identifier in the page to support another additional template or completely throw the default colors away so that the new colors replace the default colors.
The little one line JavaScript code is literally copy/paste which allows for moving between pages and page refreshes and pressing up arrow then enter on the keyboard to reapply the theme change without manually reapplying a new stylesheet and/or modifying the DOM each time.
I recently changed the "expand" part to say "[N more]" when N is the number of hidden comments. Since that's much longer than "[+N]", I assume that helps?
If so, we can change "[-]" to put some text in between the square brackets. In addition to being longer, that would also be nicely symmetrical. But what should the text be? "[collapse]" seems a bit too long, and also doesn't look right to me.
Edit: I'm all in favor of this question because I was just thinking about it this afternoon—but I've also detached this subthread from https://news.ycombinator.com/item?id=23199062 since it's not the same topic as dark modes.
Edit 2: ok, I made it use an n-dash ("[–]") instead of a hyphen ("[-]"), which expands it a tiny bit. I tried an m-dash but it looks too long.
I've had the problem, too, and this change (the edit 2) helps a lot!
The size is not ideal, but it's easily possible to zoom if required and resizing the whole line would probably have a slew of required changes with it, so kudos for finding a minimal 80% solution ;)
There are indeed lots of little things like that, but I don't see them as huge issues, whereas the lack of a dark mode is. So I'm personally going to respect the move-slow approach and only advocate the changes that I feel are truly essential :)
I would love a way to collapse the parent of a comment (or all it's children) without having to scroll up and find it by carefully tracking indentation. Some sites do this by drawing the tree of comments directly with vertical lines going down beside siblings, which can be clicked to collapse. That's a much bigger target.
I agree that navigation is an issue, especially with large threads. From my perspective it's strictly a UI question. I don't want to spoil HN's minimalism.
I've been thinking of experimenting with links in the comment line (the same place that the timestamp and "[-]" appear) which say things like "up" (to go to parent) and "next" to go to next sibling.
Hmm - but what if you want to retrace your steps? Say you're reading child #5 of a very large subthread, you click 'up' to go to the parent, which scrolls to the top of that subthread—and now you change your mind and want to go back to where you were. This seems like what the back button is for.
I'm all for not breaking the back button, believe me, but I fear that people may have very different notions of what that means.
NOOOO! Why not a check box in the profile page? There is already a place for changing the colors. Can we please not add any javascript? The server remembers my topbar color. It can remember a boolean flag too.
I have to disagree that dark mode should the default.
It'd be fine to offer that as an option, but I'm not really seeing any reason at all why that should be default and I recall a few posts here where quite a few other's expressed they were not fans of dark mode themes.
To be fair, I never browse this or most any other web site on a phone, so, maybe apply that to phones only if that's an option.
An essential addition/alternative to dark mode is automatic light filtering/dimming software. There are great apps out there for both mobile and desktop that filter blue light and dim your screen according to sunrise/sunset. e.g. https://justgetflux.com/
I wouldn't vote against the existence of a dark mode - why not make it an option - but I strongly vote against making it default. If your monitor is throwing out so much light that you're getting eye strain, you need to turn down the brightness of your monitor or phone screen.
For myself, most of the time my monitors are set to a maximum of around 30 on a scale of 100, and I don't get any eyestrain. Dark mode with a properly calibrated monitor, in contrast, does give me eye strain - the light letters on the dark background don't play well with my Keratoconus.
Right now, with HN defaults, at around 7pm, the brightness is 15, and contrast is 30.
Changing the monitor twice a day is quite a pain. Perhaps you're thinking of laptops and phones where this isn't a big deal, but external screens' brightness can't be controlled that way. And I'm not sure I'd want my main driver to adjust: at brightness levels where I can read HN without feeling like a vampire, I wouldn't be able to read some of the lower contrast syntax-highlit text in my terminal anymore.
468 comments
[ 3.7 ms ] story [ 309 ms ] threadMaybe if we had plan9 machines or lisp machines, we would be able to do that very easily.
I wonder how different computing would look.
Dark mode would be nice though.
More seriously: I've never seen a proposed "spruce-up" that didn't either add too much whitespace or too little (well, always the former), which makes me think that the current design is in the ballpark of optimal, despite its being unfashionable. Also, HN is very much a text site, a fact that goes much deeper than look-and-feel. The first thing most "spruce-ups" do is toss this quality, which compromises the site at its essence and indicates a misunderstanding of what HN is. I'm reminded of Steve Jobs' famous line about how design is not how-it-looks but how-it-works.
If someone did a redesign of HN that preserved both its information density and its textiness, I'd be stoked to see it as an experiment. We probably wouldn't change the site much, because if there's one force stronger than user complaints about design, it's user complaints about design changes. Also, I think it's an advantage for HN to have an unfashionable design, and a huge advantage to have a stable design. Still, I'd be fascinated to see it, and there might be ideas we could use.
A less controversial solution would be to simply hook into the user's system-level light/dark setting: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
That said, I've wanted this feature desperately for a long time. Browsing HN on my desktop monitor in the evening is blinding and gives me a headache. I find myself resizing the window to be phone-sized just so my eyes are assaulted with less light.
If you need a hand with the CSS, I'd be happy to write it myself (speaking of which; is HN open-source?)
No, but also yes, but mostly no: https://news.ycombinator.com/item?id=23191206
I added themes to the Anarki forum a while ago[0], along with a quick and dirty dark theme. Please ignore the garbage quality of my PR and code, but if the HN devs want to rip it off they're welcome to.
[0]https://github.com/arclanguage/anarki/pull/171/files
If it's simple to add and isn't going to break anything for anybody, we'd be happy to.
Edit: ok, as I understand it, it's simple enough to add except that you have to figure out what the color scheme for dark mode should actually be. Is that accurate?
Edit: see https://news.ycombinator.com/item?id=23199062.
In the middle of the day my monitor tops out at about 30 of 100, and in the evenings I will occasionally turn it down to about 5 or 10. Many modern monitors will offer an option to save multiple settings, or they at least make brightness a top level configuration setting.
EDIT: Is saying "If your monitor is hurting your eyes, turn it down," really such a controversial statement?
Not everything has a dark mode available, so make sure that the worst case is tolerable.
Most desktop monitors have their brightness & other config exposed via the DDC (DDC?) protocol. This is a simple UI that exposes the brightness controls on Windows. Much easier than using the buttons.
You might need to go to the monitor's menu and enable DDC if it's disabled by default.
On Linux this script works for me:
sudo modprobe i2c-dev; sudo ddcutil setvcp 10 $1 &
On macOS I've been using https://github.com/the0neyouseek/MonitorControl -- which also lets you use the brightness keys to control external monitors.
Just realize when you use them as a justification for changing defaults which work fine for most everyone else, you're going to annoy people. Especially when your preferences tend to fly in the face of common sense.
It’s also an accessibility issue, but that’s a comment for a different article.
we can even start a github repo, if anyone feels so inclined to do so
[0]: https://pastebin.com/4JYbSi5F
[edit: shorter, fixed top bar version: https://pastebin.com/dT4KKt3s ]
[edit 2: fixed textarea, dead links: https://pastebin.com/CKy4HQXE ]
It takes 15 seconds and you will have solved your problem.
In the dark reader popup window you can set the Mode; the default of Dynamic does an excellent job of making everything dark but is pretty slow. The other modes have basically no performance impact but you might see some visual bugs from time to time.
But the management is very tolerant of and even warmly welcomes the fact that the membership includes a lot of programmers and we tend to get a lot of third party solutions.
Off the top of my head, I don't know of an HN reader thingy in dark mode, but asking if those exist is much more likely to get you an immediately available solution than asking management to alter the appearance of HN in some specific way.
I understand and respect the general philosophy, but I fail to see how this particular request could be anything but a strict improvement.
Feel free to prove me wrong and talk management into making such a change. But talking at me to convince me I'm wrong is probably not really the way to do that. I have zero decision-making authority in this matter.
For news.ycombinator.com - https://pastebin.com/K1KS64KR
For hn.algolia.com (the search form) - https://pastebin.com/ksH6QcV4
Desktop Safari does, surprisingly, and I use it there.
Firefox removed that feature.
There are extensions, but browser extensions are a massive security hole so I don't use any that aren't too-big-to-be-corrupted.
In this case, you would only be able to affect your own version of the site, so any attack vector is mitigated
https://apps.apple.com/in/app/hack-for-hacker-news-developer...
We can add CSS to https://news.ycombinator.com/news.css for prefers-color-scheme: dark, but that leaves open the question of specifically what CSS to put in there. Anyone who wants to make a suggestion is welcome to. Post it in this thread so others can comment, or email it to hn@ycombinator.com. I've roped Zain, YC's designer, into helping with this, and we'll come up with something.
p.s. If you're inclined to post "this is 2020, how come HN doesn't $thing", remember our motto: move slowly and preserve things: https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que.... When I say slowly I mean slowly. This is also called alligator energy. https://news.ycombinator.com/item?id=16442716
;)
I haven't inspected their quality or thoroughness myself, but it seemed like a certain amount of that was implied
However, someone who is plugged into Reddit told me that they used to allow user-defined CSS for customizing subreddits and had to roll it back because of security issues. They built an entire customization UI instead. That scared me off the idea.
My fear with a customization UI—the HN equivalent of which would be profile settings, as you indicate—is that it would get way too complicated too quickly. How many additional settings would we need?
If someone can define a not-too-complicated set of profile settings which, when filled in to taste, would solve people's dark-mode concerns, I'm all for it. We could even make a separate editor page for it and link to that from the profile. The other constraint is: for each setting, the input format would need to be simple to sanitize (e.g. 'valid hex color'). Otherwise we just create the security issue all over again, only with a shitty nonstandard application-level CSS editor instead of standard CSS.
I posted a possible solution in another comment here[0]. You would have to write a separate dark theme, and there would be a single option to select it in the user panel. The data is literally just an integer pointing to an index in a whitelist of css filenames, and any errors would default to displaying the existing stylesheet.
[0]https://news.ycombinator.com/item?id=23198711
There could be cross-site scripting attacks whereby the user clicks on something evil in a malicious site which attacks that user's HN authenticated session by installing some malicious CSS in their profile. The UI could require a confirmation of the account password for updating any security-sensitive properties.
Users could also shoot themselves in the foot with bad CSS. The obvious fix for that is that the profile settings page itself doesn't inject the CSS, or there is a safe variant of its URL which doesn't inject CSS.
For example, I’d hide the “hide” links on the main page. I’m sure some people love that feature, but I’ve only ever used it accidentally (fatfingering on mobile).
I’d add a bunch of additional hiding CSS. I’ve long wanted a “helps-me-respect-my-time” version of HN, where voting buttons, flag links, reply boxes, and reply links are all hidden.
What.cd used to let you put a url in your settings that was injected as the stylesheet while you were logged in. This approach would let people publish and share themes--though shared themes could be a (pretty visible) security concern.
I remember also running into issues trying to use non-https-served stylesheets since the site was https and browsers balked.
[0] https://news.ycombinator.com/item?id=23199725
P.S. I hurried to this thread because I noticed that the ‘collapse comment’ links became larger on my phone and I can finally hit them on the first try. Thanks to whoever did that, sincerely! Though personally I'd encourage you/them to make the link three times wider still, to take away even more effort. Dunno if it's much visual noise to others, but at least I don't think it encroaches on other elements.
Btw, another hopefully-not-controversial change that I would make is to have the post text black, not gray. It's a pretty important element, isn't it? So it should have high contrast and be readable.
don't worry, we'll make sure we don't pull a reddit on you ;)
It uses prefers-color-scheme and 28 lines of CSS:
https://pastebin.com/4JYbSi5F
https://pastebin.com/dT4KKt3s
From all of my heart: Thank you!
As a shareholder of reddit, that hurts.
As a user of reddit and HN, thank you, I couldn't agree more.
Keeping something the way it is, is super hard in tons of ways a lot of us probably don't understand. We appreciate you.
HN design is simply the best thing out there. "Moving slowly and preserving things" - I would get this engraved on my grave. This philosophy has died unfortunately and with it went robustness, simplicity, elegance, poise, beauty, accessibility, elegance, maintainability and practicality.
Thanks dang for your gandalf-like wisdom and your resilience. I like Alligators over goddamn mosquitos that have taken over the internet.
Please dang!
https://caniuse.com/#search=css%20variables
https://stackoverflow.com/questions/44271920/css-variables-w...
I second the other commenter, don't do anything. Or get someone really good to help you!
https://userstyles.org/styles/113994/hacker-news-dark
Edit: my fault. I have too many dark mode addons/stylesheets enabled at the same time.
Midnight lizard (chrome) https://chrome.google.com/webstore/detail/midnight-lizard/pb... is a good extension that can create a dark theme by changing the contrast & things like that. It does it in a way that the same theme will work on a lot of sites. They do have more dark (& light) themes on their site & you can create your own by entering a few colors & it will create a theme based on that. Stylus is good (NOT stylish), but Midnight lizard creates themes in a way that are compatible with a lot more sites that Stylus.
None of the extensions I've tested can match the dead simple CSS override I used in qutebrowser.
old.reddit.com comments are mostly unreadable, and it cripples gmail, but I've learned to take advantage of Options-Shift-D to flip it on and off when needed.
It's now part of my web browsing workflow.
Edit:
To clarify what I mean is maybe toggling which style sheet HN gives you in settings would be ideal for all. Web standards are nice but they dont help in the minimalist ideals of HN too much.
(http://i.9ol.es/dark.png)
Could you imagine if we entrusted every website to independently implement scroll bars and zoom? What a mess that'd be.
The color pallete of a page is important, and maintaining a consistent look and feel across normal and dark mode can only be done reliably by each website's designer.
So I guess we need both the ability to have the browser auto-calculate a default dark mode, and a way for aestetically-conscious web designers to override it, and that's what we're moving towards.
In fact it's already in chrome on android, no work needs to be done (other than enabling it). Here's an image gallery guide I made: https://imgur.com/a/njNTO6T
This is the right approach, it should be solved at the browser level. In fact, it already is.
The only responsibility of web developers should be to not go out of their way and do silly things that break this.
High contrast is very useful for people with visual difficulties, but might even be counter-productive for certain types of eye strain.
I'm under the impression people asking for dark mode are looking for something that will emit less light off their screens, not necessarily make it look nore contrast-y, and the two are more often than not opposite.
https://caniuse.com/#feat=prefers-color-scheme
Thanks!
What’s the tool chain manager look like for managing the build process manager?
I don't know how to feel about that.
In comparison, the pure-CSS ideas that some people are posting would work automatically if your browser supports dark mode, and would enlarge the (cached with long ttl) CSS file only very slightly.
Pure CSS would be quite cool, but we'd probably also need a snippet of JS to add a button allowing to switch between light and dark mode. (There's probably a way to do it without JS that someone will hopefully comment too.)
A separate subdomain:
- Requires separate TLS certificates to be maintained.
- Doesn't play nice with caching.
- Doesn't play nice with password managers.
- Doesn't work with any existing links. Users would have to manually add the `dark` prefix.
- Is generally a bad user experience.
> Doesn't play nice with password managers.
Check your password manager settings. Most have options to match on domain, subdomain, port or have the ability to set equivalent domains either globally or per credential.
Seems like a fun project, so I may start planning it when I have time.
[1] https://www.eff.org/deeplinks/2019/09/victory-ruling-hiq-v-l...
I was more thinking about a local web-app that consumes the site and then outputs it in a nice mobile layout, without actually archiving or saving anything.
Truthfully, there is some Javascript. For example, onclick(). Voting without Javascript requires some extra effort.
While I understand and agree with your point, I have personally found this quoted portion to be a false assumption.
To me, "works" means I can retrieve the content of the page without using JS. If the websites we are discussing are ones where the primary purpose is reading, like HN, most will "work" for me without JS, so long as I do not rely on try using a "modern browser" to retrieve the content. In fact, I cannot even think of a single website meant for reading that I cannot read without a Javascript-enabled browser.
That's not much readable without some trickery
Name any newspaper website you think is "not much readable" without Javascript or cookies and I can prove that is a false assumption.
Thanks for the riddle! I guess you could use iframes?
Edit: Ohhh and you could use data-urls as iframe src, so as not to make a large number of requests.
I'm not a programmer, so I'm probably saying something incredibly, fantastically stupid. Take this in the spirit of "Brainstorming" where you say even the stupid stuff because that sometimes leads to good things.
I am not a programmer, but I do know some HTML and CSS and studied it a bit and Blogger (aka Blogspot) let's you dig in the code of the theme if you want, but it also has a user-friendly section where you can change colors and stuff and it let's you "add CSS" there and I do add CSS snippets there to tweak my websites.
I have tried digging in the code a few times. It's never worked for me. But adding CSS snippets is something I can handle.
You already have a feature to select your top bar color. Would it be feasible to expand that feature a little to let people select dark mode colors? (Ie to change more colors than just the top bar.)
https://chrome.google.com/webstore/detail/witchcraft-jscss-i...
I use it for a bunch of minor HN mods already, and it's great :)
I have no plans at this time to go to a third party service for this or add an extension. Though I have been thinking since I wrote the above of changing my top bar color.
I'm fine with HN moving slow and preserving things. That works for me. But the only way I will go to dark mode on HN is if it is possible to somehow do that through HN.
Maybe someday I will change my mind about that. But not today.
Being able to add some custom user definable CSS visible just for you on HN sounds like a great idea to me.
https://pastebin.com/4JYbSi5F
[edit]: fixed, shorter version: https://pastebin.com/dT4KKt3s
[edit 2: fixed textarea, dead links: https://pastebin.com/CKy4HQXE ]
[edit 3: added a screenshot: https://imgur.com/a/Ont553x ]
This could be a check in preferences, load from the DB the same time as the top bar, then insert into template or however HN is organized server side. Probably <10 lines of total code, If you include DB changes.
It would be all server side so we shouldn’t have an issue in terms of bandwidth.
I would kindly invite you to skim the CSS suggestions that others made in the thread. It's not as simple as that.
#eee for text colour.
#000 for bg (body, #hnmain)
#hnmain's background is set with an HTML attribute, !important might be necessary for some browsers? Not sure, but works on my machine(tm).
Edit: s/html/body/, wasn't necessary to select on <html>. Split body and #hnmain selectors.
Upvote arrows blend with white instead of transparent, giving a weird look.
The orange goes well with black.
Not all users might want #000, but for OLEDs it's gorgeous.
The @media selector requires a OS/Browser support, to extend that a simple way is programatically add a .dark class to <body> (edit: based on a checkbox in their profile), and add selectors with .dark.
Some colours on the site are hardcoded, like the orange asterisk on your own comments, and newbie green. They both go fine with #000 imo.
Edit: tested on the other pages, looks good imo. Login/logout don't have CSS, which'd be a bit jarring.
It's a bit sad there's no distinction between the #hnmain and the background anymore, I think if that were desirable I'd probably change <body> to #111 or so.
1. https://0x0.st/iLYb.txt
https://pastebin.com/CKy4HQXE [I'm not parent]
let me know what you think ;D
I think #000 is the way to go for OLEDs, though I'm not 100% sure. I imagine it'd be nice to configure it. #cf looks cute too for text, I guess it's not super important to be closer to #fff? Maybe we just have good eyes tho w.
Having contrast on the textarea with a different colour is definitely nice.
Any reason you're selecting on .admin td and .admin? I didn't dig into the DOM too much; I just went down news.css going through each selector with a color:, then inspected elements to make sure none got through.
The only new additions, similar to yours, is <body>, #hnmain, and textarea. input[type=text] could also be tackled, but I decided it was fine. Textarea is definitely a lot of bang for buck tho.
The .c5a, .c73, etc selectors are also important; those are for downvoted comments.
I also followed the same recipe: I copied all things that changed `color` or `background` and tried as best as possible to change the minimum possible to get a dark mode.
Anyways, regardless of whether any solution makes it in the end, I found this whole exercise to be pretty interesting!
Whipped this up real quick... keeps the spirit of HN I think, and is pretty minimal. Not my best CSS but tables/current CSS make some selectors a little tricky and after all, it's less than 1kb added, no markup or stack changes needed, and this is 'Hacker News' right? :D
@media (prefers-color-scheme: dark) { body { background-color: #1F2430; }
}Edit: missed a few on other pages! Added arrow CSS patch, added screenshot from imgur, added text input colors for profile and replies.
I want to try out the different styles in the comments, but I'm hesitant to upvote until I see for myself what it looks like.
to preview, folks can live edit this page in inspector and paste these styles into a style tag.
in firefox, F12 to open inspector, hit '+' in the style pane to insert a <style> tag (but don't add a rule), then right click the inserted tag in the inspector pane and "edit as html" to edit the html, and finally paste these styles inside the tag and click out of it.
Screenshot: https://imgur.com/a/XW1OCYb
@media (prefers-color-scheme: dark) { body { background-color: #232834; }
}edit: fixed imgur link and added full css
I've added this code to fix the reply textarea colour:
.fatitem textarea { background-color: #232834; color: #fafafa; }
Most HN threads linking to a site that has light-grey-on-dark-grey or dark-grey-on-light-grey text have at least one (off-topic) complaint about site style. Let's not make HN one of those sites.
> Let's not make HN one of those sites.
The OP of the thread you are replying to is #828282 on top of #f6f6ef. That is lower contrast than black on white.
Either it is already one of those sites or there is room between the most extreme contrasts. Pick one.
I guess everyone's mileages vary depending on their eyesight, my eye's are 53 years old now and aren't as spritely as they used to be.
This is something I don't like about VS Code. by being low contrast it means I have to turn up monitor contrast meaning everything else burns.
There is a solution, but it's a bit more complicated and requires introducing additional user preferences. Supply two color options in the css, and allow user to choose high/low brightness.
HN already has some profile filters, so adding one more might not be a problem, but I can also see how it becomes a slipper-slope of new features.
If the OS has it, you can set it to gradually phase in and out of the temperature change at a particular time. The Radeon drivers go one step further by understanding that as the year progresses, "night" and "day" happen at different times.
https://contrastrebellion.com/
[1]: https://www.theregister.co.uk/2019/07/10/firefox_68_arrives_...
Maybe try to swap the #fafafa rule with #eaeaea? Does that feel better? It's still very high contrast so maybe that could be a happy medium.
Can I create stylus theme out of this share it?
I have this as a bookmark and work well in many cases.
For those of you asking, feel free to do whatever you want with this CSS ^_^
https://gist.github.com/deleerium/ca6ddeed5dc07a81f764a83ecd...
https://0x0.st/iLYb.txt
EDIT: one problem. The header image on pages like[1] doesn't look good. Can you change the white background to transparency?
https://news.ycombinator.com/newsfaq.html
Anyways, if @dang permits, we can start a github repo for this, until all the little issues are fixed. I just hope he sees that all of this can be done in just a few lines of code
Had the same problem, changed "body" to "html", added background: #fff, now it works.
I turned it into a bookmarklet to make it easy to use on any website:
javascript:styles='html {filter: invert(1) hue-rotate(180deg) brightness(.9); background-color: #fff; }'; newSS = document.createElement('style'); newSS.type = 'text/css'; newSS.innerHTML = styles; document.documentElement.getElementsByTagName('head')[0].appendChild(newSS);void(0);
(I’d contribute a solution but currently moving across the country with only my phone available)
CSS:
@media (prefers-color-scheme: dark) { body { color:#cccccc; background-color: black } center>table { background-color: #222222;} td { color:#cccccc; } .admin td { color:white; } .subtext td { color:white; }
}it's a good hack to save you a bunch of dev setup time or if you have a production only issue.
happy hacking
Btw. TIL that you can use `comments > $x` in Algolia's search. That's a cool feature (didn't know about that) or use popular search engines' `:site` ...
I hadn’t heard this term before, and just read that an alligator can store up to 60% of the energy it gets from food as fat, mostly stored in the tail.
A large adult in average condition could survive two years or more without food!
https://books.google.com/books/about/Alligators.html?id=0UDL...
https://imgur.com/a/WZAaJST
I don't love when dark modes skew blue, so tried to keep it neutral with blacks and greys
``` @media (prefers-color-scheme:dark) { body { background-color: #2a2b2e; } #hnmain { background-color: rgb(32, 33, 36); }
} ```I like this scheme quite a bit. The white text on the orange bar is the only part I struggle with.
Why do you prefer neutral schemes?
Source for a CSS simlpe arrow https://css-tricks.com/snippets/css/css-triangle/
Some are using OS in light mode, but would still like to use the dark mode. Sometimes, it might be useful to use the light version on dark systems. (e.g. if the dark css is not well made or looks bad on some monitors)
Here's a good thread about it: https://twitter.com/SaraSoueidan/status/1245722023361380354
The CSS property is a good indicator that you prefer a dark color scheme. In my case by turning this on I want an all dark UI on everything I use - all the time. Do we really need to force toggles on every website we build now for a small number of users who want a dark browser UI, but light websites? I'd prefer to go with the assumption that they want the design dark too.
If your browser tells the website you want a dark version, you’re getting a dark version. Seems right, doesn’t it?
I have no issues with 3 options:
- Use browser
- Light
- Dark
Though. I think it’s too much configuration though.
And please, don't _force_ the theme by using prefer-color-scheme. Use it as default, but please give the option to override it.
And, I mean, the moderators don't have to make that list. The users could share what color combos work for them.
It'd also be nice to have a way to enable the dark theme without logging in, alongside a persistent setting for logged-in users. A link in the header/footer to set a cookie is probably the simplest way to accomplish that.
[1]: https://userstyles.org/styles/113994/hacker-news-dark
[1] https://i.imgur.com/ZfoXaem.png
Parts changed [HTML]: <body style="background-color: #1a1a1a;"> <table bgcolor="#2a2a2a"> <img src="y18.gif" style="border:1px #353535 solid;">
Parts changed [CSS]: a:link { color:#808080; text-decoration:none; } .subtext { font-family:Verdana, Geneva, sans-serif; font-size: 7pt; color:#606060; } .subtext a:link, .subtext a:visited { color:#606060; }
Header links: #b5b5b5 Header link divider: #666
+darker icons
is that just me? phones work fine, laptops work fine. But iPad pro 12.9" has been like that since the release of 13
a "normal" dark mode and one for oled screens which has the background straight black
The CSS works well for me, but I understand presentation is highly subjective and some people may not like it.
Perhaps more important is that tiny bit of JavaScript in the readme.md so that anybody can rapidly experiment with CSS themes for Hacker News on live pages with just copy and paste.
This was my first time to do a deep dive into the front-end code of Hacker News and the HTML is archaic. If you would like I can help spruce it up to modern 2008ish HTML code that is fully semantic, accessible, and much better for SEO. Just let me know how I can help.
There isn't a cross-browser one step way to swap CSS files on live pages that I am aware of, especially if CSP is enabled as is the case with HN.
The little one line JavaScript code is literally copy/paste which allows for moving between pages and page refreshes and pressing up arrow then enter on the keyboard to reapply the theme change without manually reapplying a new stylesheet and/or modifying the DOM each time.
The source code: https://github.com/fdzh/anarki/commit/5a58ef38111215258a2694...
BTW, I would recommend using Eigengrau rather than total black. https://twitter.com/AustinTByrd/status/1105822085362925568
Because the site is so simple, it already works really well on mobile. But these tiny little buttons ruin the experience for me, and I'm sure others.
If so, we can change "[-]" to put some text in between the square brackets. In addition to being longer, that would also be nicely symmetrical. But what should the text be? "[collapse]" seems a bit too long, and also doesn't look right to me.
Edit: I'm all in favor of this question because I was just thinking about it this afternoon—but I've also detached this subthread from https://news.ycombinator.com/item?id=23199062 since it's not the same topic as dark modes.
Edit 2: ok, I made it use an n-dash ("[–]") instead of a hyphen ("[-]"), which expands it a tiny bit. I tried an m-dash but it looks too long.
The size is not ideal, but it's easily possible to zoom if required and resizing the whole line would probably have a slew of required changes with it, so kudos for finding a minimal 80% solution ;)
I've been thinking of experimenting with links in the comment line (the same place that the timestamp and "[-]" appear) which say things like "up" (to go to parent) and "next" to go to next sibling.
I'm all for not breaking the back button, believe me, but I fear that people may have very different notions of what that means.
Also, how would you see the black bar when someone dies?
I missed that in the OP, probably because it's so far beyond what we'd do that I didn't even notice that bit.
I've edited https://news.ycombinator.com/item?id=23199062 to make this clearer.
const getAttributes = () => {
};const changeStyles = (targetElement) => {
style = document.createElement("style");
};(function main() { const { ...attributes } = getAttributes(); changeStyles(attributes.head); })();
It'd be fine to offer that as an option, but I'm not really seeing any reason at all why that should be default and I recall a few posts here where quite a few other's expressed they were not fans of dark mode themes.
To be fair, I never browse this or most any other web site on a phone, so, maybe apply that to phones only if that's an option.
For myself, most of the time my monitors are set to a maximum of around 30 on a scale of 100, and I don't get any eyestrain. Dark mode with a properly calibrated monitor, in contrast, does give me eye strain - the light letters on the dark background don't play well with my Keratoconus.
Right now, with HN defaults, at around 7pm, the brightness is 15, and contrast is 30.
In short, yes, external monitors can be adjusted on the computer.
As for the rest, it’s not as if you’re stuck with one choice of color scheme for your editors either.
Any science behind that claim?
1. Go to chrome://flags
2. Enable "Force Dark Mode for Web Contents"
This works pretty well on all sites, not just hacker news...
And you can easily click to install with a browser extension like https://add0n.com/stylus.html