Created
October 10, 2017 00:37
-
-
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.
This file contains hidden or 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
// 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(); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.