Skip to content

Instantly share code, notes, and snippets.

@SLaks
Created January 5, 2021 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SLaks/66542191f7a7bba8daf1085b58d23c03 to your computer and use it in GitHub Desktop.
Save SLaks/66542191f7a7bba8daf1085b58d23c03 to your computer and use it in GitHub Desktop.
Console Snippets to manipulate YouTube Music playlists in bulk
// 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