Skip to content

Instantly share code, notes, and snippets.

@anton-roos
Last active April 9, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anton-roos/dc953481ce4d4dde6051ee833dd2cee5 to your computer and use it in GitHub Desktop.
Save anton-roos/dc953481ce4d4dde6051ee833dd2cee5 to your computer and use it in GitHub Desktop.
Bulk unlike tweets with JavaScript
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function unlikeTweets() {
let tweets = document.querySelectorAll('[data-testid="tweet"]');
for (let tweet of tweets) {
let unlikeButton = tweet.querySelectorAll('[data-testid="unlike"]')[0];
if (unlikeButton != null) {
unlikeButton.scrollIntoView();
unlikeButton.click();
console.log("Clicked unlike");
await sleep(100);
} else {
console.log("Found no unlike button");
await sleep(100);
}
}
unlikeTweets();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment