Skip to content

Instantly share code, notes, and snippets.

@maurizi
Created July 20, 2019 16:41
Show Gist options
  • Save maurizi/65ea6676cbd94451b1846048a864b636 to your computer and use it in GitHub Desktop.
Save maurizi/65ea6676cbd94451b1846048a864b636 to your computer and use it in GitHub Desktop.
Hide old news on HN
// ==UserScript==
// @name Hide old news
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hides old articles on Hacker News
// @author Mike M
// @match https://news.ycombinator.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addGlobalStyle (css) {
var head, style
head = document.getElementsByTagName('head')[0]
if (!head) { return }
style = document.createElement('style')
style.type = 'text/css'
style.innerHTML = css
head.appendChild(style)
}
addGlobalStyle('tr.old-news:not(:hover), tr.old-news:not(:hover) + tr, tr.old-news:not(:hover) + tr + tr { opacity: 0.1; }');
document.querySelectorAll('.storylink').forEach(node => {
if (/\(\d+\)/.test(node.textContent)) {
const tr = node.closest('tr');
tr.classList.add('old-news');
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment