Last active
June 1, 2019 16:45
-
-
Save mattlockyer/9889e816c0ce0c7eddd2970b9200adc4 to your computer and use it in GitHub Desktop.
Unfollow everyone on Twitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Go to mobile.twitter.com | |
Click following and you should see the followers / following tabs at the top, make sure you're on "following". | |
Open the developer console and paste this bad boy in. | |
You can watch it working away... And stop it anytime by closing the tab. | |
It will start with your most recently followed first and work backwards chronological as it scrolls the accounts you follow. | |
*/ | |
const qs = (sel) => document.querySelectorAll(sel) | |
let arr = [] | |
const scroll = () => { | |
window.scroll(0, 9999999999999999) //scroll window | |
setTimeout(() => { | |
//fill array with 'Following' buttons | |
arr = Array.prototype.slice | |
.call(qs('[role=button] div span span')) | |
.filter((n) => n.innerText.indexOf('Following') !== -1) | |
unfollow() | |
}, 2000) | |
} | |
const unfollow = () => { | |
if (arr.length > 0) { | |
arr.pop().parentNode.parentNode.parentNode.click() //pop from array and click | |
setTimeout(() => { | |
qs('[role=button] div span span')[0].click() //click confirm unfollow | |
setTimeout(unfollow, 2000 + (Math.random() * 2000)) | |
}, 500) | |
} | |
else scroll() | |
} | |
scroll() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment