Raise the fooBar Rotating Header Image

How to delete entire twitter conversations (direct messages)?

I recently wanted to delete a massive twitter conversation with thousands of messages. To my surprise, there’s no way to delete a whole conversation with a single click in the Twitter.com Web GUI. The Twitter MacOS App has a “Delete Conversation” entry in a conversation’s context menu, but that just removes it from the Gui. Restarting the app shows that it is, in fact, still present.

My guess is that their Message storage doesn’t allow efficient deletion of conversations. But what if I _really_ want to get rid of them?

An option is to search for these services… you know… those shady ones that claim they can do the job for you, want access to your twitter account and, after you have granted them full access, ask you to take out your wallet and pay if you _really_ want them to help you. Well, F such a business model. Seriously.

There’s an easier, much safer way to delete entire conversations and guess what: I’ll tell it to you for free!

Okay, here’s what you do:

  1. Open Chrome (we’ll need the developer console. Other browsers might work, too, but I use Chrome, so I’m gonna stick with it here)
  2. Log in to twitter and go to your “Me” page
    https://twitter.com/<yournick>
  3. Open your messages (the button with the envelope) and select the conversation you want to delete. You now have the conversation-to-be-deleted in front of you.
  4. Open the JavaScript Developer console (Command+Alt+J on Chrome / MacOS)
  5. Paste the following JavaScript into the console and press enter:
    $('#global-actions').append($('<li id="del-script">').append($('<a class="js-nav">"').text('...')));
    window.delscrpt = setInterval(function() {
      $('.js-dm-error:visible').each(function() { $('a.js-dismiss', this).click(); });
      var count = $('.js-dm-delete').length;
      if (count < 3) {
        $('#del-script a').text('Del Done.');
        clearInterval(window.delscrpt);
        return;
      }
      var randIdx = Math.floor((Math.random()*count)+1);
      $('#del-script a').text('Del ' + randIdx + '/' + count);
      $('.js-dm-delete').eq(randIdx).click();
      $('.dm-delete-confirm .js-prompt-ok').each(function() { $(this).click(); });
    }, 2000);
  6. Sit back, relax and watch your conversation disappear one message at a time.

DISCLAIMER:

  • Don’t expect any support. Use at your own risk. I think this should be pretty obvious 😉
  • This method works by directly manipulating the HTML DOM of the twitter page (remote controlling the GUI if you will). It works for now (mid-September 2013), but if twitter changes their homepage, this method will die. Keep that in mind.
  • The deletion might take some time. We don’t want to hammer the twitter servers and get our account blocked after all 😉
  • Twitter has some major issues with message deletion (internal server error’s and stuff). That’s why we can’t delete messages in order and have to delete them randomly until the conversation is empty. You can’t just delete parts of a conversation. You’ve been warned.
  • The script will stop when less than 3 messages are left in the conversation, in order not to bug out. You’ll have to spend the 10 seconds and delete these last messages manually.
  • The script displays some numbers in the twitter navigation bar (in the background). The first number is the index of the randomly selected message that’s being deleted from within the returned message list. The second is the total number of messages currently returned by the twitter servers. This total number doesn’t represent the “real” number of left-over messages all the time. That’s just because of the way twitter works and spits out your messages… Non-deterministic NoSQL and stuff…

Hope it’s useful to anyone 🙂

13 Comments

  1. programmer says:

    this not work with me can you help me .

    There is a particular direct message (DM) that is being shown to me when I visit my Twitter account on Twitter-Web, and when I click on the trash icon I get an instant message saying “Internal Server Error” and the DM doesn’t delete .

  2. programmer says:

    when i try what you say i get this

    POST https://twitter.com/direct_messages/destroy 404 (Not Found) .

  3. Mike Meessen says:

    Yes, I got that lots of times, too. I don’t know whether that’s a Twitter bug or if they do that intentionally for some freaky reason :/ Sometimes it helps to just leave it and try it later. Anyway, I don’t have a reliable solution for that weird behavior… unfortunately.

  4. programmer says:

    thanx , but this problem was than 6 month .

  5. thanks! says:

    still works end of April 2014, flawlessly, changed 2000 to 100 to be faster 😛

  6. Joe Scarponi says:

    Now towards the end of May 2014 and it does NOT work. Status of 403 (Forbidden) message appears in the Console.

  7. Can A. says:

    There may be some times when some problems occur due to Twitter servers.

    This method has just worked for me on my Ubuntu OS, with Firefox Web Browser on June 2, 2014.

    Thanks!

  8. Jazmine says:

    OMG THANK YOU SO MUCH! have been looking for a way to do this for months! thank you!!!

  9. Sakti says:

    Wow, Thanks man! Still Working

  10. Josh says:

    Thanks a lot man, really useful

  11. Fahad says:

    Thank you

  12. Marie says:

    I tried to use it for some DM’s that weren’t deleting from an account that had been deleted…it gives me the same Error 404 (not found) and the red ‘Internal Server Error’ still shows. I want them gone! Any help?

  13. Sunny says:

    It does not work now 🙁 2016

Leave a Reply

Your email address will not be published. Required fields are marked *