Created
May 29, 2025 19:00
-
-
Save levhita/a6026ef5d9eaab0200be3d5611eb6a8f to your computer and use it in GitHub Desktop.
Delete Likes
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
// Open X, and navigate to your profile likes https://x.com/<username>/likes | |
// copy this into the console and run it. | |
function delay(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} | |
async function clickButtons() { | |
buttons = document.querySelectorAll("[data-testid=unlike]"); | |
for (var i = 0; i < buttons.length; i++) { | |
console.log("Clicking button " + i); | |
buttons[i].click(); | |
// 1 second looks like a good delay to avoid getting API rated | |
await delay(1000); | |
} | |
console.log("Scrolling to bottom of page"); | |
window.scrollTo(0, document.body.scrollHeight); | |
await delay(1000); | |
} | |
// Run while there are likes in the page | |
(async function main() { | |
while (document.querySelectorAll("[data-testid=unlike]").length > 0) { | |
console.log("Found " + document.querySelectorAll("[data-testid=unlike]").length + " buttons"); | |
await clickButtons(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment