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.
- 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.
- Open Twitter in your browser and go to your liked tweets page.
- Open Developer Tools → Console.
- Paste the script and press Enter to run.
- Monitor console logs to see progress.
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();