Created
February 11, 2020 22:13
-
-
Save RafahCSilva/e04185b121e064b3bb92b7e5c1e11713 to your computer and use it in GitHub Desktop.
Remove all items from Youtube Playlist "Watch Later" <https://www.youtube.com/playlist?list=WL&disable_polymer=1>
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 characters
| // REMOVE ALL ITEMS FROM YOUTUBE PLAYLIST "WATCH LATER" | |
| // Go to playlist without Polymer | |
| // https://www.youtube.com/playlist?list=WL&disable_polymer=1 | |
| window.open('https://www.youtube.com/playlist?list=WL&disable_polymer=1', '_self'); | |
| // Removing all items | |
| !function (loadMoreClass, removeBtnClass, getTitle, i) { | |
| // Load all items | |
| i('Loading all items...'); | |
| const intervalLoadMore = setInterval(() => { | |
| let btn = document.getElementsByClassName(loadMoreClass)[0]; | |
| if (btn) { | |
| i('More...'); | |
| btn.click(); | |
| } else { | |
| i('No More to Load!'); | |
| clearInterval(intervalLoadMore); | |
| // Remove each item | |
| i('Removing Items...'); | |
| Array | |
| .from(document.getElementsByClassName(removeBtnClass)) | |
| .forEach((el, idx) => { | |
| setTimeout(() => { | |
| i(`${idx}) Removing: ${getTitle(el)}`); | |
| el.click(); | |
| }, idx * 500 /* clicking "sequentially" for YouTube to update the list */); | |
| }); | |
| } | |
| }, 2000); | |
| }( | |
| /* loadMoreClass: */ 'yt-uix-button yt-uix-button-size-default yt-uix-button-default load-more-button yt-uix-load-more browse-items-load-more-button', | |
| /* removeBtnClass: */ 'yt-uix-button yt-uix-button-size-default yt-uix-button-default yt-uix-button-empty yt-uix-button-has-icon no-icon-markup pl-video-edit-remove yt-uix-tooltip', | |
| /* getTitle: */ e => e.parentElement.parentElement.parentElement.parentElement.getElementsByClassName('pl-video-title-link yt-uix-tile-link yt-uix-sessionlink spf-link ')[0].textContent.trim(), | |
| /* i: */ console.info | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment