Skip to content

Instantly share code, notes, and snippets.

@bracca95
Last active February 6, 2023 13:39
Show Gist options
  • Save bracca95/ea06bfa6c38316566f7a14a0efcd5939 to your computer and use it in GitHub Desktop.
Save bracca95/ea06bfa6c38316566f7a14a0efcd5939 to your computer and use it in GitHub Desktop.
delete-tweets.md

Ever wanted to delete all your tweets from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/with_replies
  2. Open the console and run the following JavaScript code:
/* define a function to delete tweets */
var myName = "INSERT YOUR TWITTER NAME HERE"

function unTweet() {
	// for every post
	for (const d of document.getElementsByClassName("css-1dbjc4n r-1loqt21 r-16y2uox r-1wbh5a2 r-1ny4l3l r-1udh08x r-1j3t67a r-o7ynqc r-6416eg")) {
		// if there is my name
		if (d.querySelectorAll('span[class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0"]')[0].innerHTML.includes(myName)) {
			// press the top-right arrow
			d.querySelectorAll('div[data-testid="caret"]')[0].click()
			// on the new window
			var fines1 = document.querySelectorAll('div[class="css-1dbjc4n r-yfoy6g r-1f0042m r-xnswec r-1ekmkwe r-1udh08x r-u8s1d"]')[0]
			// press "Delete"
			fines1.querySelectorAll('div[class="css-901oao r-daml9f r-1qd0xha r-a023e6 r-16dba41 r-ad9z0x r-bcqeeo r-qvutc0"]')[0].click()

			// final window
			var fines2 = document.querySelectorAll('div[class="css-1dbjc4n r-1awozwy r-yfoy6g r-t23y2h r-1jgb5lz r-pm9dpa r-1ye8kvj r-1rnoaur r-d9fdf6 r-1sxzll1 r-13qz1uu"]')[0]
			// press Delete
			fines2.querySelectorAll('div[class="css-18t94o4 css-1dbjc4n r-1dgebii r-42olwf r-sdzlij r-1phboty r-rs99b7 r-16y2uox r-1w2pmg r-1vuscfd r-1dhvaqw r-1ny4l3l r-1fneopy r-o7ynqc r-6416eg r-lrvibr"]')[0].click()
		}
	}
	// scroll window by 500 lines
	window.scrollBy(0, 500);
}

/* call it every 5000 ms (can be changed) */
var myProc = setInterval(unTweet, 5000)
  1. When the bottom is reached, type:
/* stop the process */
clearInterval(myProc)
  1. Don't forget to checkout how to remove likes and retweets!
@Sylphystia
Copy link

This doesn't appear to be working. I tried putting my handle on the first line both with and without the @ symbol.

@magdyrashwan
Copy link

does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment