Skip to content

Instantly share code, notes, and snippets.

@beenotung
Last active May 2, 2020 22:05
Show Gist options
  • Save beenotung/f282dd39376b042841751f3536e616d6 to your computer and use it in GitHub Desktop.
Save beenotung/f282dd39376b042841751f3536e616d6 to your computer and use it in GitHub Desktop.
user script to improve readability and night mode for hackers news
// ==UserScript==
// @name hackers-news
// @namespace http://tampermonkey.net/
// @version 0.1
// @description improve readability and night mode for hackers news
// @author You
// @match https://news.ycombinator.com/item?id=*
// @match https://news.ycombinator.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
let style = document.createElement('style');
style.textContent = `
body > center > table {
max-width: 40em
}
a,td,.comment {
font-size: 1.25em;
line-height: 1.6;
}
`;
function isNight() {
return true // TODO use the clock to determine
}
if (isNight()) {
style.textContent += `
body {
filter: invert(100%);
background: black;
}
*, .c00 {
color: #333;
}
/* the header */
td[bgcolor] {
background: white;
}
`
}
document.body.append(style);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment