简体   繁体   English

Chrome控制台的Javascript帮助吗? 单击所有链接网站

[英]Javascript Help For Chrome Console? Clicking All links website

this website wants me to click ALL the links on the page (there's about 2000). 该网站希望我单击页面上的所有链接(大约有2000个)。

This is the code for each link: 这是每个链接的代码:

<a href="#" id="27426879" class="unfollow">UNFOLLOW</a>

the ID changes all the time depending on the link. ID始终根据链接而变化。

Is it possible to supply me the javascript code to write into the console of google chrome to click ALL the "a" tags with the class of "unfollow" at once? 是否可以向我提供javascript代码,以便将其写入Google chrome的控制台中,以立即单击所有具有“取消关注”类的“ a”标签? thanks :) 谢谢 :)

How about? 怎么样?

var links = document.querySelectorAll("a.unfollow[href=#]");
for (var i = 0; i < links.length; ++i) {
    links[i].click();
}

Sure is: 当然是:

[].forEach.call(document.querySelectorAll('a.unfollow'), function (link){
    link.click();
});

Demo 演示版

You could do it using a plain for loop as well, but I just found it faster to do it this way. 也可以使用普通的for循环来完成此操作,但是我发现这样做更快。

谢谢我使用聊天室,此代码很容易工作:$('a.unfollow')。click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM