Skip to content

Instantly share code, notes, and snippets.

@mixu
Created October 7, 2011 17:49
Show Gist options
  • Save mixu/1270915 to your computer and use it in GitHub Desktop.
Save mixu/1270915 to your computer and use it in GitHub Desktop.
HN steveblock
// ==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