Created
January 5, 2021 18:19
-
-
Save SLaks/66542191f7a7bba8daf1085b58d23c03 to your computer and use it in GitHub Desktop.
Console Snippets to manipulate YouTube Music playlists in bulk
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
// First, load jQuery: | |
var jq = document.createElement('script'); | |
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
//////////////////////////////////////////////////////////////////////////// | |
// Remove all disliked songs: | |
for (const el of $('ytmusic-responsive-list-item-renderer:has([like-status="DISLIKE"])').get()) { | |
el.dispatchEvent(new MouseEvent('contextmenu')); | |
await new Promise(r => setTimeout(r, 100)); | |
$('ytmusic-menu-service-item-renderer:contains("Remove from playlist")')[0].dispatchEvent(new MouseEvent('click')); | |
} | |
//////////////////////////////////////////////////////////////////////////// | |
// Remove all songs after $0: | |
const start = $0; | |
while(start.nextElementSibling) { | |
$0.nextElementSibling.dispatchEvent(new MouseEvent('contextmenu')); | |
await new Promise(r => setTimeout(r, 100)); | |
$('ytmusic-menu-service-item-renderer:contains("Remove from playlist")')[0].dispatchEvent(new MouseEvent('click')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment