Skip to content

Instantly share code, notes, and snippets.

@mattlockyer
Last active June 1, 2019 16:45
Show Gist options
  • Save mattlockyer/9889e816c0ce0c7eddd2970b9200adc4 to your computer and use it in GitHub Desktop.
Save mattlockyer/9889e816c0ce0c7eddd2970b9200adc4 to your computer and use it in GitHub Desktop.
Unfollow everyone on Twitter
/*
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