Created
April 14, 2019 20:03
-
-
Save m00g00/e539ec22bf588edca0e6dfe1a05eb60c to your computer and use it in GitHub Desktop.
Hacker News filter out domains/keywords. Edit filter_out array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Unnamed Script 714923 | |
// @version 1 | |
// @grant none | |
// @match https://news.ycombinator.com/* | |
// ==/UserScript== | |
var filter_out = [ | |
'NY Times', | |
'nytimes.com' | |
]; | |
var renumber = true; | |
[...document.querySelectorAll('.sitestr'), ...document.querySelectorAll('a.storylink')] | |
.filter(e=>filter_out.some(ee=>e.textContent.match(ee))) | |
.map(e=>e.closest('tr.athing')) | |
.forEach(e=>{ | |
for (let i=0,ee=e,nee; i<3; i++) { | |
nee = ee.nextElementSibling; | |
ee.parentNode.removeChild(ee); | |
ee = nee; | |
} | |
}); | |
if (renumber) { | |
let snum; | |
document.querySelectorAll('.rank') | |
.forEach((e,i)=>{ | |
if (!snum) snum = +e.textContent.match(/\d+/)[0]; | |
e.textContent = (snum++)+'.'; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment