Skip to content

Instantly share code, notes, and snippets.

@mrhammadasif
Created March 29, 2024 12:08
Show Gist options
  • Save mrhammadasif/1bd91b4060a319b1b802935a4869e949 to your computer and use it in GitHub Desktop.
Save mrhammadasif/1bd91b4060a319b1b802935a4869e949 to your computer and use it in GitHub Desktop.
Remove all Songs from Playlist
var song = document.body.querySelectorAll( ".dropdown-trigger.ytmusic-menu-renderer" )
for ( var i = 0; i < song.length; i++ ) {
song[i].click(); var dropdown = document.body.querySelector( "ytmusic-menu-popup-renderer[slot='dropdown-content']" )
if ( dropdown != undefined ) {
var items = dropdown.querySelector( "tp-yt-paper-listbox#items" ).querySelectorAll( "ytmusic-menu-service-item-renderer" )
if ( items != null ) {
items.forEach( async ( element ) => {
if ( element.querySelector( 'yt-formatted-string' ).innerHTML == 'Remove from playlist' ) {
// element.style.backgroundColor = 'red';
element.click()
await new Promise( r => setTimeout( r, 1000 ) )
console.log( "removed from library" )
}
} )
}
}
await new Promise( r => setTimeout( r, 1000 ) )
}
@mrhammadasif
Copy link
Author

  1. Open Youtube Music
  2. Open any Playlist (from which you want to remove all the songs)
  3. Then Copy this script and paste in your console, It will remove all songs gradually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment