public
Created

hacker news user filter

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
var users = {
"friend" : 1,
"foe" : 0
};
 
$("<style type='text/css'>span.djs-highlight { font-weight: bold; }</style>").appendTo("head");
 
function traverseFromUserLink(el) {
return $(el).closest('td').find('span.comment');
}
 
function hideIt(userLink) {
traverseFromUserLink(userLink).html("[blah blah blah blah]");
}
 
function highlightIt(userLink) {
traverseFromUserLink(userLink).addClass("djs-highlight");
}
 
$('span.comhead a[href^="user?id="]').each(function(index, userLink){
var user = $(userLink).text();
if (users[user] === 0) {
hideIt(userLink);
} else if (users[user] === 1) {
highlightIt(userLink);
}
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.