Skip to content

Instantly share code, notes, and snippets.

@jakobo
Last active July 24, 2023 19:08
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 jakobo/9b1732491d686dce58bb7077eef59e6b to your computer and use it in GitHub Desktop.
Save jakobo/9b1732491d686dce58bb7077eef59e6b to your computer and use it in GitHub Desktop.
Delete Tweets from Within X Itself
function clickDots(n) {
n.querySelector("div[aria-label='More']").click();
}
function clickDelete() {
[...document.querySelectorAll("div[role='menuitem']")].filter((n) => n.innerHTML.indexOf("Delete") >= 0)[0].click();
}
function clickConfirm() {
document.querySelector("div[data-testid='confirmationSheetConfirm']").click();
}
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function run() {
let tw;
do {
tw = [...document.querySelectorAll("article[data-testid='tweet']")].filter(
(n) => n.innerHTML.indexOf("Pinned") === -1
)[0];
if (!tw) break;
clickDots(tw);
await sleep(150);
clickDelete();
await sleep(150);
clickConfirm();
await sleep(1000);
} while (tw);
}
// run();
@jakobo
Copy link
Author

jakobo commented Jul 24, 2023

Delete Tweets From Within X

Precondition: X.com sucks, you want to nuke everything you've posted today save for a pinned message. You also don't have a legacy API account.

Throw it into the console. It does not start without your blessing.

You must manually call run() in the console. This won't run for you by default.

What this does

It is an automation loop. It...

  1. Clicks the "..." in your tweet
  2. Clicks "Delete" for you in the menu
  3. Clicks "Delete" for you on the dialog box
  4. Repeats until there's nothing left

To stop the madness, refresh your browser. It's not fast, because it can't be fast. But unless Elon decides to throw a tantrum, this will always work for as long as you can log in. (or they break accessibility. or their tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment