44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
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);
|