最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - Javascript Help For Chrome Console? Clicking All links website - Stack Overflow

programmeradmin2浏览0评论

this website wants me to click ALL the links on the page (there's about 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.

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? thanks :)

this website wants me to click ALL the links on the page (there's about 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.

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? thanks :)

Share Improve this question edited Jan 13, 2013 at 20:55 Pointy 414k62 gold badges595 silver badges629 bronze badges asked Jan 13, 2013 at 20:54 Rahul KhoslaRahul Khosla 44910 silver badges21 bronze badges 1
  • 3 Inject jQuery then $('a.unfollow[href="#"]').click(); – Musa Commented Jan 13, 2013 at 20:58
Add a ment  | 

3 Answers 3

Reset to default 4

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.

Thanks I used chat room this code works easy: $('a.unfollow').click()

发布评论

评论列表(0)

  1. 暂无评论