Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unfollow everyone on twitter.com
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/7580315
//
// 1. Go to https://twitter.com/YOUR_USER_NAME/following
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
//
// Last Updated: 09 April 2020
(() => {
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(
followButtons.map(async (followButton) => {
followButton && followButton.click();
await sleep({ seconds: 1 });
const confirmButton = document.querySelector($confirmButton);
confirmButton && confirmButton.click();
})
);
};
const nextBatch = async () => {
scrollToTheBottom();
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 {
addNewRetry();
}
if (retryLimitReached()) {
console.log(`NO ACCOUNTS FOUND, SO I THINK WE'RE DONE`);
console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`);
} else {
await sleep({ seconds: 2 });
return nextBatch();
}
};
nextBatch();
})();
@Slyferr
Copy link

Slyferr commented Sep 3, 2021

Is there a script that can auto accept follower request?

@AppFull
Copy link

AppFull commented Sep 27, 2021

There is a new twitter features "remove this follower", is there any script for that (mass remove followers)?

@JamieMason
Copy link
Author

JamieMason commented Sep 28, 2021

Is there a script that can auto accept follower request?
@Slyferr

Could be but I don't know

There is a new twitter features "remove this follower", is there any script for that (mass remove followers)?
@AppFull

Not that I have seen

@AppFull
Copy link

AppFull commented Oct 11, 2021

@JamieMason
Copy link
Author

JamieMason commented Oct 11, 2021

Nice!

@PranitChavan
Copy link

PranitChavan commented Oct 23, 2021

23rd Oct 2021, Still Works.

@websmyth
Copy link

websmyth commented Dec 6, 2021

This is an amazing script: I’ve used it and recommended it to several people. 🙏

@chathurangaonnet
Copy link

chathurangaonnet commented Dec 7, 2021

IT worked for me. Thanks a lot !!!

@JamieMason
Copy link
Author

JamieMason commented Dec 13, 2021

Thanks @websmyth and good luck with that removing likes variation you mentioned.

@websmyth
Copy link

websmyth commented Dec 13, 2021

Cheers, @JamieMason. Edited the comment as it seems there’s no way to remove more than 3200 likes: scrolling manually beyond that, tweets are listed with an unliked UI when they are liked. Nothing more can be done, for now. 😬

@JamieMason
Copy link
Author

JamieMason commented Dec 13, 2021

long shot but you might be able to work around that by having your script open and control twitter in a popup or iframe instead of the current page, then refreshing that window after x amount of likes have been processed inside it 🤞

@websmyth
Copy link

websmyth commented Dec 14, 2021

Thanks! Will look into it. From initial investigations, it seems the only way to unlike those posts is to relike them...urgh! Anyway, don’t want to detail your Gist. Thanks so much for the script: so helpful!

@isinguard
Copy link

isinguard commented Dec 25, 2021

@JamieMason the script now is only unfollowing 2 users per page scroll, can anybody update it please?

@UWReserves
Copy link

UWReserves commented Jan 3, 2022

@JamieMason @isinguard is right doesn't mass unfollow like it use to. It only unfollows a few and then you have to stop and restart it.

@fraterboots
Copy link

fraterboots commented Jan 12, 2022

Beautiful!

@UWReserves
Copy link

UWReserves commented Jan 12, 2022

I'm not sure if anything has changed since my last comment but it appears to be working like it use to now.

@JamieMason
Copy link
Author

JamieMason commented Jan 13, 2022

The last update was 09 April 2020, glad to hear it is still working alright. Maybe @isinguard and @UWReserves are both using a particular browser where it is not working right at the moment, or have a particular browser extension installed which might clash with it, I don't know.

@fayssalElAnsari
Copy link

fayssalElAnsari commented Jan 20, 2022

thanks, still working 👍

@yusufpapurcu
Copy link

yusufpapurcu commented Jan 26, 2022

Legend.

@evelinas
Copy link

evelinas commented Jan 26, 2022

Thank you so much! Do you happen to have a script to remove all followers?

@AppFull
Copy link

AppFull commented Jan 31, 2022

Also looking for modified script to "remove all followers" because the menu hid under "..." menu

@JamieMason
Copy link
Author

JamieMason commented Jan 31, 2022

Thank you so much! Do you happen to have a script to remove all followers?
@evelinas

You're welcome, thanks. I just have this one script to remove follows.

Also looking for modified script to "remove all followers" because the menu hid under "..." menu
@AppFull

Quite a few people have asked about this too, I hope you all find one 🤞. Thanks.

@Natsusomekeishi
Copy link

Natsusomekeishi commented Mar 18, 2022

2022.3.18 可用,但是有BUG,存在部分上面的关注者无法取关

@ykavi
Copy link

ykavi commented Apr 24, 2022

great 🎉

@Sarievo
Copy link

Sarievo commented May 24, 2022

Wow

@benedlore
Copy link

benedlore commented May 29, 2022

Worked for about 22K of the 40K followings I was trying to remove in one go, but then started to think it was all done and needed to be restarted a few times on a refreshed page. Still better than any others I've tried.

@JamieMason
Copy link
Author

JamieMason commented May 29, 2022

@benedlore glad it mostly worked out, 40K is a lot.

@isinguard
Copy link

isinguard commented May 29, 2022

@benedlore glad it mostly worked out, 40K is a lot.

It’s not that it stopped working, twitter usually puts ur acc on cooldown if you perform and action like following/unfollowing/like/unlike.. etc excessively. Just let the account rest a while, refresh the “following” page and paste the code again, then resume the unfollowing. Same thing goes with the unliking script ..

@speakingpen
Copy link

speakingpen commented Jun 6, 2022

This is pretty much helpful

@roy-heinrich
Copy link

roy-heinrich commented Jun 16, 2022

Still works damn.

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