-
-
Save rochacbruno/dbedf63aa4d4d2909323facd9a0dc334 to your computer and use it in GitHub Desktop.
Revisions
-
rochacbruno created this gist
Feb 9, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ # Delete whatch later videos from youtube - OPen youtube, change language to English - Go to your watch later playlist - OPen the inspect -> console - Paste the script and execute it This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ function deleteVideoFromWatchLater() { video = document.getElementsByTagName('ytd-playlist-video-renderer')[0]; video.querySelector('#primary button[aria-label="Action menu"]').click(); var things = document.evaluate( '//span[contains(text(),"Remove from")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); for (var i = 0; i < things.snapshotLength; i++) { things.snapshotItem(i).click(); } } async function deleteWatchLater() { let batchSize = 200; let waitBetweenBatchesInMilliseconds = 1000 * 60 * 5 let waitBetweenDeletionsInMilliseconds = 500; let totalWaitTime = ((5000 / batchSize) * (waitBetweenBatchesInMilliseconds / 1000 / 60)) + (5000 * (waitBetweenDeletionsInMilliseconds / 1000 / 60)) console.log(`Deletion will take around ${totalWaitTime.toFixed(0)} minutes to run if the playlist is full.`); let count = 0; while (true) { await new Promise(resolve => setTimeout(resolve, waitBetweenDeletionsInMilliseconds)); deleteVideoFromWatchLater(); count++; if (count % batchSize === 0 && count !== 0) { console.log('Waiting for 5 minutes...'); await new Promise(resolve => setTimeout(waitBetweenBatchesInMilliseconds)); } } } deleteWatchLater();