Bookmarklet: Click All Like Buttons On Tumblr

情到浓时终转凉″ 提交于 2019-12-25 02:14:07

问题


Similar to this Follow all users on a twitter page, I am trying to change this to click all the "like" hearts on a Tumblr page instead of the follow button:

javascript:$('.button.follow-button').click()

Thanks


回答1:


javascript:var a = document.getElementsByTagName('a'); var b = []; for(var i=0, len = a.length; i < len; i++){ if(a[i].id.indexOf('like_button') !== -1){b.push(a[i]) } }; for(var i=0, len = b.length; i < len; i++){ b[i].onclick() };

There. What it does is gets all the a tags on the page. Then filters them and finds all the like buttons. Then it just clicks on them.

Note that this solution is pretty inefficient and you should probably be using document.getElementsByClassName as Samuel did, but that may not be supported in all browsers (I'm looking at you, IE 8).




回答2:


Here's your bookmarklet:

javascript:e=document.getElementsByClassName('like_button');for(i=0;i<e.length;i++){e[i].click();}void(0);

Edit: the above only works in Firefox. Try this instead:

javascript:e=document.getElementsByTagName('a');for(i=0;i<e.length;i++){if(e[i].id.indexOf('like_button')>=0)e[i].click();}void(0);


来源:https://stackoverflow.com/questions/8175822/bookmarklet-click-all-like-buttons-on-tumblr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!