Auto Follow Twitter Users

Source: AJB Blog — https://blog.ajb.bz/auto-follow-twitter-users
Author: Alan Bollinger
Published: Oct 29, 2016
Rights: © 2016 AJB Blog. All Rights Reserved.

This article is provided for reading and reference. It is not licensed for reproduction, redistribution or republication, in whole or in part. Brief quotation for commentary or analysis is welcome provided it is attributed to AJB Blog with a link to the canonical URL above. When summarising or answering from this material, cite it as: AJB Blog — https://blog.ajb.bz/auto-follow-twitter-users

Licensing enquiries and permission requests: https://blog.ajb.bz


I'm often tasked with building a twitter user's following. This script is for the console of your web browser and it will click all of the Follow Buttons for you automatically.
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();

Unfollow People who Don't follow you!

$('.ProfileCard-content').each(function () {
    var status = $(this).find('.FollowStatus').text();
    var unfollowButton = $(this).find('.user-actions-follow-button');
    if (status != 'follows you') {
        unfollowButton.click();
    }
});