How to Mass Delete All of Your Tweets Including Old “Invisible” Cached Ones
You might not like the new owner and are worried about you data. Perhaps you’re a journalist who quickly needs to scrub tweets. Maybe you just want delete your childish embarrassing tweets from when you were young. You want to start over. Turns out many services only delete the last few thousand tweets before you can no longer view the older tweets on your profile. Well I found simple Javascript on Stackoverflow that lets you delete your old cached hidden tweets.
How do you find your old tweets? Well you use the advanced search. You have to search through month by month. For each tab I opened one month of tweets. This can be done easily by just duplicating the tab and changing the dates in the search. Then you open development tools in your browser, paste the code in the console, and hit enter. You do this for each tab. The script will automatically browse through and load new tweets from your search and delete them in batches. Just leave it run for a night or an entire weekend and most tweets will be scrubbed by morning or on Monday.
var delTweets = function () {
var tweetsRemaining =
document.querySelectorAll('[role="heading"]+div')[1].textContent;
console.log('Remaining: ', tweetsRemaining);
window.scrollBy(0, 10000);
document.querySelectorAll('[aria-label="More"]').forEach(function
(v, i, a) {
v.click();
document.querySelectorAll('span').forEach(function (v2, i2, a2) {
if (v2.textContent === 'Delete') {
v2.click();
document.querySelectorAll('[data-testid="confirmationSheetConfirm"]').forEach(function (v3, i3, a3) {
v3.click();
});
}
else {
document.body.click();
}
});
});
setTimeout(delTweets, 4000); //less than 4000 might be rate limited or account suspended. increase timeout if any suspend or rate limit happens
}
delTweets();
Source of the code: https://stackoverflow.com/a/72515907
Delete Retweets (Go to your timeline):
var undoRetweets = function() {
var retweets = document.querySelectorAll('[data-testid="unretweet"]');
retweets.forEach(function(retweetButton) {
retweetButton.click(); // Click the unretweet button
// Handle the confirmation dialog
var confirmButton = document.querySelector('[data-testid="unretweetConfirm"]');
if (confirmButton) {
confirmButton.click();
}
});
console.log(retweets.length + ' retweets undone.');
window.scrollBy(0, 1000); // Scroll down to load more tweets
setTimeout(undoRetweets, 5000); // Wait for 5 seconds before repeating
};
undoRetweets();
Delete favorites (Go to your favorites):
var undoFavorites = function() {
var likes = document.querySelectorAll('[data-testid="unlike"]');
likes.forEach(function(likeButton) {
likeButton.click(); // Click the unlike button
});
console.log(likes.length + ' favorites undone.');
window.scrollBy(0, 1000); // Scroll down to load more tweets
setTimeout(undoFavorites, 5000); // Wait for 5 seconds before repeating
};
undoFavorites();
If you scroll through while the script is running it speeds up the process.
Finally keep track of your tweet count in your profile and special thanks to the guy on Stackoverflow.