Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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