Last active
April 9, 2022 13:35
-
-
Save anton-roos/dc953481ce4d4dde6051ee833dd2cee5 to your computer and use it in GitHub Desktop.
Bulk unlike tweets with JavaScript
This file contains hidden or 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
function sleep(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} | |
async function unlikeTweets() { | |
let tweets = document.querySelectorAll('[data-testid="tweet"]'); | |
for (let tweet of tweets) { | |
let unlikeButton = tweet.querySelectorAll('[data-testid="unlike"]')[0]; | |
if (unlikeButton != null) { | |
unlikeButton.scrollIntoView(); | |
unlikeButton.click(); | |
console.log("Clicked unlike"); | |
await sleep(100); | |
} else { | |
console.log("Found no unlike button"); | |
await sleep(100); | |
} | |
} | |
unlikeTweets(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment