Last active
August 25, 2024 15:41
-
-
Save jakobo/9b1732491d686dce58bb7077eef59e6b to your computer and use it in GitHub Desktop.
Delete Tweets from Within X Itself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...
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)