Last active
June 18, 2020 20:33
-
-
Save chadlavi/888a0889dadf82a60ba0f32017a5e9cb to your computer and use it in GitHub Desktop.
automatically click "hide" on ads in hackernews
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 No ads on HN | |
// @version 0.0.1 | |
// @author Chad Lavimoniere | |
// @grant none | |
// @include https://news.ycombinator.com/* | |
// @downloadURL https://gist.github.com/chadlavi/888a0889dadf82a60ba0f32017a5e9cb/raw/no-ads-hn.user.js | |
// @updateURL https://gist.github.com/chadlavi/888a0889dadf82a60ba0f32017a5e9cb/raw/no-ads-hn.user.js | |
// ==/UserScript== | |
document.querySelectorAll('td.subtext').forEach(cell => { | |
const text = cell.innerText | |
// ads don't have points listed in their subtext lines, so any subtext | |
// line that doesn't contain the string "point" is proably an ad | |
if (!text.match(/point/)){ | |
const links = cell.querySelectorAll('a') | |
links.forEach(link => { | |
if (link.innerText === 'hide') { | |
console.log('clicking "hide" link') | |
link.click() | |
} | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment