Last active
November 25, 2024 02:53
-
-
Save vincerubinetti/de993cd0d842a7afc8743a016b1a27ff to your computer and use it in GitHub Desktop.
Run in dev console on Twitter followers page to get buttons to easily force users to unfollow you
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
const sleep = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms)); | |
const update = () => | |
document.querySelectorAll(`[data-testid="UserCell"]`).forEach((row) => { | |
if (row.querySelector(".unfollow-button")) return; | |
const button = document.createElement("button"); | |
button.className = "unfollow-button"; | |
button.innerText = "Unfollow"; | |
button.onclick = async () => { | |
const dropdown = row.querySelector(`[aria-label="More"]`); | |
dropdown.focus(); | |
dropdown.click(); | |
await sleep(); | |
document.querySelector(`[data-testid="removeFollower"]`).click(); | |
await sleep(); | |
document | |
.querySelector(`[data-testid="confirmationSheetConfirm"]`) | |
.click(); | |
row.remove(); | |
}; | |
row.append(button); | |
const avatar = row.querySelector(`[data-testid^="UserAvatar-Container"]`); | |
avatar.parentElement.parentElement.style.flexBasis = "200px"; | |
avatar.style.height = ""; | |
}); | |
update(); | |
new MutationObserver(update).observe(document, { | |
subtree: true, | |
childList: true, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment