-
-
Save dongarchive/9c4e2aed43e73c7554b5c74855dc063e to your computer and use it in GitHub Desktop.
// ------------------- | |
// 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 |
VM50:7 Refused to load the script 'https://code.jquery.com/jquery-latest.min.js' because it violates the following Content Security Policy directive: "script-src 'self' https://instagram.com https://www.instagram.com https://.www.instagram.com https://.cdninstagram.com wss://www.instagram.com https://.facebook.com https://.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
Sorry this script doesn't seem to work anymore due to what you posted, the jquery seems to be blocked by instagram. I've made a new script here for following:
https://gist.github.com/chaodonghu/c25c7ee3e3eb85c0a0de051892e596a4
and here for unfollowing:
https://gist.github.com/chaodonghu/c942b6ca8f8c247ccacd3b0123ff3580
VM50:7 Refused to load the script 'https://code.jquery.com/jquery-latest.min.js' because it violates the following Content Security Policy directive: "script-src 'self' https://instagram.com https://www.instagram.com https://.www.instagram.com https://.cdninstagram.com wss://www.instagram.com https://.facebook.com https://.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
Sorry this script doesn't seem to work anymore due to what you posted, the jquery seems to be blocked by instagram. I've made a new script here for following:
https://gist.github.com/chaodonghu/c25c7ee3e3eb85c0a0de051892e596a4
and here for unfollowing:
https://gist.github.com/chaodonghu/c942b6ca8f8c247ccacd3b0123ff3580
I'm trying the following right now and it's working. Thanks a lot!
VM50:7 Refused to load the script 'https://code.jquery.com/jquery-latest.min.js' because it violates the following Content Security Policy directive: "script-src 'self' https://instagram.com https://www.instagram.com https://.www.instagram.com https://.cdninstagram.com wss://www.instagram.com https://.facebook.com https://.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
Sorry this script doesn't seem to work anymore due to what you posted, the jquery seems to be blocked by instagram. I've made a new script here for following:
https://gist.github.com/chaodonghu/c25c7ee3e3eb85c0a0de051892e596a4
and here for unfollowing:
https://gist.github.com/chaodonghu/c942b6ca8f8c247ccacd3b0123ff3580I'm trying the following right now and it's working. Thanks a lot!
No worries, sorry I'm on my personal account vs work account lol. Just be careful to set the limit/timer accordingly so you don't get detected by instagram for scripting.
haha never mind. How to do that(to set the limit)?. And one other thing. I'm trying to write a selenium based(not decided yet) script to do the same job. From your experience with IG Technology and bot detection. Anything I should be aware of while building the script?
haha never mind. How to do that(to set the limit)?. And one other thing. I'm trying to write a selenium based(not decided yet) script to do the same job. From your experience with IG Technology and bot detection. Anything I should be aware of while building the script?
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.
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?
VM50:7 Refused to load the script 'https://code.jquery.com/jquery-latest.min.js' because it violates the following Content Security Policy directive: "script-src 'self' https://instagram.com https://www.instagram.com https://.www.instagram.com https://.cdninstagram.com wss://www.instagram.com https://.facebook.com https://.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.