Unfollow Accounts -- Tutorial
Step-by-step guide to unfollowing accounts on X using XActions browser scripts.
Prerequisites
- Logged into x.com in your browser
- Browser DevTools console (F12 -> Console tab)
Quick Start
- Navigate to
https://x.com/YOUR_USERNAME/following - Open DevTools (F12) and go to the Console tab
- Copy the contents of the script you need (see table below)
- Edit the
CONFIGsection - Paste into the console and press Enter
Scripts Overview
| Script | Requires core.js | Purpose |
|---|---|---|
src/unfollowEveryone.js |
No | Unfollow every account you follow |
src/unfollowback.js |
No | Unfollow only non-followers |
src/automation/smartUnfollow.js |
Yes | Time-based unfollow (integrates with keywordFollow) |
Configuration
src/unfollowEveryone.js
const CONFIG = {
maxUnfollows: Infinity,
minDelay: 1200,
maxDelay: 3000,
scrollDelay: 2000,
whitelist: [
// 'nichxbt',
// 'elonmusk',
],
dryRun: false,
maxRetries: 8,
maxConsecutiveErrors: 5,
rateLimitPauseMs: 60000,
trackUnfollowed: true,
exportOnComplete: true,
};
src/unfollowback.js
const CONFIG = {
maxUnfollows: Infinity,
whitelist: [],
dryRun: true, // SET FALSE TO EXECUTE
minDelay: 1500,
maxDelay: 3500,
scrollDelay: 2000,
maxConsecutiveErrors: 8,
maxEmptyScrolls: 6,
rateLimitCooldown: 60000,
exportOnComplete: true,
};
src/automation/smartUnfollow.js (requires core.js)
const OPTIONS = {
DAYS_TO_WAIT: 3, // Unfollow if not followed back in 3 days
MAX_UNFOLLOWS: 50,
WHITELIST: [],
DRY_RUN: false,
ONLY_TRACKED: true, // Only unfollow users tracked by keywordFollow
DELAY_BETWEEN_UNFOLLOWS: 2000,
};
Step-by-Step Guide
Unfollow Everyone
Step 1: Navigate to https://x.com/YOUR_USERNAME/following.
Step 2: Set your whitelist (accounts to never unfollow):
const CONFIG = {
whitelist: ['nichxbt', 'openai', 'bestfriend'],
dryRun: false,
maxUnfollows: 100, // Start with a small batch
};
Step 3: Paste src/unfollowEveryone.js. It scrolls through your following list and unfollows each account:
UNFOLLOW EVERYONE
LIVE
Max: 100 | Delay: 1200-3000ms | Whitelist: 3
#1 Unfollowed @randomuser1
#2 Unfollowed @randomuser2
#3 Unfollowed @randomuser3
...
#25 (25 done | 3 skipped | 0 err | 62s | 24.2/min)
Step 4: Use controls while running:
XActionsUtils.pause(); // Pause
XActionsUtils.resume(); // Resume
XActionsUtils.abort(); // Stop
Step 5: A JSON log is auto-downloaded and saved to localStorage.
Unfollow Non-Followers Only
Step 1: Navigate to https://x.com/YOUR_USERNAME/following.
Step 2: Start with a dry run:
const CONFIG = {
whitelist: ['nichxbt', 'important_friend'],
dryRun: true,
maxUnfollows: 50,
};
Step 3: Paste src/unfollowback.js. The script checks each user for the "Follows you" badge:
UNFOLLOW NON-FOLLOWERS
DRY RUN -- no accounts will be unfollowed.
Would unfollow: @nonfollower1
Would unfollow: @nonfollower2
Whitelisted: @important_friend
RESULTS
Scanned: 200
Unfollowed: 45
Follows back: 152
Whitelisted: 1
Step 4: Set dryRun: false and re-paste to execute:
dryRun: false,
Step 5: Use controls while running:
XActions.pause(); // Pause
XActions.resume(); // Resume
XActions.abort(); // Stop
XActions.status(); // Show progress
Smart Unfollow (Time-Based)
This works with keywordFollow.js to unfollow users who did not follow back within a grace period.
Step 1: First, you need follower data. Navigate to x.com/YOUR_USERNAME/followers and paste the smart unfollow script. It scrapes and saves your followers list.
Step 2: Then navigate to x.com/YOUR_USERNAME/following and paste it again. It compares against tracked users from keywordFollow.js:
const OPTIONS = {
DAYS_TO_WAIT: 3,
MAX_UNFOLLOWS: 30,
DRY_RUN: false,
ONLY_TRACKED: true,
};
Step 3: The script finds users you followed (via keywordFollow) who did not follow back within 3 days:
Starting Smart Unfollow...
Wait period: 3 days
Tracking 45 previously followed users
Loaded 1200 followers from previous scrape
Found 12 non-followers past the 3-day threshold
Unfollowing @user1 (didn't follow back in 3 days)
Unfollowing @user2 (didn't follow back in 3 days)
Done! Unfollowed 12 users.
Step 4: Stop at any time:
window.stopSmartUnfollow();
Tips & Tricks
- Always use
dryRun: truefirst withunfollowback.jsto preview who will be unfollowed. - The whitelist is critical. Add close friends, important contacts, and accounts you want to keep following regardless.
unfollowback.jsdetects the "Follows you" badge on each user cell. This is the most reliable indicator.- Rate limits are strict for unfollows. Keep delays at 1.5-3 seconds. The scripts auto-pause on rate limits.
- Progress is saved to localStorage. If you stop and restart, previously processed users are skipped.
- Reload and re-run if some users were missed. The following list loads lazily.
- Smart unfollow is a two-step process: scrape followers first (on /followers page), then unfollow (on /following page).
- Export is automatic. A JSON file downloads with all unfollowed accounts and statistics.
Troubleshooting
| Problem | Solution |
|---|---|
| "Wrong page! Go to /following" | Navigate to x.com/YOUR_USERNAME/following |
| "Core module not loaded!" | Paste core.js before smartUnfollow.js |
| "No tracked users found" | Run keywordFollow.js first, or set ONLY_TRACKED: false |
| "No followers data" | Run smartUnfollow on /followers page first to scrape |
| Script stops after a few unfollows | Rate-limited. Wait 60 seconds or increase delays. |
| "Consecutive errors -- aborting" | X may have changed the unfollow confirmation UI |
| Whitelisted user still unfollowed | Check whitelist spelling (case-insensitive, no @ prefix) |
Related Scripts
src/followAccount.js-- Follow specific accountssrc/automation/keywordFollow.js-- Keyword-based followsrc/automation/followTargetUsers.js-- Follow followers of target accountssrc/detectUnfollowers.js-- Detect who unfollowed you
⚡ Ready to try Unfollow Accounts -- Tutorial?
XActions is 100% free and open-source. No API keys, no fees, no signup.
Browse All Scripts