Last active
December 21, 2022 14:20
-
-
Save dongarchive/9c4e2aed43e73c7554b5c74855dc063e to your computer and use it in GitHub Desktop.
Follow and unfollow instagram script - ApplyBoard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------- | |
// To mass follow | |
// ------------------- | |
// 1. Open instagram page (eg. https://www.instagram.com/visatoronto/) utilizing google chrome | |
// 2. Click 'xxx followers' on instagram page, this will open up a modal containing user's followers | |
// 3. Open google chrome developer tools by either (1) right clicking on the screen and clicking 'inspect' | |
// OR (2) Command + Option + J | |
// 4. Click on the 'console' method in dev tools | |
// 5. First paste the following code to instantiate jquery and press enter | |
let script = document.createElement("script"); | |
script.setAttribute('src', '//code.jquery.com/jquery-latest.min.js'); | |
script.addEventListener('load', function() { | |
let script = document.createElement('script'); | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
// 6. Then paste this into the console to allow mass following and press enter | |
window.setInterval(function() { | |
// Set counter to follow | |
var x = 0; | |
$("button:contains('Follow')").each(function() { | |
// Limit to only follow 12 people every interval | |
if (x == 12) { | |
return false; | |
} | |
// Filter out following and follow buttons | |
if ($(this).text() != 'Follow') { | |
return; | |
} | |
// // Only click on follow buttons | |
$(this).trigger("click"); | |
// Add to the counter | |
x++; | |
// Scroll down | |
$('.j6cq2').scrollTop($('.j6cq2')[0].scrollHeight); | |
}) | |
}, 1000 * 60 * 15); // Call every 15 minutes | |
// ------------------- | |
// To mass unfollow | |
// ------------------- | |
// 1. Open instagram page (eg. https://www.instagram.com/visatoronto/) utilizing google chrome | |
// 2. Click 'xxx following' on instagram page, this will open up a modal containing all the user's the user is following | |
// 3. Open google chrome developer tools by either (1) right clicking on the screen and clicking 'inspect' | |
// OR (2) Command + Option + J | |
// 4. Click on the 'console' method in dev tools | |
// 5. Paste the following code to instantiate jquery and press enter | |
let script = document.createElement("script"); | |
script.setAttribute('src', '//code.jquery.com/jquery-latest.min.js'); | |
script.addEventListener('load', function() { | |
let script = document.createElement('script'); | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
// 6. Paste this into the console to allow mass unfollowing and press enter | |
window.setInterval(function() { | |
// Start counter to follow | |
var x = 0; | |
$("button:contains('Following')").each(function() { | |
// Limit to only unfollow 12 people every interval | |
if (x == 12) { | |
return false; | |
} | |
// // Only click on following buttons | |
$(this).trigger("click"); | |
// Add to the counter | |
x++; | |
// Scroll down | |
$('.j6cq2').scrollTop($('.j6cq2')[0].scrollHeight); | |
}) | |
}, 1000 * 60 * 15); // Call every 15 minutes |
Thanks a lot Chao. This is really helpful :)
Could you whitelist people that are following you back or is it one or the other only?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 37 (https://gist.github.com/chaodonghu/c25c7ee3e3eb85c0a0de051892e596a4#file-follow-instagram-js-L37) you can change the multiple of the randomTimeout.
eg.
const randomTimeout = () => (Math.floor((Math.random() * 10) + 1) * 1000) + 20000
->const randomTimeout = () => (Math.floor((Math.random() * 10) + 1) * 1000) + 40000
Essentially changing the follow rate from 20-29s to 40-49s. The bot detection is kind of hard to avoid to be honest from what i've read it's probably ~100 followers/hour that it's capped at. If you really wanted to just have the tab open and run it with a safe 60-69 second rate.
For selenium based it should be the same thing, just have it click through and set the rate accordingly.