Created
September 14, 2019 05:09
-
-
Save daehee/760b3998022edebe386bfefbe9ab254b to your computer and use it in GitHub Desktop.
Unlike all your liked tweets
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
// Unlike all your liked tweets | |
// This is derived Twitter Unfollow script, by Jamie Mason (https://twitter.com/fold_left) | |
// https://gist.github.com/JamieMason/7580315 | |
// | |
// 1. Go to https://twitter.com/YOUR_USER_NAME/likes | |
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac) | |
// 3. Paste this into the Developer Console and run it | |
(() => { | |
const unlikeButtonQuery = '[data-testid="unlike"]'; | |
const confirmButtonQuery = '[data-testid="confirmationSheetConfirm"]'; | |
const sleep = ({ seconds }) => | |
new Promise(proceed => { | |
console.log(`WAITING FOR ${seconds} SECONDS...`); | |
setTimeout(proceed, seconds * 1000); | |
}); | |
const nextBatch = async () => { | |
window.scrollTo(0, document.body.scrollHeight); | |
await sleep({ seconds: 1 }); | |
const unlikeButtons = Array.from(document.querySelectorAll(unlikeButtonQuery)); | |
const unlikeButtonCount = unlikeButtons.length; | |
if (unlikeButtonCount === 0) { | |
console.log(`NO MORE TO UNLIKE, I THINK WE'RE DONE`); | |
console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`); | |
return; | |
} | |
console.log(`UNLIKING ${unlikeButtonCount} TWEETS...`); | |
await Promise.all( | |
unlikeButtons.map(async unlikeButton => { | |
unlikeButton.click(); | |
await sleep({ seconds: 1 }); | |
}) | |
); | |
await sleep({ seconds: 2 }); | |
nextBatch(); | |
}; | |
nextBatch(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment