Forked from qoomon/youtube_clean_watch_later_videos.js
Created
April 17, 2021 22:54
-
-
Save iasinDev/3c0354afcd417e45793cea53b7033008 to your computer and use it in GitHub Desktop.
Revisions
-
qoomon revised this gist
Apr 16, 2021 . 1 changed file with 10 additions and 9 deletions.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 @@ -7,7 +7,7 @@ // adjust REMOVE_BUTTON_TEXT to your language (default is english) (async function() { const REMOVE_BUTTON_TEXT = "Remove from Watch later" const sleep = (timeout) => new Promise(res => setTimeout(res, timeout)) const untilDefined = async (factory, timeout = 100) => { @@ -21,23 +21,24 @@ console.info("start...") while(true) { let videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if(videos.length == 0) break for (let videoElement of videos) { let videoTitle = videoElement.querySelector('a#video-title') console.info("remove: " + videoTitle.innerText) console.info(" " + videoTitle.href) let actionMenu = videoElement.querySelector('#menu') let actionMenuButton = actionMenu.querySelector('#button') console.debug("click actionMenuButton", actionMenuButton) actionMenuButton.click() let removeButton = await untilDefined(() => document.evaluate( `//ytd-popup-container/tp-yt-iron-dropdown//tp-yt-paper-item[contains(., "${REMOVE_BUTTON_TEXT}")]`, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue); console.debug("click removeButton", removeButton) removeButton.click() await sleep(200) } } -
qoomon revised this gist
Apr 16, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -33,7 +33,7 @@ console.debug("click actionMenuButton") actionMenuButton.click(); let removeButton = await untilDefined(() => document.evaluate('//span[contains(text(), "' + REMOVE_BUTTON_TEXT + '")]', actionMenu, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue); console.debug("click removeButton") -
qoomon revised this gist
Apr 16, 2021 . 1 changed file with 1 addition and 1 deletion.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 @@ -33,7 +33,7 @@ console.debug("click actionMenuButton") actionMenuButton.click(); let removeButton = await untilDefined(() => document.evaluate('//span[contains(text(), ' + REMOVE_BUTTON_TEXT + ')]', actionMenu, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue); console.debug("click removeButton") -
qoomon revised this gist
Apr 16, 2021 . 1 changed file with 4 additions and 1 deletion.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 @@ -4,8 +4,11 @@ // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script // adjust REMOVE_BUTTON_TEXT to your language (default is english) (async function() { const REMOVE_BUTTON_TEXT = "Remove from" const sleep = (timeout) => new Promise(res => setTimeout(res, timeout)) const untilDefined = async (factory, timeout = 100) => { while (true) { @@ -30,7 +33,7 @@ console.debug("click actionMenuButton") actionMenuButton.click(); let removeButton = await untilDefined(() => document.evaluate('//span[contains(text(), REMOVE_BUTTON_TEXT)]', actionMenu, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue); console.debug("click removeButton") -
qoomon created this gist
Feb 21, 2021 .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,42 @@ // This script will remove all videos from watch later list // // Usage // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script (async function() { const sleep = (timeout) => new Promise(res => setTimeout(res, timeout)) const untilDefined = async (factory, timeout = 100) => { while (true) { let value = factory() if (value != null) return value await sleep(timeout) } } console.info("start...") while(true) { let videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if(videos.length == 0) break; for (let videoElement of videos) { let videoTitle = videoElement.querySelector('a#video-title') console.info("remove: " + videoTitle.innerText) console.info(" " + videoTitle.href) let actionMenu = videoElement.querySelector('#menu') let actionMenuButton = actionMenu.querySelector('#button'); console.debug("click actionMenuButton") actionMenuButton.click(); let removeButton = await untilDefined(() => document.evaluate('//span[contains(text(),"Remove from")]', actionMenu, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue); console.debug("click removeButton") removeButton.click(); await sleep(200) } } console.info("done!") })();