Skip to content

Instantly share code, notes, and snippets.

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/930e64d41d5c449122b8fcccc96def69 to your computer and use it in GitHub Desktop.
Save anton-roos/930e64d41d5c449122b8fcccc96def69 to your computer and use it in GitHub Desktop.
Delete your tweets from Tweets & replies with JavaScript
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function deleteTweets() {
let tweets = document.querySelectorAll('[data-testid="tweet"]');
for (let tweet of tweets) {
// Replace "Your Display Name"
if (tweet.querySelector("span:first-child").innerHTML.includes("Your Display Name")) {
console.log("My tweet");
tweet.querySelectorAll('[data-testid="caret"]')[0].scrollIntoView();
tweet.querySelectorAll('[data-testid="caret"]')[0].click();
console.log("Clicked caret");
await sleep(1000);
document.querySelectorAll('[role="menuitem"]')[0].click();
console.log("Clicked delete");
await sleep(1000);
document
.querySelectorAll('[data-testid="confirmationSheetConfirm"]')[0]
.click();
console.log("Clicked confirm");
await sleep(1000);
} else {
console.log("Not my tweet");
}
}
deleteTweets();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment