Skip to content

Instantly share code, notes, and snippets.

@meysampg
Forked from lindenb/README.md
Last active March 23, 2024 21:31
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 meysampg/7a4f63cc1e47ccf18af44bdaab5cc4c5 to your computer and use it in GitHub Desktop.
Save meysampg/7a4f63cc1e47ccf18af44bdaab5cc4c5 to your computer and use it in GitHub Desktop.
Delete Tweets
I want to delete all my tweets without deleting my account.
This script deletes your tweets and repost from twitter without using the Twitter API, just by using the **firefox** javascript scratchpad.
Chage **YOURNAME** in the script below.
The script is quite slow but it works so far , I set some long timeout to let the DOM document to (re)load.
May be it could be much faster but I'm not a javascript guy.
- Open https://twitter.com/USERNAME
- Open the Firefox Developer Tools `Firefox > Tools > Browsers Tool > Web developer Tools`. Go to the "Web Console" tab ([ https://firefox-source-docs.mozilla.org/devtools-user/](https://firefox-source-docs.mozilla.org/devtools-user/web_console/) )
- paste the javascript code into the Command line intrepreter https://firefox-source-docs.mozilla.org/devtools-user/web_console/the_command_line_interpreter/index.html
- wait...
function confirmDelete() {
var iter = document.evaluate("//span[text()='Delete' and @style='text-overflow: unset;']",document,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
var a = iter.iterateNext();
if(a==null) return false;
a.click();
return true
}
function moreDelete() {
console.log("moreDelete");
var iter = document.evaluate("//span[text()='Delete']",document,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
var a = iter.iterateNext();
if(a==null) return false;
a.click();
return confirmDelete();
}
function undoRepost() {
var iter = document.evaluate("//span[text()='Undo repost']",document,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
var a = iter.iterateNext();
if(a==null) return false;
a.click();
return true;
}
function postDetector() {
var iter = document.evaluate("//div[@aria-label='More' and @role='button']",document,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
var a = iter.iterateNext();
if(a==null) return false;
a.click();
if (moreDelete()) {
setTimeout(postDetector, 1000);
}
}
function repostDetector() {
var iter = document.evaluate("//div[contains(@aria-label,'Reposted') and @role='button' and @data-testid='unretweet']",document,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
var a = iter.iterateNext();
if(a==null) return false;
a.click();
if (undoRepost()) {
setTimeout(repostDetector, 1000);
}
}
function collect() {
console.log("colllect");
postDetector();
repostDetector();
}
collect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment