Skip to content

Instantly share code, notes, and snippets.

@aymericbeaumet
Last active May 4, 2026 17:15
Show Gist options
  • Select an option

  • Save aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d to your computer and use it in GitHub Desktop.

Select an option

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: https://twitter.com/{username}/likes
  2. 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)
@Scoubi-7
Copy link
Copy Markdown

Scoubi-7 commented Jan 27, 2026

I want to delete my old likes.
Usually when I wanted my old likes appear, I force the update by scrolling down the page and the codes above work fine for me.
But since yesterday, the old likes no longer appear with these method (even with the @hamzah1P16 code)
I tried with Brave, google and with the application.
I have over 2800 likes but they are invisible
Do you have a solution?

@arepageek
Copy link
Copy Markdown

arepageek commented Apr 11, 2026

I created this:


// Paste this entire code in console on: https://x.com/YOURUSERNAME/likes

(() => {
  console.log('%c🚀 Starting Ultimate X Likes Unremover v5 (2026)...', 'color: #1d9bf0; font-size: 18px; font-weight: bold;');
  console.log('%c✅ Script loaded successfully - ignore the "undefined" below', 'color: #00c060;');

  const CONFIG = {
    maxUnlikes: 999999,
    baseDelay: 2350,
    jitter: 650,
    scrollDelay: 3000,
    batchSize: 10,
    extraBatchDelay: 14000,
    scrollAmount: 950,
    maxFailedScrolls: 8,
    rateLimitPause: 65000
  };

  let count = 0;
  let isRunning = true;
  let failedScrolls = 0;
  let startTime = Date.now();

  const wait = ms => new Promise(r => setTimeout(r, ms));

  const getUnlikeButtons = () => Array.from(document.querySelectorAll('[data-testid="unlike"]'));

  const detectRateLimit = () => {
    const alerts = document.querySelectorAll('[role="alert"], [data-testid*="toast"]');
    for (const el of alerts) {
      const txt = el.textContent.toLowerCase();
      return txt.includes("try again later") || txt.includes("rate limit") || 
             txt.includes("too many requests") || txt.includes("something went wrong");
    }
    return false;
  };

  const scrollDown = async () => {
    window.scrollBy({ left: 0, top: CONFIG.scrollAmount, behavior: "smooth" });
    await wait(CONFIG.scrollDelay);
  };

  const removeAllLikes = async () => {
    console.log('%c⏹️  Controls → stopUnlikes() | resumeUnlikes()', 'color: #f5a623;');

    while (isRunning && count < CONFIG.maxUnlikes) {
      const buttons = getUnlikeButtons();

      if (buttons.length === 0) {
        failedScrolls++;
        console.log(`📜 No likes visible. Scrolling... (${failedScrolls}/${CONFIG.maxFailedScrolls})`);

        if (failedScrolls >= CONFIG.maxFailedScrolls) {
          console.log('%c✅ No more likes found. Process finished!', 'color: #00c060; font-weight: bold;');
          break;
        }
        await scrollDown();
        continue;
      }

      failedScrolls = 0;

      for (const btn of buttons) {
        if (!isRunning || count >= CONFIG.maxUnlikes) break;

        if (detectRateLimit()) {
          console.log('%c⚠️ Rate limit detected! Pausing 65 seconds...', 'color: #ff9900; font-weight: bold;');
          await wait(CONFIG.rateLimitPause);
          continue;
        }

        try {
          btn.scrollIntoView({ behavior: "smooth", block: "center" });
          await wait(420);

          btn.click();
          count++;

          const elapsed = ((Date.now() - startTime) / 60000).toFixed(1);
          console.log(`💔 Unliked #${count}  |  Time: ${elapsed} min`);

          const randomDelay = CONFIG.baseDelay + (Math.random() * CONFIG.jitter - CONFIG.jitter / 2);
          await wait(randomDelay);

          if (count % CONFIG.batchSize === 0) {
            console.log(`⏳ Safety pause after ${CONFIG.batchSize} unlikes...`);
            await wait(CONFIG.extraBatchDelay);
          }
        } catch (err) {
          console.warn('⚡ Click error:', err.message);
        }
      }

      await scrollDown();
    }

    const totalMin = ((Date.now() - startTime) / 60000).toFixed(1);
    console.log('%c🏁 Process completed!', 'color: #1d9bf0; font-size: 16px; font-weight: bold;');
    console.log(`Total unliked: ${count} | Duration: ${totalMin} minutes`);
  };

  window.stopUnlikes = () => { isRunning = false; console.log('%c⏹️ PAUSED', 'color: #ff9900;'); };
  window.resumeUnlikes = () => { isRunning = true; removeAllLikes(); console.log('%c▶️ Resuming...', 'color: #00c060;'); };

  removeAllLikes();
})();

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