Skip to content

Instantly share code, notes, and snippets.

@ankurdhuriya
Created November 19, 2025 21:19
Show Gist options
  • Select an option

  • Save ankurdhuriya/06655cab55b040cfb2b22e77bd5cb0ee to your computer and use it in GitHub Desktop.

Select an option

Save ankurdhuriya/06655cab55b040cfb2b22e77bd5cb0ee to your computer and use it in GitHub Desktop.

Twitter Unlike Bot Script

This script automates the process of unliking tweets on Twitter using browser JavaScript console. It repeatedly finds and clicks the "unlike" button on tweets until no more are found, up to a maximum count.

Features

  • Dynamically scrolls to load more tweets if none are immediately available for unliking.
  • Uses adjustable wait times to balance speed and avoid Twitter's rate limits.
  • Logs progress to the console for monitoring.
  • Stops gracefully when no more unlikes are found or maximum count is reached.

Usage

  1. Open Twitter in your browser and go to your liked tweets page.
  2. Open Developer Tools → Console.
  3. Paste the script and press Enter to run.
  4. Monitor console logs to see progress.

Script Snippet

function nextUnlike() {
  return document.querySelector('[data-testid="unlike"]');
}

function wait(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function scrollToBottom() {
  window.scrollBy(0, window.innerHeight);
  await wait(1000);  // shorter wait after scroll to speed up
}

async function removeAll(maxCount = 500) {
  let count = 0;
  let next = nextUnlike();
  while (count < maxCount) {
    if (!next) {
      await scrollToBottom();
      next = nextUnlike();
      if (!next) {
        console.log('No more unlikes found after scrolling.');
        break;
      }
    }
    next.focus();
    next.click();
    console.log(`Unliked ${++count} tweets`);
    // Faster wait times: 500ms normally, 5s every 50 unlikes.
    await wait(count % 50 === 0 ? 5000 : 500);
    next = nextUnlike();
  }
  console.log('Finished unliking, total count =', count);
}

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