Forked from qoomon/youtube_clean_watch_later_videos.js
Last active
March 11, 2023 19:41
-
-
Save udovichenko/295357dc6b504e4ce3dd540ad6c368a4 to your computer and use it in GitHub Desktop.
Revisions
-
udovichenko revised this gist
Feb 10, 2023 . 1 changed file with 55 additions and 55 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 @@ -1,67 +1,67 @@ (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later' // de-DE: const REMOVE_BUTTON_TEXT = 'Aus "Später ansehen" entfernen' // pt-BR: const REMOVE_BUTTON_TEXT = 'Remover de Assistir mais tarde' // swe-SE: const REMOVE_BUTTON_TEXT = 'Ta bort från Titta senare' // zh-Hans-CN: const REMOVE_BUTTON_TEXT = '从稍后观看中移除' // ru-RU: const REMOVE_BUTTON_TEXT = 'Удалить из плейлиста "Смотреть позже"' const playlistName = document.querySelector('#title a').text const limit = +prompt(`How many videos do you want to remove from ${playlistName}?`) if (!limit) return console.info('start...') let count = 0 while (true) { const videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if (videos.length == 0) break for (const videoElement of videos) { const videoTitle = videoElement.querySelector('a#video-title') console.info(`Remove Video\n` + ` Title: ${videoTitle.innerText}\n` + ` URL: ${videoTitle.href}`) const actionMenuButton = videoElement.querySelector('#menu #button') console.debug('click actionMenuButton', actionMenuButton) actionMenuButton.click() const removeButton = await untilDefined(() => { for (const actionMenu of [...document.querySelectorAll('ytd-popup-container > tp-yt-iron-dropdown')]) { if ((actionMenu) => actionMenu.style.display !== 'none') { for (const actionButton of [...actionMenu.querySelectorAll('tp-yt-paper-item')]) { if (actionButton.innerText.trim().toLowerCase() === REMOVE_BUTTON_TEXT.toLowerCase()) { return actionButton } } } } console.debug('wait for removeButton') }) console.debug('click removeButton', removeButton) removeButton.click() count++ if (count >= limit) break const randDelay = 1000 + Math.random() * 400 await sleep(randDelay) } if (count >= limit) break } console.info('done!') // === util functions ======================================================== async function sleep(timeout) { return new Promise((res) => setTimeout(res, timeout)) } async function untilDefined(factory, checkInterval = 100) { while (true) { const value = factory() if (value != null) return value await sleep(checkInterval) } } })() -
udovichenko revised this gist
Feb 10, 2023 . 1 changed file with 60 additions and 64 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 @@ -1,71 +1,67 @@ (async function () { const REMOVE_BUTTON_TEXT = 'Remove from Watch later' // de-DE: const REMOVE_BUTTON_TEXT = 'Aus "Später ansehen" entfernen' // pt-BR: const REMOVE_BUTTON_TEXT = 'Remover de Assistir mais tarde' // swe-SE: const REMOVE_BUTTON_TEXT = 'Ta bort från Titta senare' // zh-Hans-CN: const REMOVE_BUTTON_TEXT = '从稍后观看中移除' // ru-RU: const REMOVE_BUTTON_TEXT = 'Удалить из плейлиста "Смотреть позже"' const playlistName = document.querySelector('#title a').text const limit = +prompt(`How many videos do you want to remove from ${playlistName}?`) if (!limit) return console.info('start...') let count = 0 while (true) { const videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if (videos.length == 0) break for (let videoElement of videos) { const videoTitle = videoElement.querySelector('a#video-title') console.info(`Remove Video\n` + ` Title: ${videoTitle.innerText}\n` + ` URL: ${videoTitle.href}`) const actionMenuButton = videoElement.querySelector('#menu #button') console.debug('click actionMenuButton', actionMenuButton) actionMenuButton.click() const removeButton = await untilDefined(() => { for (const actionMenu of [...document.querySelectorAll('ytd-popup-container > tp-yt-iron-dropdown')]) { if ((actionMenu) => actionMenu.style.display !== 'none') { for (const actionButton of [...actionMenu.querySelectorAll('tp-yt-paper-item')]) { if (actionButton.innerText.trim().toLowerCase() === REMOVE_BUTTON_TEXT.toLowerCase()) { return actionButton } } } } console.debug('wait for removeButton') }) console.debug('click removeButton', removeButton) removeButton.click() count++ if (count >= limit) break const randDelay = 1000 + Math.random() * 400 await sleep(randDelay) } if (count >= limit) break } console.info('done!') // === util functions ======================================================== async function sleep(timeout) { return new Promise((res) => setTimeout(res, timeout)) } async function untilDefined(factory, checkInterval = 100) { while (true) { const value = factory() if (value != null) return value await sleep(checkInterval) } } })() -
udovichenko revised this gist
Feb 10, 2023 . 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 @@ -48,7 +48,7 @@ count++ if (count >= limit) break const randDelay = 1000 + Math.random() * 400 await sleep(randDelay) } if (count >= limit) break -
udovichenko revised this gist
Feb 10, 2023 . 1 changed file with 14 additions and 14 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 @@ -1,10 +1,3 @@ (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later' @@ -15,16 +8,19 @@ const playlistName = document.querySelector("#title a").text let limit = +prompt(`How many videos do you want to remove from ${playlistName}?`); if (!limit) return; console.info("start...") let count = 0; while (true) { const videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if (videos.length == 0) break for (let videoElement of videos) { const videoTitle = videoElement.querySelector('a#video-title') console.info(`Remove Video\n` + ` Title: ${videoTitle.innerText}\n` @@ -48,12 +44,16 @@ }) console.debug("click removeButton", removeButton) removeButton.click() count++ if (count >= limit) break const randDelay = 200 + Math.random() * 500 await sleep(randDelay) } if (count >= limit) break } console.info("done!") // === util functions ======================================================== @@ -68,4 +68,4 @@ await sleep(checkInterval) } } })() -
udovichenko revised this gist
Feb 10, 2023 . 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 @@ -15,7 +15,7 @@ const playlistName = document.querySelector("#title a").text const limit = prompt(`How many videos do you want to remove from ${playlistName}?`); if (!limit) return; console.info("start...") -
udovichenko revised this gist
Feb 10, 2023 . 1 changed file with 6 additions and 5 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 @@ -15,11 +15,11 @@ const playlistName = document.querySelector("#title a").text const limit = prompt(`How many videos do you want to remove from ${playlistName}?`)); if (!limit) return; console.info("start...") let count while(true) { const videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if(videos.length == 0) break @@ -49,10 +49,11 @@ console.debug("click removeButton", removeButton) removeButton.click() const randDelay = 200 + Math.random() * 500; await sleep(randDelay) } } console.info("done!"); // === util functions ======================================================== -
qoomon revised this gist
Mar 31, 2022 . 1 changed file with 5 additions and 4 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,10 +7,11 @@ // adjust REMOVE_BUTTON_TEXT accordingly to your language, see examples below (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later' // de-DE: const REMOVE_BUTTON_TEXT = 'Aus "Später ansehen" entfernen' // pt-BR: const REMOVE_BUTTON_TEXT = 'Remover de Assistir mais tarde' // swe-SE: const REMOVE_BUTTON_TEXT = 'Ta bort från Titta senare' // zh-Hans-CN: const REMOVE_BUTTON_TEXT = '从稍后观看中移除' const playlistName = document.querySelector("#title a").text -
qoomon revised this gist
Mar 31, 2022 . 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 @@ -7,7 +7,7 @@ // adjust REMOVE_BUTTON_TEXT accordingly to your language, see examples below (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later' // en // de-DE: 'Aus "Später ansehen" entfernen' // pt-BR: 'Remover de Assistir mais tarde' // zh-Hans-CN: '从稍后观看中移除' -
qoomon revised this gist
Mar 14, 2022 . 1 changed file with 1 addition and 0 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 @@ -43,6 +43,7 @@ } } } console.debug("wait for removeButton") }) console.debug("click removeButton", removeButton) removeButton.click() -
qoomon revised this gist
Mar 14, 2022 . 1 changed file with 2 additions and 2 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 @@ -58,11 +58,11 @@ return new Promise(res => setTimeout(res, timeout)) } async function untilDefined(factory, checkInterval = 100) { while (true) { const value = factory() if (value != null) return value await sleep(checkInterval) } } })(); -
qoomon revised this gist
Mar 14, 2022 . 1 changed file with 3 additions and 3 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 @@ -34,9 +34,9 @@ actionMenuButton.click() const removeButton= await untilDefined(() => { for (const actionMenu of [...document.querySelectorAll('ytd-popup-container > tp-yt-iron-dropdown')]) { if(actionMenu => actionMenu.style.display !== "none") { for (const actionButton of [...actionMenu.querySelectorAll('tp-yt-paper-item')]) { if(actionButton.innerText.trim().toLowerCase() === REMOVE_BUTTON_TEXT.toLowerCase()){ return actionButton } -
qoomon revised this gist
Mar 14, 2022 . 1 changed file with 10 additions and 7 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 @@ -33,14 +33,17 @@ console.debug("click actionMenuButton", actionMenuButton) actionMenuButton.click() const removeButton= await untilDefined(() => { for (const dropdown of [...document.querySelectorAll('ytd-popup-container > tp-yt-iron-dropdown')]) { if(dropdown => dropdown.style.display !== "none") { for (const actionButton of [...dropdown.querySelectorAll('tp-yt-paper-item')]) { if(actionButton.innerText.trim().toLowerCase() === REMOVE_BUTTON_TEXT.toLowerCase()){ return actionButton } } } } }) console.debug("click removeButton", removeButton) removeButton.click() @@ -62,4 +65,4 @@ await sleep(timeout) } } })(); -
qoomon revised this gist
Mar 3, 2022 . 1 changed file with 9 additions and 5 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 @@ -6,14 +6,17 @@ // #2 run following script in your browser console // adjust REMOVE_BUTTON_TEXT accordingly to your language, see examples below (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later'// en // de-DE: 'Aus "Später ansehen" entfernen' // pt-BR: 'Remover de Assistir mais tarde' // zh-Hans-CN: '从稍后观看中移除' const playlistName = document.querySelector("#title a").text if(!confirm(`Are you sure to delete ALL videos from ${playlistName}?`)) { return } console.info("start...") while(true) { @@ -22,8 +25,9 @@ for (let videoElement of videos) { const videoTitle = videoElement.querySelector('a#video-title') console.info(`Remove Video\n` + ` Title: ${videoTitle.innerText}\n` + ` URL: ${videoTitle.href}`) const actionMenuButton = videoElement.querySelector('#menu #button') console.debug("click actionMenuButton", actionMenuButton) -
qoomon revised this gist
Mar 3, 2022 . 1 changed file with 1 addition and 4 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 @@ -13,10 +13,7 @@ // zh-Hans-CN: '从稍后观看中移除' const playlistName = document.querySelector("#title a").text if(!confirm(`Are you sure to delete ALL videos from ${playlistName}?`)) return console.info("start...") while(true) { -
qoomon revised this gist
Mar 3, 2022 . 1 changed file with 2 additions and 2 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 @@ -6,8 +6,8 @@ // #2 run following script in your browser console // adjust REMOVE_BUTTON_TEXT accordingly to your language, see examples below (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later' // en: 'Remove from Watch later' // de-DE: 'Aus "Später ansehen" entfernen' // pt-BR: 'Remover de Assistir mais tarde' // zh-Hans-CN: '从稍后观看中移除' -
qoomon revised this gist
Mar 3, 2022 . 1 changed file with 38 additions and 28 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 @@ -3,52 +3,62 @@ // Usage // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script in your browser console // adjust REMOVE_BUTTON_TEXT accordingly to your language, see examples below (async function() { const REMOVE_BUTTON_TEXT = 'Remove from Watch later'// en // de-DE: 'Aus "Später ansehen" entfernen' // pt-BR: 'Remover de Assistir mais tarde' // zh-Hans-CN: '从稍后观看中移除' const playlistName = document.querySelector("#title a").text if(!confirm(`Are you sure to delete ALL videos from ${playlistName}?`)) { return } console.info("start...") while(true) { const videos = document.querySelectorAll('#primary ytd-playlist-video-renderer') if(videos.length == 0) break for (let videoElement of videos) { const videoTitle = videoElement.querySelector('a#video-title') console.info("remove: " + videoTitle.innerText) console.info(" " + videoTitle.href) const actionMenuButton = videoElement.querySelector('#menu #button') console.debug("click actionMenuButton", actionMenuButton) actionMenuButton.click() const actionMenuPopup = await untilDefined(() => { const container = document.querySelector('ytd-popup-container > tp-yt-iron-dropdown') if (container && container.style.display !== "none") { return container } }) const removeButton = [...actionMenuPopup.querySelectorAll('tp-yt-paper-item')] .find(el => el.innerText.trim().toLowerCase() === REMOVE_BUTTON_TEXT.toLowerCase()) console.debug("click removeButton", removeButton) removeButton.click() await sleep(200) } } console.info("done!") // === util functions ======================================================== async function sleep (timeout) { return new Promise(res => setTimeout(res, timeout)) } async function untilDefined(factory, timeout = 100) { while (true) { const value = factory() if (value != null) return value await sleep(timeout) } } })(); -
qoomon revised this gist
Mar 3, 2022 . 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 @@ -8,7 +8,7 @@ // get you location code by executing document.documentElement.lang (async function() { const REMOVE_BUTTON_TEXT_MAP = { 'en': 'Remove from Watch later', 'en-GB': 'Remove from Watch Later', 'de-DE': 'Aus "Später ansehen" entfernen', 'pt-BR': 'Remover de Assistir mais tarde', -
qoomon revised this gist
Feb 28, 2022 . 1 changed file with 2 additions and 2 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 @@ -8,8 +8,8 @@ // get you location code by executing document.documentElement.lang (async function() { const REMOVE_BUTTON_TEXT_MAP = { 'en': 'Remove from Watch Later', 'en-GB': 'Remove from Watch Later', 'de-DE': 'Aus "Später ansehen" entfernen', 'pt-BR': 'Remover de Assistir mais tarde', 'zh-Hans-CN': '从稍后观看中移除', -
qoomon revised this gist
Feb 8, 2022 . 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 @@ -4,7 +4,7 @@ // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script // adjust REMOVE_BUTTON_TEXT_MAP, if your language code is missing // get you location code by executing document.documentElement.lang (async function() { const REMOVE_BUTTON_TEXT_MAP = { -
qoomon revised this gist
Feb 8, 2022 . 1 changed file with 2 additions and 2 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 @@ -4,8 +4,8 @@ // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script // adjust REMOVE_BUTTON_TEXT_MAP, if your language is missing // get you location code by executing document.documentElement.lang (async function() { const REMOVE_BUTTON_TEXT_MAP = { 'en': 'Remove from Watch later', -
qoomon revised this gist
Sep 23, 2021 . 1 changed file with 1 addition and 0 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 @@ -12,6 +12,7 @@ 'en-GB': 'Remove from Watch later', 'de-DE': 'Aus "Später ansehen" entfernen', 'pt-BR': 'Remover de Assistir mais tarde', 'zh-Hans-CN': '从稍后观看中移除', } const sleep = (timeout) => new Promise(res => setTimeout(res, timeout)) -
qoomon revised this gist
Jun 17, 2021 . 1 changed file with 1 addition and 0 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 @@ -11,6 +11,7 @@ 'en': 'Remove from Watch later', 'en-GB': 'Remove from Watch later', 'de-DE': 'Aus "Später ansehen" entfernen', 'pt-BR': 'Remover de Assistir mais tarde', } const sleep = (timeout) => new Promise(res => setTimeout(res, timeout)) -
qoomon revised this gist
Jun 5, 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 @@ -5,7 +5,7 @@ // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script // adjust REMOVE_BUTTON_TEXT_MAP if your language is missing //. get you location code by executing document.documentElement.lang (async function() { const REMOVE_BUTTON_TEXT_MAP = { 'en': 'Remove from Watch later', -
qoomon revised this gist
Apr 21, 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 @@ -4,7 +4,7 @@ // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script // adjust REMOVE_BUTTON_TEXT_MAP if your language is missing (async function() { const REMOVE_BUTTON_TEXT_MAP = { -
qoomon revised this gist
Apr 21, 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 @@ -4,7 +4,7 @@ // // #1 go to https://www.youtube.com/playlist?list=WL // #2 run following script // adjust REMOVE_BUTTON_TEXT_MAP if your langanguage is missing (async function() { const REMOVE_BUTTON_TEXT_MAP = { -
qoomon revised this gist
Apr 21, 2021 . 1 changed file with 8 additions and 2 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,11 @@ // adjust REMOVE_BUTTON_TEXT to your language (default is english) (async function() { const REMOVE_BUTTON_TEXT_MAP = { 'en': 'Remove from Watch later', 'en-GB': 'Remove from Watch later', 'de-DE': 'Aus "Später ansehen" entfernen', } const sleep = (timeout) => new Promise(res => setTimeout(res, timeout)) const untilDefined = async (factory, timeout = 100) => { @@ -33,8 +37,10 @@ console.debug("click actionMenuButton", actionMenuButton) actionMenuButton.click() let languageCode = document.documentElement.lang let removeButtonText = REMOVE_BUTTON_TEXT_MAP[languageCode] || REMOVE_BUTTON_TEXT_MAP[languageCode.split('-')[0]] let removeButton = await untilDefined(() => document.evaluate( `//ytd-popup-container/tp-yt-iron-dropdown//tp-yt-paper-item[contains(., "${removeButtonText}")]`, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue); console.debug("click removeButton", removeButton) -
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")
NewerOlder