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

this website wants me to click ALL the links on the page (there's about 2000).This is the code for

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()

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745296161a4621156.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信