Created
April 29, 2022 07:42
-
-
Save qoomon/13a012bb102b8746595ffb0b021acf00 to your computer and use it in GitHub Desktop.
Clean TikTok favourites
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
async function sleep (timeout) { | |
return new Promise(res => setTimeout(res, timeout)) | |
} | |
let videoElement = document.querySelector('div[data-e2e="user-liked-item"]').parentElement | |
while(videoElement) { | |
console.log(videoElement) | |
videoElement.scrollIntoView() | |
await sleep() | |
const videoLink = videoElement.querySelector('a[title]') || videoElement.querySelector('a') | |
console.log(videoLink.title); | |
videoLink.click() | |
await sleep() | |
const like = document.querySelector('[data-e2e="browse-like-icon"]') | |
if (like.querySelector('svg[fill="rgba(254, 44, 85, 1.0)"]')){ | |
console.log("└‣ unliked") | |
like.click() | |
await sleep() | |
} | |
document.querySelector('[data-e2e="browse-close"]').click() | |
await sleep() | |
videoElement = videoElement.nextElementSibling | |
} | |
console.log('Done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment