Created
December 9, 2022 00:10
-
-
Save gugadev/3c382543ecb5b287ee7a992245f4691b to your computer and use it in GitHub Desktop.
Tiny script to unfollow all people you're following. Just go to https://twitter.com/<youruser>/following, open the console and run the code (testing in responsive mode).
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
function unfollow() { | |
let count = 0 | |
const buttons = document.querySelectorAll('[data-testid*="-unfollow"]') | |
if (!buttons.length) { | |
console.log(`${count} People unfollowed`) | |
return | |
} | |
const waitFor = (ms) => new Promise(resolve => setTimeout(resolve, ms)) | |
const acceptModals = async (index = 0) => { | |
if (index === buttons.length - 1) { | |
return | |
} | |
const confirmBtn = document.querySelector('[data-testid*="confirmationSheetConfirm"]') | |
confirmBtn.click() | |
count += 1 | |
await waitFor(150) // you can play with this timing if you don't have the desired results. | |
return acceptModals(index + 1) | |
} | |
for (const button of buttons) { | |
button.click() | |
} | |
acceptModals().then(unfollow, console.err) | |
} | |
unfollow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment