X (formerly Twitter) removed the "Unfollow All" button β this script brings it back.
This JavaScript snippet runs in your browser and safely unfollows users one by one from your Following list, imitating natural scrolling and clicking behavior to avoid detection.
- β Google Chrome browser (desktop)
- β Logged into your x.com account
- β A little patience
-
Open your Following page:
Go to:https://x.com/YOUR_USERNAME/following
-
Open the Developer Console:
- Windows/Linux:
Ctrl + Shift + J
- macOS:
Cmd + Option + J
- Windows/Linux:
-
Paste the entire script into the console and press Enter.
// Paste this in Chrome DevTools on your Following page
window.STOP_UNFOLLOW = false;
let unfollowedCount = 0;
const MAX_UNFOLLOWS = 400;
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function unfollowAll() {
const scrollContainer = document.querySelector('[data-testid="primaryColumn"]');
let lastHeight = 0;
while (!window.STOP_UNFOLLOW && unfollowedCount < MAX_UNFOLLOWS) {
const buttons = [...document.querySelectorAll('div[role="button"]')]
.filter(btn => btn.innerText === "Following" || btn.getAttribute('aria-label')?.includes("Following"));
for (const btn of buttons) {
if (window.STOP_UNFOLLOW || unfollowedCount >= MAX_UNFOLLOWS) break;
btn.click();
await sleep(500 + Math.random() * 1000);
const confirmBtn = document.querySelector('div[role="button"][data-testid="confirmationSheetConfirm"]');
if (confirmBtn) {
confirmBtn.click();
unfollowedCount++;
console.log(`β
Unfollowed ${unfollowedCount}`);
await sleep(1000 + Math.random() * 2000);
} else {
console.warn("β οΈ Confirm button not found. Skipping.");
}
}
scrollContainer.scrollBy(0, 2000);
await sleep(2000 + Math.random() * 2000);
if (scrollContainer.scrollHeight === lastHeight) break;
lastHeight = scrollContainer.scrollHeight;
}
console.log("π Done. Total unfollowed:", unfollowedCount);
}
unfollowAll();
- The script will:
- Scroll the page to load more followed users
- Click each "Following" button
- Confirm the Unfollow action
- Repeat until limit is reached or manually stopped
Paste this into the console anytime:
window.STOP_UNFOLLOW = true;