Follow all users on a twitter page [closed]

微笑、不失礼 提交于 2019-12-03 03:56:44

问题


I'm on https://twitter.com/#!/username/followers ; is there any greasemonkey script to follow all the twitter users on that page?


回答1:


Here's a new one which also employs a delay to prevent spam issues.

var FOLLOW_PAUSE = 1250;
var FOLLOW_RAND = 250; 
var PAGE_WAIT = 2000;
__cnt__ = 0; 
var f;
f = function() {
        var eles;
        var __lcnt__ = 0;
        eles = jQuery('.Grid-cell .not-following .follow-text').each(function(i, ele) {
                    ele = jQuery(ele);
                    if (ele.css('display') != 'block') {
                        console.trace('Already following: ' + i);
                        return;
                    }
                    setTimeout(function() {
                              console.trace("Following " + i + " of " + eles.length);
                            ele.click();
                            if ((eles.length - 1) == i) {
                                console.trace("Scrolling...");
                                window.scrollTo(0, document.body.scrollHeight);
                                setTimeout(function() {
                                    f();
                                }, PAGE_WAIT);
                            }
                    }, __lcnt__++ * FOLLOW_PAUSE + Math.random()*(FOLLOW_RAND) - FOLLOW_RAND/2);
                    __cnt__++;
        });
}
f();

What it does:

  • Looks for follow buttons
  • Checks that you aren't already following or pending (display: block check)
  • Sets a timer to click the FOLLOW buttons every 500ms to prevent spam issues.
  • NEW! When it's done them all, scrolls the page and waits a couple seconds for the next loads to appear, then repeats the whole process!

Notes for hackers:

  • Works on Chrome latest version and Twitter as of the 30th of Sep 2016.
  • You seem to need to "click" the DIV inside the A tag, not the A tag itself.
  • HOMEWORK: Maybe try jQuery's live() function to auto-click any new buttons which show up after the initial page load :)

Disclaimer: This is not a hack...just a technique to save some wrist and finger RSI :) Regardless, use cautiously and respectfully.

UPDATE: Improved for latest twitter. Now employs randomness in the timing to make you look less like a bot




回答2:


Twitter uses JQuery, so a way to do this, assuming that you aren't doing this so much as to trigger the rate limits (the rate limits will apply more aggressively to web client users as compared to API users) is to do the equivalent of:

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

You can accomplish this in GreaseMonkey if you'd like, or setting it as a JavaScript bookmarklet, or by copy-pasting this into your address bar and hitting enter:

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



回答3:


I modified the code that Hari Karam Singh posted earlier to work to the to-date Twitter.

__cnt__=0; jQuery('.stream button.follow-button > span.follow-text').each(function (i, ele) { ele = jQuery(ele); if (ele.css('display')!='block') {console.log('already following:', i); return;} setTimeout(function () {ele.click();}, __cnt__++*500); });



回答4:


It doesn´t work anymore, but if you use the object instead of the alias i´ll do javascript:jQuery('.button.follow-button').click();. You can also use the in-built debugger in chrome or firebug to add a button that cam do this for you, and add a settimeout to avoid interference with the api's restrictions.

<input type="button" onclick="javascript:jQuery('.button.follow-button').click();" value="follow!
">


来源:https://stackoverflow.com/questions/5841118/follow-all-users-on-a-twitter-page

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