Skip to content

Instantly share code, notes, and snippets.

Last active May 15, 2024 09:49
Show Gist options
  • Save aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d to your computer and use it in GitHub Desktop.
Save aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d to your computer and use it in GitHub Desktop.
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to:{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
  window.scrollTo(0, document.body.scrollHeight)
}, 1000)
Copy link

Anon14j1 commented Apr 5, 2024

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();; // 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')) {; // 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 } }

// Scroll to the bottom of the page to load more tweets
window.scrollTo(0, document.body.scrollHeight);
await wait(3000); // Wait for more tweets to load
tweetButtons = getAllTweetButtons(); // Refresh the list of tweet buttons


console.log('Finished, count =', count); }


Fix for shadow likes on feed Works with Old Twitter layouts Modify the rate limiting waiting as neccessary

Im getting a Promise error when i try this
"promise {: undefined}"

Copy link

In my account, I have 53 unavailable posts that exist only as a number, and as for likes, they are 66 unavailable likes, and sometimes they are 99 likes. What is the solution to make the same number 0 in the posts and likes tab? I have tried all available solutions and have been suffering from this issue for more than a year and have not found a solution?!

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