Add js script for cleaning Watch Later
This commit is contained in:
parent
637c319c30
commit
51c7b11809
43
clean-watch-later.js
Normal file
43
clean-watch-later.js
Normal file
@ -0,0 +1,43 @@
|
||||
setInterval(function() {
|
||||
// Click on the treedots of first video in the list
|
||||
document.querySelector('#contents button#button').click();
|
||||
|
||||
// Click on the "Save to playlist" button
|
||||
var save2playlist = document.evaluate('//yt-formatted-string[contains(text(),"Save to playlist")]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
|
||||
save2playlist.snapshotItem(0).click();
|
||||
|
||||
// search playlist with name wel
|
||||
var checkboxLabel = document.evaluate(
|
||||
'//tp-yt-paper-checkbox[@id="checkbox" and .//text()[contains(., "wel")]]',
|
||||
document,
|
||||
null,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
null
|
||||
).singleNodeValue;
|
||||
|
||||
if (checkboxLabel) {
|
||||
// Check if the descendant with id "checkmark" does not have the class "hidden"
|
||||
var checkmarkDescendant = checkboxLabel.querySelector('div#checkmark');
|
||||
|
||||
if (checkmarkDescendant && checkmarkDescendant.classList.contains('hidden')) {
|
||||
// Click on the checkboxLabel
|
||||
checkboxLabel.click();
|
||||
console.log('Added video to playlist.');
|
||||
}
|
||||
else {
|
||||
console.log('Video is already in the playlist.');
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for a second before the second click
|
||||
setTimeout(function() {
|
||||
document.querySelector('#contents button#button').click();
|
||||
}, 2000);
|
||||
|
||||
// Click on the "Remove from watch later" button
|
||||
var things = document.evaluate('//span[contains(text(),"Watch later")]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
|
||||
for (var i = 0; i < things.snapshotLength; i++) {
|
||||
things.snapshotItem(i).click();
|
||||
}
|
||||
|
||||
}, 2000);
|
||||
Loading…
Reference in New Issue
Block a user