Skip to content

Instantly share code, notes, and snippets.

@openfirmware
Created June 11, 2011 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save openfirmware/1021044 to your computer and use it in GitHub Desktop.
Save openfirmware/1021044 to your computer and use it in GitHub Desktop.
Remove duplicate songs from Grooveshark queue. Keeps first instance of song. Compares using SongID, so will not catch different uploads for the same song. Tested with Google Chrome 12, Safari 5, and Firefox 4.
song_hash = {};
removal_list = [];
for(var i = 0; i < window.GS.player.queue.songs.length; i++) {
var song = window.GS.player.queue.songs[i];
if(song_hash[song["SongID"]] == undefined) {
song_hash[song["SongID"]] = 1;
} else {
removal_list.push(song["queueSongID"]);
}
}
window.GS.player.removeSongs(removal_list);
@openfirmware
Copy link
Author

Second version is slower, but works with Firefox 4. If you're using Chrome/Safari, 43550f is faster and does the same thing.

@theabraham
Copy link

GS.player.player.removeSongs(queueSongIDArray) will remove all songs in the array at once; doing it one at a time is a huge performance drain (I tested it with 500 songs, and it took about 8 seconds!)

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