Lurker News
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?

Comments (445) 93 threads

Show all comments

Showing thread 14 of 93

badrchoubai1 reply#
This is code for an extension I run locally.

const getAttributes = () => {

  let head = document.head || document.getElementsByTagName("head")[0];

  return {
    head,
  };
};

const changeStyles = (targetElement) => {
style = document.createElement("style");

  // set style.innerHTML to darker colors, append to head
  style.type = "text/css";
  style.innerHTML = `
    body, #hnmain { background: #272822; }
    a.storylink, a.morelink, span.commtext { color: #fff; }
    a.storylink:visited { color: #444444; }
  `;
  targetElement.appendChild(style);
};

(function main() { const { ...attributes } = getAttributes(); changeStyles(attributes.head); })();

fermienrico2 replies#
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.
jypepin#
I think he shared this in case others want to use this to update their hn theme locally, not for hn to implement this...
badrchoubai#
Actually I wonder if I could implement that with the extension, that would be nice.