Clearing Twitter Data

Clearing Twitter Data

While I am moving off Twitter these are some of the ways you can keep your data safe.

Because of EU regulations that are designed to protect users data and privacy, companies now offer functionality to be able to Download all your data, and also the functionality to Delete all your data easily. While this is only an EU thing, companies have put this out to everyone regardless of geolocation to show good will and to let people know they are taking user data seriously. Or because they wanted to avoid more regulations.

Screenshot of Twitter Settings Page

Archive

First of all, if you want to keep your data, you can download an archive of all of your data.
Under Settings and Support > Settings and Privacy > Your Account, you should find a link to “Download an archive of your data”.
This does take a bit for Twitter to prepare. It can take a few days before the archive is ready. Once it is ready you will get an email with a link to download the archive. (keep this in a safe place!)
This is one of the things I was worried could break. Then I would lose all my data.

Deactivating and Deleting Account

Under Settings and Support > Settings and Privacy > Your Account, you should find a link to “Deactivate your Account”. And this setting should allow you to Deactivate and Delete your account. Twitter will still have your data for 30 days, during which you can Reactivate your account if you wish, but after the 30 days they say that your account including all tweets, likes, DMs will be Deleted.

Deleting Tweets and Likes

For me, I actually wanted to keep my account but delete all my tweets and likes. Holding on to my account to be able to still communicate with people and to view others tweets just made sense for me.
There are several ways to delete all your tweets.

  1. API script
    This option is not easy as it involves creating an Application that will systematically delete each of your tweets one by one. But with Twitter now charging money to have API access, this may not be possible anymore. There are a lot of guides and examples out there that shows you how to use the API, but really this is only for experts.
  2. Paid Service
    There are companies out there that can delete your Tweets for you. This is the way I went about it. I used TweetDelete. This company does use the aforementioned API method to delete all your tweets for you for a small fee. It still has to follow the API restrictions, so using this service, you can only delete 5000 tweets a month. There are ways around this they offer for a higher fee which I did pay for and it did a great job. But their functionality for deleting likes wasn’t working. I think this was because a change on the API or something. The paid services do charge a monthly rate, so make sure to stop that monthly charge once you are done with the service!
  3. Manually
    So you can go to the Twitter page and manually one by one click on the links to delete all of your tweets and likes. Depending on how many tweets you created and likes you have, this may take a very long time! Those of you with larger accounts good luck with that!
  4. Manually Automatically
    This is fun. I actually created a script that can run on your browser that will one by one delete all of your tweets and likes by simulating a user sitting there and clicking each button one by one. I done this work because TweetDelete couldn’t remove all my likes. If you do go this route tho, you probably will be breaking your user agreement with Twitter so do so at your own risk.

Scripts

Twitter Console Screenshot

To run these scripts you have to open up the console.
Usually done by pressing F12 and clicking on the “Console” Tab.
Really a website is an application that runs on your browser window, and the console is a place where you have full control over the website.
I mean, you do have full control over your website to begin with, but the console is kinda like doing that on expert mode. Don’t trust anyone who tells you to copy/paste anything unknown here. The script might be malicious.

Delete Tweets

Go to your twitter profile page. So for me that is https://twitter.com/GeekGirl1024
And then open the console like I described above.
And copy/paste the following script.
When you press enter the script will start and delete all of your tweets one by one. (It is kinda fun to watch it go)

let waitTime = 500;

function OpenMoreMenu() {
  let moreButton = document.querySelector("div[aria-haspopup='menu'][aria-label='More']");
  if (moreButton) {
    moreButton.click();
    setTimeout(ClickDelete, waitTime);
  } else {
    console.log("I can't find anything more to do");
  }
}

function ClickDelete() {
  let deleteButton = document.querySelector("div[role='menu'] div[role='menuitem']");
  if (deleteButton) {
    deleteButton.click();
    setTimeout(ConfirmDelete, waitTime);
  } else {
    console.log("I can't find anything more to do");
  }
}

function ConfirmDelete() {
  let confirmButton = document.querySelector("div[data-testid='confirmationSheetDialog'] div[role='button']");
  if (confirmButton) {
    confirmButton.click();
    setTimeout(OpenMoreMenu, waitTime);
  } else {
    window.scrollTo(0, document.body.scrollHeight);
    setTimeout(OpenMoreMenu, waitTime);
  }
}

OpenMoreMenu();

If at any point you want to stop the script you can just refresh the browser window.
I wrote this after I already deleted all my tweets, and I posted a new bunch to delete but wasn’t enough to get a load more tweets option. I did add a function to scroll to the bottom. Maybe that loads more tweets? Anyway use however you like.

Delete Likes

Because TweetDelete delete likes functionality was broken, I created this script to automatically delete all my likes one by one.
Go to your profile page again and click on “Likes”
And then open the console like I described above.
And copy/paste the following script.
When you press enter the script will start and unliking all of your tweets one by one. (It is kinda fun to watch it go)


let waitTime = 500;

function batchUnlike(isContinue) {
    
  let unlike = document.querySelector("div[data-testid='unlike']");
  if (unlike) {
    unlike.click();
    window.setTimeout(() => { batchUnlike(false) }, waitTime);
  } else {
    if (isContinue) {
      console.log("I can't find anything else to do")
    } else {
      window.scrollTo(0, document.body.scrollHeight);
      window.setTimeout(() => { batchUnlike(true) }, 15000);
    }
  }
}

batchUnlike(false);

This script is a bit more rudimentary cuz I just threw it together. It does however does auto scroll to load more likes.
It just finds all unlike buttons and clicks on them one by one. If it doesn’t find anymore unlike buttons it scrolls down, and waits 15 sec for more tweets to load and keeps going.
Refresh your website to stop it running.

Note

If not having enough time between actions, Twitter may detect you acting like a bot or something and start refusing to take your requests. If that is the case then probably adjust the wait time to be slower and run it again later.
I think sometimes while you still have more tweets or likes, Twitter won’t give you any more to delete, but there are still more. Those probably were in deep storage somewhere, and gotta let Twitter bring out the most recent ones and you can run the scripts again.
The scripts here are super fragile. It relies on it’s capability to find certain buttons. If for some reason Twitter changes their UI or some other things, they may fail to work.
Twitter may ban you for using these scripts!
Use at your own risk.
Don’t come at me asking for help.