Greasemonkey,删除;元素
我有这个 Greasemonkey 脚本,我最初想获取所有 元素并搜索这些元素,但我无法让它工作。因此,我尝试搜索
元素本身,如果它们包含“
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";
}
}
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";
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或许条件可以宽松一些?也许代替:
做:
Maybe make the condition a little looser? Maybe instead of:
do:
尝试使用 getAttribute 而不是直接访问属性
href
:try using getAttribute instead of directly accessing the property
href
: