Created
October 7, 2011 17:49
-
-
Save mixu/1270915 to your computer and use it in GitHub Desktop.
HN steveblock
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 Hacker News Steve Filter | |
// @description Filter "Hacker News" items about Steve Jobs | |
// @include http://news.ycombinator.com/* | |
// ==/UserScript== | |
(function(){ | |
var list = ['steve', 'jobs', 'job\'s']; | |
// get spans | |
d = document.getElementsByTagName('td'); | |
var links = []; | |
for(var i = 0; i < d.length; i++) { | |
var elem = d[i]; | |
if(elem.getAttribute('class') == 'title') { | |
links.push(elem); | |
} | |
} | |
function removeHN(elem) { | |
var parent = elem.parentNode; | |
var pointsNode = parent.nextSibling; | |
var spacerNode = pointsNode.nextSibling; | |
parent.parentNode.removeChild(spacerNode); | |
parent.parentNode.removeChild(pointsNode); | |
parent.parentNode.removeChild(parent); | |
} | |
links.forEach(function(elem){ | |
if(list.some(function(word){ | |
console.log(elem.innerHTML.toLowerCase(), word, elem.innerHTML.toLowerCase().match(word)); | |
return elem.innerHTML.toLowerCase().match(word); | |
})) { | |
removeHN(elem); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment