Jon Stuebe

Rdio Add Multiple Songs to Playlist

Rdio Add Multiple Songs to Playlist

Posted by Jon Stuebe on .
Featured

Rdio Add Multiple Songs to Playlist

Posted by Jon Stuebe on .

I was bothered by not having the option to add multiple songs to a playlist so I wrote this little script. It's still a little buggy, but essentially before selecting any songs click on the bookmarklet and then select each song by clicking on any area inside of the song list that isn't already clickable. This should light up the song row and a new button "Add to Playlist" should appear. The rest is self explanatory. At some point I will turn this into a full fledge chrome extension with other features that I feel have been missing.

gist

javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.7",function($,L){var playlists = [];$("body > .Menu").remove();$(".TrackList .Track:first").find('.ActionMenu.pill').trigger('click');$("body > .Menu:first").find(".scroller.vertical").find(".embedded").find("li[title=" + name + "]").trigger('click');$(".menu_click_shield").trigger('click');$("body > .Menu .scroller.vertical .embedded li").each(function(){   playlists.push($(this).attr('title').trim());});$("body > .Menu").remove();var add_playlist_index = [];$(".horizontal .ActionMenu.toolbar").append('<button class="button add_to_playlist" style="display: none;">Add To Playlist</a>');$("button.add_to_playlist").on('click', function () {        var playlist_markup = '<div class="playlist_selection">';    $.each(playlists, function(index, value){        playlist_markup = playlist_markup + '<div class="info light_text"><a href="#">' + value + '</a></div>';    });    playlist_markup = playlist_markup + '</div>';    new_dialog('Playlists', playlist_markup);    return false;});function check_index() {    if (add_playlist_index.length == 0) {        $("button.add_to_playlist").fadeOut();    } else {        $("button.add_to_playlist").fadeIn();    }}$(".TrackList .Track").on('click', function () {    $(this).toggleClass('addToPlaylist');    var sel_index = $(".TrackList .Track").index($(this));    if ($(this).hasClass("addToPlaylist")) {        $(this).css('background-color', '#e1e6e9');        add_playlist_index.push(sel_index);        check_index();    } else {        $(this).css('background-color', '');        add_playlist_index.splice(add_playlist_index.indexOf(sel_index), 1);        check_index();    }});function addToPlaylist(name) {    $.each(add_playlist_index, function (index, value) {        $("body > .Menu").remove();        $(".TrackList .Track").eq(value).find('.ActionMenu.pill').trigger('click');        $("body > .Menu:first").find(".scroller.vertical").find(".embedded li:contains('" + name + "')").trigger('click');        $(".menu_click_shield").trigger('click');    });    var $active_els = $(".TrackList .Track.addToPlaylist");    $active_els.removeClass('addToPlaylist');    $active_els.css('background-color', '');    add_playlist_index = [];    check_index();    alert('Added to songs to playlist');}function new_dialog(title, content) {    $(".Dialog.ComponentDialog").remove();    var markup = '<div class="Dialog ComponentDialog" style=""><div class="content default_dialog" style="width: 600px; margin-top: 150px;"><div class="header clearfix" style=""><div class="title section_header">{{ title }}</div></div><div class="Scrollable desktop" style="width: 600px;"> <div class="top_shadow"></div><div class="bottom_shadow"></div> <div class="Scrollable_Scrollbar vertical" style="display: none;"><div class="puck"></div> </div><div class="scroller vertical" style="width: 600px;"><div class="body clearfix"> <div class="container clearfix" style=""><div class="InfiniteScroll SourceList"><div class="scrollable_content"><div class="Person clearfix is_offline list_info list_item ui-droppable"> {{ content }} </div></div><div class="Spinner loaded"></div></div></div></div></div></div><div class="footer clearfix" style=""><div class="Dialog_ButtonBar"><button data-cid="c1023" class="button">Close</button></div></div></div></div>';    $("body").append( markup.replace('{{ title }}', title).replace('{{ content }}', content) );    $(".Dialog.ComponentDialog button.button").on('click', function(){ $(".Dialog.ComponentDialog").remove(); });    $(".Dialog .playlist_selection a").on('click', function(){        addToPlaylist($(this).html());        $(".Dialog.ComponentDialog").remove();        return false;    });}});
user

Jon Stuebe