Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Code for a bookmarklet to more quickly delete DMs via the Twitter web interface.
// This doesn't work THAT well, but it kinda works... so!
// 1. Make a new bookmarklet with the code below as its URL
// 2. Go to
// 2a. This won't work on the "normal" DM pages, i.e., not the mobile site
// 3. Select a thread
// 3a. So, you see a list of messages now, right?
// 4. Click this bookmarklet :)
// 5. repeat as many times as necessary!
// 6. I think this probably goes without saying, but this doesn't delete your DMs from the *other* person's account. But it does make them invisible to, e.g., someone who hacks your account. Not that that's ever going to happen.
// 6a. It's definitely going to happen
javascript:(function(){document.querySelectorAll('div').forEach(function(e) {if (e.innerHTML.match(/\d+:\d\d \w\w$/g)) { console.log(e.innerHTML);; document.querySelectorAll('[role="button"] span').forEach(function(del) { if (del.innerHTML.match(/^Delete$/g)) { console.log("gotcha!");; } } ); } } ); })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.