Created
June 11, 2011 22:37
-
-
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.
This file contains 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
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"]); | |
} | |
} | |
for(var i = 0; i < removal_list.length; i++) { | |
var song = removal_list[i]; | |
window.GS.player.removeSongs(song); | |
} |
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
Second version is slower, but works with Firefox 4. If you're using Chrome/Safari, 43550f is faster and does the same thing.