Greasemonkey,删除< a>元素 [英] Greasemonkey, delete <a> element
本文介绍了Greasemonkey,删除< a>元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个Greasemonkey脚本,本来我想获取所有<table>
元素并搜索这些元素的,但是我无法使其正常工作.因此,我尝试搜索<a>
元素本身,如果它们包含" http://www.4chanscapepk,则将它们隐藏起来.t35.com ",但也不起作用.我想念什么?
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].href.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 )
这样做:
results[i].href.indexOf("unwantedsites.com") >= 0 )
这篇关于Greasemonkey,删除< a>元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文