Skip to content

Instantly share code, notes, and snippets.

@Om-Thorat
Created February 2, 2023 08:13
Show Gist options
  • Save Om-Thorat/a74bf83b52d669b19311325b35d7440c to your computer and use it in GitHub Desktop.
Save Om-Thorat/a74bf83b52d669b19311325b35d7440c to your computer and use it in GitHub Desktop.
Clean the youtube Watch Later playlist by removing the videos you have watched!
var WList = document.querySelector("#contents").querySelector("#contents").querySelector("#contents").children
console.log(WList.length)
function sleep(ms) {return new Promise(resolve => setTimeout(resolve, ms));}
console.log("Starting...")
removed = [];
async function clean() {
for (let i = 0; i < WList.length; i++) {
const vid = WList[i];
var prog = vid.children[1].querySelector("#container #thumbnail #thumbnail #overlays #progress");
if (prog != null) {
if (Number(prog.style.width.slice(0, -1)) >= 90) {
console.log("watched");
removed.push(vid.children[1].querySelector("#container #thumbnail #thumbnail").href);
vid.children[2].querySelector("#button #button").click();
await sleep(500)
document.querySelector("ytd-popup-container #contentWrapper #items").children[2].click();
await sleep(500)
i = i - 1
}
}
}
console.log(removed)
console.log("done!")
}
clean()
@Om-Thorat
Copy link
Author

Get the Firefox Add-on Here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment