This was inspired by Chris Pederick's similar project which no longer works. Probably it no longer works because rdio changed some of their html/css/js. The project on this page will probably suffer a similar fate.
The way this works is that you enter in a playlist name below, and then drag the generated link to your bookmarks. When you're on an album page on Rdio.com, click the bookmark to add all the album's songs to the playlist. You'll get a js popup when it's done.
Use at your own risk - I assume no responsibility for your use of this tool, since rdio could modify their code at any time in such a way that this tool might break. Tested only in chrome.
(function(){
playlist="All";
//helper function
function s(x){
if (typeof x!="string")
return "";
return x;
}
//get all track buttons
var tracks = $.makeArray($(document).find('span').filter(function(i){
var clss = s($(this).attr('class'));
return clss.indexOf('menu_sus')!=-1 && clss.indexOf('album')==-1 && $(this).size()==1 && $(this).children().size()>0
}));
var timer=0;
function clickAddButton(f){
var addButton = $("button").filter(function(){return $(this).text().indexOf("Add")!=-1});
if (addButton.length==0)
setTimeout(function(){clickAddButton(f)},50);
else{
addButton.last().click();
addButton.remove();
f();
}
}
function onDoneLoading(f){
var x = $(document).find('*').filter(function(i){
return s($(this).attr('id'))=="loading_indicator" && $(this).css('display')!='none';
}).find(':visible');
if (x.length==0)
f();
else
setTimeout(function(){onDoneLoading(f)},50)
}
var length = tracks.length;
function addNextTrack(){
if (tracks.length==0){
alert("Added "+length+" songs to playlist");
return;
}
$(tracks.shift()).click();
//get add to playlist button
var addToPlaylist = $(document).find('*').filter(function(i){
var html = s($(this).html());
var clss = s($(this).attr('class'));
return html.indexOf('Add to Playlist...')!=-1 && clss.indexOf('sus_link')!=-1;
});
addToPlaylist.click();
onDoneLoading(function(){
var opt = $("option").filter(function(){return $(this).text() == playlist});
var val = $(opt).val();
$("#playlistSelection").val(val);
onDoneLoading(function(){
clickAddButton(function(){
$(addToPlaylist).remove();
onDoneLoading(addNextTrack);
})
})
});
}
addNextTrack();
})()