Skip to content

Instantly share code, notes, and snippets.

@AsP3X
Last active December 14, 2021 14:21
Show Gist options
  • Save AsP3X/ef54e5c1a7f4c8d5eb83da314dd0eeaf to your computer and use it in GitHub Desktop.
Save AsP3X/ef54e5c1a7f4c8d5eb83da314dd0eeaf to your computer and use it in GitHub Desktop.
Removing all video inside of the youtubes watch later playlist.
var clearTimer;
function clearWatchList(interval) {clearTimer = setInterval(clearWatchLater, interval);}
function getButtonAttr() {
var elemArray = document.querySelectorAll("#button");
return elemArray[37].getAttribute("aria-label");
}
function getPlaylistName() {
var playlistElem = document.getElementById("text-displayed");
return playlistElem.innerHTML;
}
function clearWatchLater(buttonName, fieldName) {
var selectorLabel = getButtonAttr();
var playlistName = getPlaylistName();
document.querySelector(`#primary button[aria-label="${selectorLabel}"]`).click();
var things = document.evaluate(`//span[contains(text(),"${playlistName}")]`,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
if (things.snapshotLength = 0) {killSwitch()}
for (var i = 0; i < things.snapshotLength; i++) {
things.snapshotItem(i).click();
}
}
function killSwitch() {
clearInterval(clearTimer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment