Skip to content

Instantly share code, notes, and snippets.

@thomasrstegelmann
Last active November 1, 2024 20:25
Show Gist options
  • Save thomasrstegelmann/6e459898dc3640bf921c to your computer and use it in GitHub Desktop.
Save thomasrstegelmann/6e459898dc3640bf921c to your computer and use it in GitHub Desktop.
I modified Karan's script to follow only profiles that match a certain keywords to follow only relevant accounts. Please see https://medium.com/marketing-102/how-i-grew-from-300-to-5k-followers-in-just-3-weeks-2436528da845#.75mau0pj9 for details
a = setInterval(function () {
window.scrollTo(0,document.body.scrollHeight);
$(".ProfileCard-userFields").each( function() {
if($(this).find('.ProfileCard-bio').text().match(new RegExp("google|twitter|airbnb|entrepreneur|founder|tech|growthhacking|hacking|official|consultant|analytics|ecom|startup|ceo|ux|seo|ecommerce|growth"), "g") !== null )
{
$(this).parent().find('.not-following .user-actions-follow-button.js-follow-btn').click();
}
} );
}, 1000);
@Deepsgrey
Copy link

This code is not working for me, just scrolling the page.

@amolwagh
Copy link

Wow, this is like the best modification you have made. I wonder if you could add negative keywords like "-ppc", so it will ignore people with such keywords.

Anyways, it's awesome. Thanks a ton!

@bovas85
Copy link

bovas85 commented Feb 9, 2017

@amolwagh you can do that easily adding to the regex
"google|twitter|airbnb|entrepreneur|founder|tech|growthhacking|hacking|official|consultant|analytics|ecom|startup|ceo|ux|seo|ecommerce|growth|(?!sex|anotherblockedword|porn)"

the last bit says negative lookahead these words and ignore them

@bovas85
Copy link

bovas85 commented Feb 9, 2017

I suggest making the script go a bit slower to avoid being banned.
The 1000 is 1s delay between follows.
Also instead of having the regexp there, you can have it in a separate variable so it's easier to edit.
text preceeded by // is a comment and won't be run. It is there to explain what can be done

var regex = ["google", "twitter", "airbnb", "entrepreneur", "founder", "tech", "growthhacking", "hacking",
             "official", "consultant", "analytics", "ecom", "startup", "ceo", "ux", "seo", "ecommerce", "growth"]; // add or change words here
var banned = ["|(?!", "sex", "porn"] // add more banned words here
var target = regex.join("|") + banned.join("|") + ")";
var interval = 5000 // 1000 = 1 second

a = setInterval(function () {
  window.scrollTo(0,document.body.scrollHeight);
  $(".ProfileCard-userFields").each( function() {
    if($(this).find('.ProfileCard-bio').text().match(new RegExp(target), "g") !== null )
    {
      $(this).parent().find('.not-following .user-actions-follow-button.js-follow-btn').click();
    }
  } );
}, interval);

@juan397
Copy link

juan397 commented Aug 2, 2017

Can you a make similar auto-follow script for Quora? I've been looking everywhere, still couldn't find a working one

@tawrahim
Copy link

First of all, make sure that you are on /followers page e.g => https://twitter.com/uber/followers
Open the developer console whiles you on that page and paste the following code

var regex = ["google", "twitter", "airbnb", "entrepreneur", "founder", "tech", "growthhacking", "hacking",
             "official", "consultant", "analytics", "ecom", "startup", "ceo", "ux", "seo", "ecommerce", "growth"]; // add or change words here
var banned = ["|(?!", "sex", "porn"] // add more banned words here
var target = regex.join("|") + banned.join("|") + ")";
var interval = 10000 // 1000 = 1 second
a = setInterval(function () {
    window.scrollTo(0,document.body.scrollHeight);
    var fields = $(".ProfileCard-userFields");
    for (var i = 0; i < fields.length; i++) {
        var p = fields[i].getElementsByClassName('ProfileCard-bio');
        if (p[0].textContent.length > 1) {
            if (p[0].textContent.match(new RegExp(target), "g") !== null) {
                $('.not-following .user-actions-follow-button.js-follow-btn').click();
            }
        }
    }
}, interval);

@infotainor254
Copy link

awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment