Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.
- Go to: https://twitter.com/{username}/likes
- Open the console and run the following JavaScript code:
setInterval(() => {
for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
d.click()
}
window.scrollTo(0, document.body.scrollHeight)
}, 1000)
function getAllTweetButtons() {
return Array.from(document.querySelectorAll('.tweet-interact-favorite'));
}
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function processTweet(tweetButton) {
tweetButton.focus();
tweetButton.click(); // Click to like (if not liked) or unlike (if liked)
await wait(1000); // Reduced wait time
// Check if the tweet is still liked, if so, click again to unlike
if (tweetButton.classList.contains('tweet-interact-favorited')) {
tweetButton.click(); // Click again to ensure it's unliked
await wait(500); // Reduced wait time
console.log('Ensured tweet is unliked');
} else {
console.log('Processed tweet');
}
}
async function removeAll() {
let count = 0;
let tweetButtons = getAllTweetButtons();
while (count < 500 && tweetButtons.length > 0) {
for (let i = 0; i < tweetButtons.length && count < 500; i++) {
await processTweet(tweetButtons[i]);
count++;
if (count % 50 === 0) {
console.log('Waiting to prevent rate-limiting');
await wait(15000); // Wait to prevent rate-limiting
}
}
}
console.log('Finished, count =', count);
}
removeAll();
Fix for shadow likes on feed
Works with Old Twitter layouts
Modify the rate limiting waiting as neccessary