Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name hotentry_cleaner
// @namespace hotentry_cleaner
// @include http://b.hatena.ne.jp/*
// ==/UserScript==
(function() {
//TODO
//Input tags you want to eliminate them from Hatena Bookmark hotentry pages.
//In default, entries which were tagged as Facebook, iPhone and iPad will be eliminated.
var ngtags = ['facebook', 'iphone', 'ipad'];
function lowerAll(strings){
result = [];
for(var i = 0; i < strings.length; i++){
result[i] = strings[i].toLowerCase();
}
return result;
}
function findEntries(){
var xp = '//ul[contains(concat(" ",normalize-space(@class)," "), " hotentry ")]/li';
var entries = document.evaluate(xp, document, null, XPathResult.ANY_TYPE, null);
return entries;
}
function isInclude(entry, ngtags){
var xp = "div/ul/li[2]/a";
var tags = document.evaluate(xp, entry, null, XPathResult.ANY_TYPE, null);
var tag = tags.iterateNext();
while(tag){
for(var i = 0; i < ngtags.length; i++){
if(tag.innerHTML.toLowerCase() == ngtags[i]){
return true;
}
}
tag = tags.iterateNext();
}
return false;
}
function evaluateEntries(entries){
var entry = entries.iterateNext();
var eliminates = [];
while(entry){
if(isInclude(entry, ngtags)){
eliminates.push(entry);
}
entry = entries.iterateNext();
}
return eliminates;
}
function eliminateEntries(entries){
for(var i = 0; i < eliminates.length; i++){
eliminates[i].style.display = "none";
}
}
ngtags = lowerAll(ngtags);
var entries = findEntries();
var eliminates = evaluateEntries(entries);
eliminateEntries(eliminates);
})();
@kokutoto

This comment has been minimized.

Copy link
Owner Author

@kokutoto kokutoto commented Oct 19, 2010

特定のタグが付いたホッテントリを非表示にするGreasemonkeyスクリプト
http://d.hatena.ne.jp/kokutoto/20101014/p1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.