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() };
Daedalus - Reinstate Monica
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