Skip to content

Instantly share code, notes, and snippets.

@chadlavi
Last active June 18, 2020 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadlavi/888a0889dadf82a60ba0f32017a5e9cb to your computer and use it in GitHub Desktop.
Save chadlavi/888a0889dadf82a60ba0f32017a5e9cb to your computer and use it in GitHub Desktop.
automatically click "hide" on ads in hackernews
// ==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