Skip to content

Instantly share code, notes, and snippets.

@robinsloan
Created September 1, 2019 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinsloan/01fcd60be602ed8f7e4a741ce6092bcd to your computer and use it in GitHub Desktop.
Save robinsloan/01fcd60be602ed8f7e4a741ce6092bcd to your computer and use it in GitHub Desktop.
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 mobile.twitter.com/messages
// 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); e.click(); document.querySelectorAll('[role="button"] span').forEach(function(del) { if (del.innerHTML.match(/^Delete$/g)) { console.log("gotcha!"); del.click(); } } ); } } ); })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment