Skip to content

Instantly share code, notes, and snippets.

@farzany
Last active May 7, 2025 05:30
Show Gist options
  • Select an option

  • Save farzany/7b36a1f3e719091a79ba508974c9be27 to your computer and use it in GitHub Desktop.

Select an option

Save farzany/7b36a1f3e719091a79ba508974c9be27 to your computer and use it in GitHub Desktop.
Twitter (𝕏) Script: Unlike all liked Tweets
async function wait(count) {
const timeout = count % 50 === 0 ? 30000 : Math.random() * 1000 + 2000;
await new Promise(resolve => setTimeout(resolve, timeout));
}
async function unlikeAllTweets({ limit, deleteTweets=false }) {
let count = 0;
while (count < limit) {
const unlikeButton = document.querySelector('[data-testid="unlike"]');
if (!unlikeButton) break;
if (!deleteTweets) {
unlikeButton.focus();
}
unlikeButton.click();
const tweet = unlikeButton.closest('[data-testid="tweet"]');
const author = tweet?.querySelector('[data-testid="User-Name"]')?.textContent?.split('@')[0] || 'User';
console.log(`Unliked Tweet #${++count} by ${author}`);
await wait(count);
if (deleteTweets) {
tweet.closest('[data-testid="cellInnerDiv"]').remove();
}
}
console.log(`Done! Unliked ${count} tweets.`);
}
unlikeAllTweets({ limit: 50, deleteTweets: true });
@abdelkabirouadoukou
Copy link

thx

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