Created
March 2, 2026 18:39
-
-
Save ftmoose/f14eebb686d727e65bb7aacfcad215d8 to your computer and use it in GitHub Desktop.
Delete all X 'tweets' from your profile, run on the 'replies' tab.
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 username = '@username'; | |
| const deleteAllTweets = async () => { | |
| const processed = new Set(); | |
| const delay = ms => new Promise(r => setTimeout(r, ms + Math.random() * ms * 0.5)); | |
| const processTweet = async (tweet) => { | |
| if (processed.has(tweet)) return; | |
| processed.add(tweet); | |
| const retweetBtn = tweet.querySelector('[data-testid="unretweet"]'); | |
| if (retweetBtn) { | |
| retweetBtn.click(); | |
| await delay(250); | |
| const confirm = document.querySelector('[data-testid="unretweetConfirm"]'); | |
| if (confirm) confirm.click(); | |
| return; | |
| } | |
| const caret = tweet.querySelector('[data-testid="caret"]'); | |
| if (caret) { | |
| caret.click(); | |
| await delay(250); | |
| const dropdown = document.querySelector('[data-testid="Dropdown"]'); | |
| if (dropdown && dropdown.firstElementChild) { | |
| dropdown.firstElementChild.click(); | |
| await delay(250); | |
| const confirm = document.querySelector('[data-testid="confirmationSheetConfirm"]'); | |
| if (confirm) confirm.click(); | |
| } | |
| } | |
| }; | |
| while (true) { | |
| const tweets = Array.from(document.querySelectorAll('[data-testid="tweet"]')) | |
| .filter(t => !processed.has(t)) | |
| .filter(t => t.innerText && t.innerText.includes(username)); | |
| if (!tweets.length) { | |
| window.scrollTo({ top: document.body.scrollHeight, behavior: 'instant' }); | |
| await delay(250); | |
| const fresh = document.querySelectorAll('[data-testid="tweet"]'); | |
| if (![...fresh].some(t => !processed.has(t))) break; | |
| continue; | |
| } | |
| for (const tweet of tweets) { | |
| await processTweet(tweet); | |
| } | |
| // window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }); | |
| await delay(250); | |
| } | |
| console.log('All tweets processed.'); | |
| }; | |
| deleteAllTweets(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment