javascript Instagram 汽车喜欢 Bookmarklet

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10669617/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:38:55  来源:igfitidea点击:

Instagram auto like Bookmarklet

javascriptinstagrambookmarkletsocial-media-like

提问by DASH006

Instagram Like (heart) auto click Post Bookmarklet

Instagram Like (heart) 自动点击 Post Bookmarklet

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

目标:点击页面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() };

采纳答案by Daedalus

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 thisanswer.

至于班级检查“功能”,在答案中应归功于信用。

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

我仍然不确定上面的代码是否真的有效,但到目前为止它在 jsfiddle 中“有效”(将链接拖到按钮栏,单击按钮栏中的链接,观察控制台)。