Skip to content

Instantly share code, notes, and snippets.

@berstend
Last active June 29, 2025 15:11
Show Gist options
  • Save berstend/752e7b54fd0bbd8b672882459d149b60 to your computer and use it in GitHub Desktop.
Save berstend/752e7b54fd0bbd8b672882459d149b60 to your computer and use it in GitHub Desktop.
Mass unfollow users on Instagram (no app needed)
  • Go to your profile on instagram.com (sign in if not already)
  • Click on XXX following for the popup with the users you're following to appear
  • Open Chrome Devtools and Paste the following into the Console and hit return:
(async function(){
  const UNFOLLOW_LIMIT = 800
  const delay = (ms) => new Promise(_ => setTimeout(_, ms))
  const findButton = (txt) => [...document.querySelectorAll("button").entries()].map(([pos, btn]) => btn).filter(btn => btn.innerHTML === txt)[0]

  console.log("Start")
  for (let i = 0; i < UNFOLLOW_LIMIT; i++) {
    const $next = findButton("Following")          
    if (!$next) { continue }
    $next.scrollIntoViewIfNeeded()  
    $next.click()
    await delay(100)
    $confirm = findButton("Unfollow")    
    if ($confirm) {
      $confirm.click()
    }

    await delay(20 * 1000) // Wait 20s, 200 unfollows per hour limit
    console.log(`Unfollowed #${i}`)
  }

  console.log("The end")
})()
@glitzhXEC
Copy link

ty

@a-mangareader
Copy link

ayo my dude how do i add exceptions to the list :<

@Tpcoo
Copy link

Tpcoo commented May 17, 2022

someone help TP#1000 add cord

@mamorutakamura
Copy link

it aint working

@FaisalAhmed123
Copy link

Just get this but nothing happens
image

@macedonga
Copy link

This updated code will work (it's working for me):

(async function(){
  const UNFOLLOW_LIMIT = 800
  const delay = (ms) => new Promise(_ => setTimeout(_, ms))
  const findButton = (txt) => [...document.querySelectorAll("button").entries()].map(([pos, btn]) => btn).filter(btn => btn.innerText === txt)[0]

  console.log("Start")
  for (let i = 0; i < UNFOLLOW_LIMIT; i++) {
    const $next = findButton("Following")          
    if (!$next) { continue }
    $next.scrollIntoViewIfNeeded()  
    $next.click()
    await delay(100)
    $confirm = findButton("Unfollow")    
    if ($confirm) {
      $confirm.click()
    }

    await delay(20 * 1000) // Wait 20s, 200 unfollows per hour limit
    console.log(`Unfollowed #${i}`)
  }

  console.log("The end")
})()

@vatistasdimitris1
Copy link

vatistasdimitris1 commented Dec 23, 2023

Here I am ed developer and I have Upgraded the code for you here:

(async function () {
const UNFOLLOW_LIMIT = 800;
const UNFOLLOW_INTERVAL = 0; // Unfollow as quickly as possible
const BREAK_DURATION = 5 * 60 * 1000; // 5 minutes break
const TOTAL_DURATION = 10 * 60 * 1000; // 10 minutes duration

let stopScript = false;

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const findButton = (txt) =>
[...document.querySelectorAll("button").entries()]
.map(([pos, btn]) => btn)
.filter((btn) => btn.innerText === txt)[0];

console.log("Start");

let startTime = new Date().getTime();

// Interval to check for user input to stop the script
const stopInterval = setInterval(() => {
if (stopScript) {
console.log("Script stopped by user.");
clearInterval(stopInterval);
}
}, 1000);

while (new Date().getTime() - startTime < TOTAL_DURATION && !stopScript) {
for (let i = 0; i < UNFOLLOW_LIMIT && !stopScript; i++) {
const $next = findButton("Following");
if (!$next) {
continue;
}
$next.scrollIntoViewIfNeeded();
$next.click();
await delay(100);
const $confirm = findButton("Unfollow");
if ($confirm) {
await $confirm.click(); // Wait for the unfollow to complete
}

  await delay(UNFOLLOW_INTERVAL);
  console.log(`Unfollowed #${i}`);
}

console.log(`Taking a break for ${BREAK_DURATION / 1000} seconds...`);
await delay(BREAK_DURATION);

if (!stopScript) {
  startTime = new Date().getTime(); // Reset start time for the next cycle
}

}

console.log("T

@YAGOPORTELAYP
Copy link

YAGOPORTELAYP commented Oct 21, 2024 via email

@je4npw
Copy link

je4npw commented Nov 5, 2024

//for pt_BR users

(async function(){
  const UNFOLLOW_LIMIT = 800
  const delay = (ms) => new Promise(_ => setTimeout(_, ms))
  const findButton = (txt) => [...document.querySelectorAll("button").entries()].map(([pos, btn]) => btn).filter(btn => btn.innerText === txt)[0]

  console.log("Start")
  for (let i = 0; i < UNFOLLOW_LIMIT; i++) {
    const $next = findButton("Seguindo")          
    if (!$next) { continue }
    $next.scrollIntoViewIfNeeded()  
    $next.click()
    await delay(100)
    $confirm = findButton("Deixar de seguir")    
    if ($confirm) {
      $confirm.click()
    }

    await delay(20 * 1000) // Aguarde 20s, 200 unfollows Γ© o limite por hora
    console.log(`Unfollowed #${i}`)
  }

  console.log("Fim")
})()

@AkioThe1st
Copy link

here is new updated version 2024/29/12
Happy Holidays!

    const UNFOLLOW_LIMIT = 800;
    const UNFOLLOW_INTERVAL = 0; // Unfollow as quickly as possible
    const BREAK_DURATION = 5 * 60 * 1000; // 5 minutes break
    const TOTAL_DURATION = 10 * 60 * 1000; // 10 minutes duration

    let stopScript = false;

    const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
    const findButton = (txt) =>
        [...document.querySelectorAll("button")]
            .filter((btn) => btn.innerText === txt)[0];

    console.log("Start");

    let startTime = new Date().getTime();

    // Interval to check for user input to stop the script
    const stopInterval = setInterval(() => {
        if (stopScript) {
            console.log("Script stopped by user.");
            clearInterval(stopInterval);
        }
    }, 1000);

    while (new Date().getTime() - startTime < TOTAL_DURATION && !stopScript) {
        for (let i = 0; i < UNFOLLOW_LIMIT && !stopScript; i++) {
            const $next = findButton("Following");
            if (!$next) {
                continue;
            }
            $next.scrollIntoViewIfNeeded();
            $next.click();
            await delay(100);
            const $confirm = findButton("Unfollow");
            if ($confirm) {
                await $confirm.click(); // Wait for the unfollow to complete
            }

            await delay(UNFOLLOW_INTERVAL);
            console.log(`Unfollowed #${i}`);
        }

        console.log(`Taking a break for ${BREAK_DURATION / 1000} seconds...`);
        await delay(BREAK_DURATION);

        if (!stopScript) {
            startTime = new Date().getTime(); // Reset start time for the next cycle
        }
    }

    console.log("Task completed");
})();```

@NareshBisht
Copy link

Here is the updated version:

const UNFOLLOW_LIMIT = 800;
const UNFOLLOW_INTERVAL = 0; // Unfollow as quickly as possible
const BREAK_DURATION = 5 * 60 * 1000; // 5 minutes break
const TOTAL_DURATION = 10 * 60 * 1000; // 10 minutes duration

let stopScript = false;

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const findButton = (txt) =>
    [...document.querySelectorAll("button")]
        .find((btn) => btn.innerText.trim() === txt);

console.log("Start");

(async function () {
    let startTime = Date.now();

    // Interval to check for user input to stop the script
    const stopInterval = setInterval(() => {
        if (stopScript) {
            console.log("Script stopped by user.");
            clearInterval(stopInterval);
        }
    }, 1000);

    while (Date.now() - startTime < TOTAL_DURATION && !stopScript) {
        for (let i = 0; i < UNFOLLOW_LIMIT && !stopScript; i++) {
            const $next = findButton("Following");
            if (!$next) {
                console.log("No more users to unfollow.");
                break;
            }

            $next.scrollIntoView({ behavior: "smooth", block: "center" });
            $next.click();
            await delay(100);

            const $confirm = findButton("Unfollow");
            if ($confirm) {
                $confirm.click(); // No need for await
            }

            await delay(UNFOLLOW_INTERVAL);
            console.log(`Unfollowed #${i + 1}`);
        }

        console.log(`Taking a break for ${BREAK_DURATION / 1000} seconds...`);
        await delay(BREAK_DURATION);

        if (!stopScript) {
            startTime = Date.now(); // Reset start time for the next cycle
        }
    }

    console.log("Task completed");
})();

@hashilbasheer
Copy link

is there any way to unfollow the people who are not following you back?

@thekyeal
Copy link

thekyeal commented Mar 1, 2025

Updated code

const UNFOLLOW_LIMIT = 800;
const UNFOLLOW_INTERVAL = 100; // Avoid 0 to prevent browser throttling
const BREAK_DURATION = 5 * 60 * 1000; // 5 minutes break
const TOTAL_DURATION = 10 * 60 * 1000; // 10 minutes duration

let stopScript = false;

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const findButton = (txt) =>
[...document.querySelectorAll("button")]
.find((btn) => btn.textContent.includes(txt));

console.log("Start");

(async function () {
let startTime = Date.now();

// Stop the script when user sets stopScript = true
document.addEventListener("keydown", (event) => {
    if (event.key === "Escape") {
        stopScript = true;
        console.log("Script stopping...");
    }
});

while (Date.now() - startTime < TOTAL_DURATION && !stopScript) {
    let unfollowCount = 0;

    for (let i = 0; i < UNFOLLOW_LIMIT && !stopScript; i++) {
        const $next = findButton("Following");
        if (!$next) {
            console.log("No more users to unfollow.");
            break;
        }

        $next.scrollIntoView({ behavior: "smooth", block: "center" });
        await delay(200); // Allow scroll to settle

        $next.click();
        await delay(300); // Wait for confirmation button to appear

        const $confirm = findButton("Unfollow");
        if ($confirm) {
            $confirm.click();
            console.log(`Unfollowed #${i + 1}`);
            unfollowCount++;
        } else {
            console.warn("Unfollow confirmation button not found.");
        }

        await delay(UNFOLLOW_INTERVAL);
    }

    if (unfollowCount === 0) {
        console.log("No more actions possible, stopping.");
        break;
    }

    console.log(`Taking a break for ${BREAK_DURATION / 1000} seconds...`);
    await delay(BREAK_DURATION);
}

console.log("Task completed");

})();

@dasrii
Copy link

dasrii commented Mar 2, 2025

(async function(){
const UNFOLLOW_LIMIT = 800
const delay = (ms) => new Promise(_ => setTimeout(_, ms))
const findButton = (txt) => [...document.querySelectorAll("button").entries()].map(([pos, btn]) => btn).filter(btn => btn.innerText === txt)[0]

console.log("Start")

for (let i = 0; i < UNFOLLOW_LIMIT; i++) {
const $next = findButton("Following")
if (!$next) { continue }
$next.scrollIntoViewIfNeeded()
$next.click()
await delay(100)
$confirm = findButton("Unfollow")
if ($confirm) {
$confirm.click()
}

await delay(1 * 1000) // Wait 1s, 500 unfollows per hour limit
console.log(`Unfollowed #${i}`)

}

console.log("The end")
})()

This is working on 2 March 2025

@korkom5910
Copy link

The key arrived almost immediately after I completed the purchase, and the activation process was seamless. I simply entered the key, followed the instructions, and within minutes, my Windows 11 Pro was fully activated without any problems. It felt like a huge relief since I didn’t have to worry about expiration or activation errors.

And they partnered with microsoft

@FaisalAhmed123
Copy link

I have re-written it to sort iron some issues out with how fast it was unfollowing people (and not all of it registering), here is my version for anyone interested : https://github.com/FaisalAhmed123/Instagram-Unfollow/blob/main/main

@MahanKdi
Copy link

MahanKdi commented May 6, 2025

I have re-written it to sort iron some issues out with how fast it was unfollowing people (and not all of it registering), here is my version for anyone interested : https://github.com/FaisalAhmed123/Instagram-Unfollow/blob/main/main

I'm new can you please tell me how to use this.

@kmt9967
Copy link

kmt9967 commented May 19, 2025

@MahanKdi , Just Log into the Instagram on web browser . open the following list
image

Then go the the browser settings and open up the dev tools
image

Select Console , and copy paste this code there
image

Here's the working code :

(async function(){
  const UNFOLLOW_LIMIT = 800
  const delay = (ms) => new Promise(_ => setTimeout(_, ms))
  const findButton = (txt) => [...document.querySelectorAll("button").entries()].map(([pos, btn]) => btn).filter(btn => btn.innerText === txt)[0]

  console.log("Start")
  for (let i = 0; i < UNFOLLOW_LIMIT; i++) {
    const $next = findButton("Following")          
    if (!$next) { continue }
    $next.scrollIntoViewIfNeeded()  
    $next.click()
    await delay(100)
    $confirm = findButton("Unfollow")    
    if ($confirm) {
      $confirm.click()
    }

    await delay(20 * 1000) // Wait 20s, 200 unfollows per hour limit
    console.log(`Unfollowed #${i}`)
  }

  console.log("The end")
})() 

@aelphias
Copy link

// with chatGPT added random delays:
// randomDelay(5000, 20000) creates a random wait between 5 and 20 seconds (in milliseconds).
(async function() {
const UNFOLLOW_LIMIT = 800;

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const randomDelay = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
const findButton = (txt) => [...document.querySelectorAll("button")].find(btn => btn.innerText === txt);

console.log("Start");

for (let i = 0; i < UNFOLLOW_LIMIT; i++) {
const nextButton = findButton("Following");
if (!nextButton) {
console.log("No more 'Following' buttons found.");
break;
}

nextButton.scrollIntoViewIfNeeded();
nextButton.click();
await delay(300); // Let the UI open the confirm dialog

const confirmButton = findButton("Unfollow");
if (confirmButton) {
  confirmButton.click();
}

const waitTime = randomDelay(5000, 20000); // 5 to 20 seconds
console.log(`Unfollowed #${i + 1}. Waiting ${Math.floor(waitTime / 1000)}s...`);
await delay(waitTime);

}

console.log("The end");
})();

@aelphias
Copy link

aelphias commented Jun 29, 2025

(async function () {
const MAX_PER_DAY = 400; // Maximum number of unfollows allowed per day
const PAUSE_AFTER_BATCH = 10; // Pause after every 10 unfollows
const PAUSE_DURATION = 10 * 60 * 1000; // Pause duration: 10 minutes (in ms)
const delay = (ms) => new Promise(r => setTimeout(r, ms));
const randomDelay = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
const findButton = (txt) => [...document.querySelectorAll("button")].find(btn => btn.innerText === txt);

// Use localStorage to track today's date and unfollow count
const today = new Date().toISOString().split("T")[0]; // format: YYYY-MM-DD
const key = unfollowed_${today};
const alreadyUnfollowed = parseInt(localStorage.getItem(key) || "0");

// If daily limit reached, stop immediately
if (alreadyUnfollowed >= MAX_PER_DAY) {
console.log(πŸ›‘ Daily limit of ${MAX_PER_DAY} unfollows already reached.);
return;
}

window.STOP_UNFOLLOW = false;
let unfollowed = alreadyUnfollowed;

console.log(πŸš€ Start unfollow session (${unfollowed}/${MAX_PER_DAY} already unfollowed today));

for (let i = 0; unfollowed < MAX_PER_DAY; i++) {
if (window.STOP_UNFOLLOW) {
console.log("πŸ›‘ Unfollow process manually stopped.");
break;
}

const nextButton = findButton("Following");
if (!nextButton) {
  console.log("❗ No more 'Following' buttons found.");
  break;
}

// 20% chance to "change mind" and skip unfollow (human-like randomness)
if (Math.random() < 0.2) {
  console.log("πŸ€” Skipped this one (random 'changed mind')");
  window.scrollBy(0, 100);
  await delay(randomDelay(1000, 2000));
  continue;
}

nextButton.scrollIntoViewIfNeeded();
nextButton.click();
await delay(300);

const confirmButton = findButton("Unfollow");
if (confirmButton) {
  confirmButton.click();
  unfollowed++;
  localStorage.setItem(key, unfollowed); // Save progress in localStorage
  console.log(`βœ… Unfollowed #${unfollowed} today`);
} else {
  console.log("⚠️ Confirm button not found");
}

window.scrollBy(0, randomDelay(50, 150)); // Simulate human scrolling

const waitTime = randomDelay(5000, 20000); // Wait 5–20 seconds randomly
console.log(`⏳ Waiting ${Math.floor(waitTime / 1000)} seconds...`);
await delay(waitTime);

// After every batch, take a longer break
if (unfollowed % PAUSE_AFTER_BATCH === 0 && unfollowed !== 0) {
  console.log(`😴 Pausing for ${PAUSE_DURATION / 60000} minutes after ${unfollowed} unfollows`);
  await delay(PAUSE_DURATION);
}

}

console.log(🏁 Finished session. Total unfollowed today: ${unfollowed});
})();

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