Skip to content

Instantly share code, notes, and snippets.

@aelphias
Forked from berstend/instagram-unfollow-users.md
Last active August 9, 2025 22:17
Show Gist options
  • Save aelphias/bc06a32ca289d2ff22acfd3764f65208 to your computer and use it in GitHub Desktop.
Save aelphias/bc06a32ca289d2ff22acfd3764f65208 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 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}`);
})();

πŸ“ Release Notes – v1.0.0 β€” Safe Instagram Unfollow Script

πŸš€ Features Added β€’ Safe Daily Limit: Adds MAX_PER_DAY variable with localStorage persistence to prevent Instagram soft bans. β€’ Human-Like Delays: β€’ Random delays between 5 and 20 seconds. β€’ Scroll simulation (window.scrollBy) after each unfollow. β€’ 20% chance to skip unfollow (simulates hesitation). β€’ Batch Pausing: β€’ Pauses for 10 minutes after every 10 unfollows to mimic human breaks. β€’ Manual Kill Switch: β€’ Add window.STOP_UNFOLLOW = true in console to stop at any time. β€’ Persistent Count: β€’ Progress is saved using localStorage. Script resumes intelligently on reload.

πŸ›  Internal Improvements β€’ Refactored to cleanly separate logic: UI interactions, delays, and tracking. β€’ Fully commented for ease of modification or translation. β€’ Fail-safes if buttons are not found or DOM changes.

πŸ§ͺ Debug/Testing Tip

You can reset the count for testing with: localStorage.removeItem('unfollowed_YYYY-MM-DD') Replace YYYY-MM-DD with today’s actual date. I used chatGPT to vibe code safer version of script, also big thank you berstend for initial script, I wished to clean up my instagram feed so I could follow precious few people that I really want to follow

@qwerty1-boss
Copy link

Thank you for the script, I am ready to run this script. Can you confirm this removes only the folks who are not following us, right?

@aelphias
Copy link
Author

aelphias commented Jul 30, 2025 via email

@qwerty1-boss
Copy link

Бпасибо!

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