Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2017 23:27
Show Gist options
  • Save lifenautjoe/01828b35132adc096500c2ea9b8c313d to your computer and use it in GitHub Desktop.
Save lifenautjoe/01828b35132adc096500c2ea9b8c313d to your computer and use it in GitHub Desktop.
Script to unfollow people in the instagram website
* Instagram web unfollow script
* A script to unfollow people in the instagram website
* WHY?
* I needed to clean my account so I quickly did this
* Go to your instagram profile while logged in and run the following code in your console
* It opens your followers list and goes one by one unfollowing with a random interval of 1 to 10
* seconds in between
* Yes, although you will first be notified several times about strange activity
* Simply put, use it at your own risk and not for long.
* Created on 15/03/17.
* @author Joel Hernandez <>
openFollowersWindow().then(function () {
function openFollowersWindow() {
var onFollowersWindowWasOpenedListeners = [];
var openWindowTimeout = 3000;
var followersElement = getFollowersElement();;
function digestOnFollowersWindowWasOpenedListeners() {
onFollowersWindowWasOpenedListeners.forEach(function (onFollowersWindowWasOpenedListener) {
var wasOpened;
setTimeout(function () {
// TODO Verify that the window was indeed opened
wasOpened = true;
}, openWindowTimeout);
return {
then: function (onFollowersWindowWasOpened) {
if (wasOpened) {
} else {
function getFollowersElement() {
return getFollowersElementWithUsername(getUsername());
function getUsername() {
var pageTitleElement = document.getElementsByTagName('h1')[0];
if (!pageTitleElement) throw new Error('No title to get username from');
return pageTitleElement.innerHTML;
function getFollowersElementWithUsername(username) {
var followersElement = document.querySelectorAll('a[href="/' + username + '/following/"]')[0];
if (!followersElement) throw new Error('No followers element was found');
return followersElement;
var unfollowsPool;
function populateUnfollowsPool() {
var buttons = document.getElementsByTagName('button');
unfollowsPool = [];
for (var i = 0; i < buttons.length; i++) {
var button = buttons[i];
if (button.innerHTML.includes('Following')) {
var randomTimeoutForUnfollow = Math.floor((Math.random() * 10) + 1) * 1000;
console.log('Following button!');
var unfollow = {
buttonElement: button,
timeout: randomTimeoutForUnfollow
function digestUnfollowsPool() {
if (unfollowsPool.length === 0) {
console.log('Unfollow pool empty, repopulating');
var unfollow = unfollowsPool.shift();
var unfollowTimeout = unfollow.timeout;
console.log('Clicking unfollow button in ', unfollowTimeout);
setTimeout(function () {
var unfollowButtonElement = unfollow.buttonElement;
console.log('Clicking unfollow button');;
console.log('Clicked. Continuing digesting unfollow pool');
}, unfollowTimeout);
Copy link

not a js programmer, so don't understand all parts of the script. tried to make code changes on my local copy to see if i could populate the list with only 100 followers, but i obviously don't know js, so things didn't work. wondering if the original dev (@adminy) would be interested in making this change in the script, so that in stead of populating the list with "all" followers, populate the list with only 100 odd followers. that would also be good to ensure that we don't get banned by instag.

this is urgent, because (1) i have maintained a private account so far, (2) i am following over 1000 accounts, most of which i do not wish to share with others - friends and family (3) a new, "very close friend" wants to follow me or see the list of people i am following. #3 mandates that i clean up my list asap. your help is appreciated.

Copy link

try this

const unfollow = setInterval(()=>{
const allElements = document.getElementsByClassName("_aacl _aaco _aacw _adda _aad6 _aade");
for (const el of allElements) {;
setTimeout(() => console.log('espera'), 1000);
setTimeout(() => {
const xpath = "//a[text()='Dejar de seguir']";
const matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;;
setTimeout(() => console.log('espera'), 1000);
}, 2000);


Copy link

Copy link

How to use it like how to open it.

im new in that and im with c#

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