Greasemonkey, delete <a> element
I have this Greasemonkey script, I originally wanted to get all the <table>
elements and search through those for but I couldn't get that to work. So I tried searching for the <a>
elements themselves and just hiding them if they contained "http://www.4chanscapepk.t35.com" but its not working either. What am I missing?
var results = document.getElementsByTagName("a");
for ( var i=0; i<results.length; i++ ) {
if (
results[i].hr开发者_JAVA百科ef.indexOf("http://www.unwantedsites.com") == 0 ) {
results[i].parentNode.style.display = "none";
}
}
Maybe make the condition a little looser? Maybe instead of:
results[i].href.indexOf("http://www.unwantedsites.com") == 0 )
do:
results[i].href.indexOf("unwantedsites.com") >= 0 )
try using getAttribute instead of directly accessing the property href
:
if ( results[i].getAttribute("href").indexOf("http://www.unwantedsites.com") == 0 ) {
精彩评论