Skip to content

Instantly share code, notes, and snippets.

Last active February 19, 2024 14:18
Star You must be signed in to star a gist
Save JamieMason/7580315 to your computer and use it in GitHub Desktop.
Unfollow everyone on

Unfollow everyone on

  1. Go to
  2. Open the Developer Console. (COMMAND+ALT+I on Mac)
  3. Paste this into the Developer Console and run it
// Unfollow everyone on, by Jamie Mason (
// 1. Go to
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
// Last Updated: 30 October 2023
(() => {
  const $followButtons = '[data-testid$="-unfollow"]';
  const $confirmButton = '[data-testid="confirmationSheetConfirm"]';

  const retry = {
    count: 0,
    limit: 3,

  const scrollToTheBottom = () => window.scrollTo(0, document.body.scrollHeight);
  const retryLimitReached = () => retry.count === retry.limit;
  const addNewRetry = () => retry.count++;

  const sleep = ({ seconds }) =>
    new Promise((proceed) => {
      console.log(`WAITING FOR ${seconds} SECONDS...`);
      setTimeout(proceed, seconds * 1000);

  const unfollowAll = async (followButtons) => {
    console.log(`UNFOLLOWING ${followButtons.length} USERS...`);
    await Promise.all( (followButton) => {
        followButton &&;
        await sleep({ seconds: 1 });
        const confirmButton = document.querySelector($confirmButton);
        confirmButton &&;

  const nextBatch = async () => {
    await sleep({ seconds: 1 });

    const followButtons = Array.from(document.querySelectorAll($followButtons));
    const followButtonsWereFound = followButtons.length > 0;

    if (followButtonsWereFound) {
      await unfollowAll(followButtons);
      await sleep({ seconds: 2 });
      return nextBatch();
    } else {

    if (retryLimitReached()) {
      console.log(`NO ACCOUNTS FOUND, SO I THINK WE'RE DONE`);
    } else {
      await sleep({ seconds: 2 });
      return nextBatch();


This script:

  • Is completely free and has been since 2013.
  • Doesn't try and get you to sign in or take your personal data.
  • Automates your web browser to make it click unfollow buttons, scroll down to reveal more, then do it again.
  • No tricks, all of the code is here so you can see exactly what it does.

If this script was useful and saved you time, maybe kick in for a Coffee to say thanks:


Copy link

Still works! Thank you so much. Is there a code to follow massively on Twitter?

Copy link

Great @niklas44f1. You could probably modify the script slightly so it works on someone's Following page for example, and clicks follow instead of unfollow or something. I'm not going to do it but it should be a fairly small job for someone.

Copy link

still work thx

Copy link

GeekProgram007 commented Nov 8, 2023

How to unfollow only unlocked (e.g. not private) accounts? The data id is data-testid="icon-lock"

Copy link

Works. Thanks!

Copy link

thank you very much , its working fine.

Copy link

Thanks :) Its working FIne

Copy link

Mucenio commented Jan 25, 2024


Copy link

Still working, amazing!
Thank you!

Copy link

pkfrank commented Feb 19, 2024


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