Skip to content

Instantly share code, notes, and snippets.

@kylehotchkiss
Created October 10, 2017 00:37
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 kylehotchkiss/ada2830256d596dcd6a76452637795f6 to your computer and use it in GitHub Desktop.
Save kylehotchkiss/ada2830256d596dcd6a76452637795f6 to your computer and use it in GitHub Desktop.
Twitter bulk tweet deleter. Run in twitter console. To get a `authenticity_token`, make a tweet on twitter.com, then check network. It's in the inspector. Doesn't appear rate limited (uses twitter's internal API), but hard to tell.
// Download your archive and use the CSV to get IDs to delete.
var tweets = ["X", "Y", "Z"]
// See description about authenticity_token
(function() {
var i = 0;
var iterator = function iterator() {
if ( i < tweets.length ) {
var tweet = tweets[i]
fetch('https://twitter.com/i/tweet/destroy', {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'x-twitter-active-user': 'yes',
'x-requested-with': 'XMLHttpRequest',
'accept': 'application/json, text/javascript, */*; q=0.01'
},
body: $.param({
_method: 'DELETE',
authenticity_token: '%SEE ABOVE%',
id: tweet
})
}).then(() => {
i++; iterator();
}).catch(( error ) => {
console.log( error );
i++; iterator();
});
} else {
console.log('Done!');
}
}
iterator();
})();
@kylehotchkiss
Copy link
Author

In order to get the IDs I wanted to delete, I made a small script locally that used React to narrow down tweets. Using a blacklist to blanket remove some terms, and a rule to delete all but 5 tweets for every month of twitter history before one year ago. I recommend making a cool UI yourself to narrow down tweet IDs from archive.

Enjoy.

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