DEV Community

Cover image for Delete your Twitter data while it's still free. (so until February 9th 2023)
Al
Al

Posted on

Delete your Twitter data while it's still free. (so until February 9th 2023)

This might be your last chance to easily delete all of your tweets without a hassle. Here's what you gotta do to reduce your digital footprint before Elon revokes free access to the API and therefore destroys a plethora of apps.

The ways to mass delete your tweets and likes is limited, the free API will only go up to 3200 deleted tweets. If you have thousands of them, immediately request your twitter archive, it will take up to 24 hours for you to get it and download it:

You have to go there to request it:
Settings and Support > Settings and privacy > Your Account > Download an archive of your data

Also available through this link: DOWNLOAD YOUR DATA

Once this is done, extract your archive cause it's time to start cleaning.

We will use this great app by Logan Han: https://github.com/logan-han/twitter-deleter

But before that, go to wherever you extracted your twitter archive and rename data/tweets.js with data/tweet.js. We need to remove the 's' to use the singular form.

The reason is that at the time I'm writing this (03 February 2023), the app we're going to use will look for data/tweet.js, singular form, even though the Twitter archive use the plural form.

Now open tweet.js with your favorite editor and edit the first two lines of your file this:

Before:

window.YTD.tweets.part0 = [
  {
    "tweet" : {
Enter fullscreen mode Exit fullscreen mode

After:

window.YTD.tweets.part0 = [{
  "tweet": {
Enter fullscreen mode Exit fullscreen mode

Once you're done, save and zip this js file.

Head to Logan's site, right here: https://twitter.han.life/

Now be aware that the app only supports up to 10MB so if you exceed this weight there is a very easy fix: cut your tweet.js file into multiple parts and simply re-run the app until you've deleted everything.

One tweet looks like this:

{
  "tweet": {
    "edit_info": {
      "initial": {
     ......
    "favorited": false,
    "full_text": "blablabla",
    "lang": "en"
  }
},
Enter fullscreen mode Exit fullscreen mode

It starts with { followed by "tweet": { and ends with a bracket followed by a comma: },

Keep this pattern in mind while removing excess tweets to run the app, make sure in any case that your tweet.js files will always start with this: window.YTD.tweets.part0 = [{ and end with this: ]

Now let the app run and go do something else, it will delete all of your tweets.

Now onto the likes...


Open your browser, go to your likes (https://twitter.com/[YOURACCOUNT]/likes), open the dev console and paste this in it:

setInterval(() => {
for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
d.click()
}
window.scrollTo(0, document.body.scrollHeight)
}, 10000)
Enter fullscreen mode Exit fullscreen mode

You can also use GreaseMonkey for your script and you can find more snippets over here and see what works best for you: https://gist.github.com/aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d

Just keep in mind that you will need to be aware of cooldowns, the API will block you for minutes or hours if do too many requests, the rate limit seems to be of 900 requests every 15 minutes.

Be wary that there are likes that will persist even if they show up as unliked, you will have to re-like and re-unlike them to get rid of them:

setInterval(async () => {
  for (const d of document.querySelectorAll('div[data-testid="like"]')) {
     d.click()
  }

  await new Promise(r => setTimeout(r, 5000));

  for (const e of document.querySelectorAll('div[data-testid="unlike"]')) {
    e.click()
  }

  window.scrollTo(0, document.body.scrollHeight)
}, 20000)
Enter fullscreen mode Exit fullscreen mode

This snippet by 0xfoobar does this and has greater timeouts between liking and unliking (so the API will not be angry at you).

Enjoy experimenting and reducing your online footprint!

Top comments (0)