Created
October 14, 2010 05:44
-
-
Save kokutoto/625638 to your computer and use it in GitHub Desktop.
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 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); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
特定のタグが付いたホッテントリを非表示にするGreasemonkeyスクリプト
http://d.hatena.ne.jp/kokutoto/20101014/p1