Instagram auto like Bookmarklet

a 夏天 提交于 2019-12-10 11:19:52

问题


Instagram Like (heart) auto click Post Bookmarklet

Objective: Click all "Like" heart on page http://www.gramfeed.com/instagram/tags#photo

Here is the code I was working with. This one worked on another site,

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

回答1:


The following should work; I've tested it on my end, and it likes the hearts(though that doesn't work since I'm not logged in, etc).

javascript:(function(){for(i=0;i<document.getElementsByTagName('img').length;i++){if((' '+document.getElementsByTagName('img')[i].className+' ').indexOf(' liker ')> -1){document.getElementsByTagName('img')[i].click();}}})();

As to the class checking 'function', credit where credit is due in regards to this answer.

Update

javascript:(function(){for(i=0;i<document.getElementsByTagName('img').length;i++){if((' '+document.getElementsByTagName('img')[i].className+' ').indexOf(' liker ')>-1){var t=document.getElementsByTagName('img')[i];if(document.dispatchEvent){var o=document.createEvent('MouseEvents');o.initMouseEvent('click',true,true,window,1,1,1,1,1,false,false,false,false,0,t);t.dispatchEvent(o)}else if(document.fireEvent){t.fireEvent('onclick')}else if(t.click()){t.click()}}}})();

I am still unsure if the above code will really work, but it has so far 'worked' in jsfiddle(drag link to button bar, click link in button bar, observe console).



来源:https://stackoverflow.com/questions/10669617/instagram-auto-like-bookmarklet

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