Last active
September 3, 2023 07:33
-
-
Save dustywusty/645d89f926b9cb47af8ed3dd839cccec to your computer and use it in GitHub Desktop.
twitter unlike unlike-all script browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for your browser's javascript console on the <https://twitter.com/user/likes> page | |
let totalUnlikedCount = 0; | |
const clickUnlikeButtons = () => { | |
const unlikeButtons = Array.from(document.querySelectorAll('div[data-testid="unlike"]')); | |
let count = 0; | |
unlikeButtons.forEach((button) => { | |
const ariaLabel = button.getAttribute('aria-label'); | |
const likesMatch = ariaLabel && ariaLabel.match(/^\d+\sLikes?\.\sLiked$/); | |
if (likesMatch) { | |
button.click(); | |
count++; | |
} | |
}); | |
return count; | |
}; | |
const scrollToBottom = () => { | |
window.scrollTo(0, document.body.scrollHeight * 2); | |
}; | |
const main = async () => { | |
while (true) { | |
if (totalUnlikedCount >= 499) { | |
console.log('Reached rate limit of 499, stopping!'); | |
break; | |
} | |
const count = clickUnlikeButtons(); | |
console.log(`Unliked ${count} tweets this round!`); | |
totalUnlikedCount += count; | |
scrollToBottom(); | |
await new Promise(resolve => setTimeout(resolve, 10000)); | |
} | |
console.log(`Total unliked tweets: ${totalUnlikedCount}`); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment