Created
August 12, 2010 21:05
-
-
Save BenWard/521725 to your computer and use it in GitHub Desktop.
A quick quick quick bookmarklet to redirect from an Rdio.com artist or album page to the equivalent page on MOG.
This file contains hidden or 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
javascript:MOGRdioExt%20=%20{redirect:%20function()%20{var%20artist%20=%20%22%22;var%20album%20=%20%22%22;var%20parts%20=%20window.location.href.split(%27/%27);for(var%20i=0;%20i%20<%20parts.length;%20i++)%20{p=parts[i];switch(p)%20{case%20%27artist%27:i%20=%20i+1;artist%20=%20parts[i];break;case%20%27album%27:i%20=%20i+1;album%20=%20parts[i];break;default:break;}}if(%22%22%20===%20artist)%20{alert(%22This%20only%20works%20if%20you%27re%20viewing%20an%20Rdio%20artist%20or%20album.%22);}else%20{window.location.href%20=%20%22http://mog.com/music/%22+artist+%22/%22+album;}}};MOGRdioExt.redirect(); |
This file contains hidden or 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
MOGRdioExt = { | |
redirect: function() { | |
var artist = ""; | |
var album = ""; | |
var parts = window.location.href.split('/'); | |
for(var i=0; i < parts.length; i++) { | |
p=parts[i]; | |
switch(p) { | |
case 'artist': | |
i = i+1; | |
artist = parts[i]; | |
break; | |
case 'album': | |
i = i+1; | |
album = parts[i]; | |
break; | |
default: | |
break; | |
} | |
} | |
if("" === artist) { | |
alert("This only works if you're viewing an Rdio artist or album."); | |
} | |
else { | |
window.location.href = "http://mog.com/music/"+artist+"/"+album; | |
} | |
} | |
}; | |
MOGRdioExt.redirect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now superseded by MOGthis, which redirects from both Rdio and Spotify URLs, and supports Rdio track URLs. https://gist.github.com/714812