Created
November 25, 2010 02:10
-
-
Save BenWard/714796 to your computer and use it in GitHub Desktop.
Convert a Spotify URL into a MOG URL for music playback in North America.
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:(function()%20{function%20esc(s)%20{return%20s.replace(%27%20%27,%20%27-%27);}var%20track,%20artist,%20album,links%20=%20document.getElementsByTagName(%27a%27);for(var%20i=0;l=links[i];i++)%20{if(l.href.match(/^spotify:track:/))%20{track%20=%20l.innerText;}else%20if(l.href.match(/open.spotify.com\/artist/))%20{artist%20=%20l.title;}else%20if(l.href.match(/open.spotify.com\/album/))%20{album%20=%20l.title;}}window.location.href%20=%20%27http://mog.com/music/%27%20+%20esc(artist)%20+%20%27/%27%20+%20esc(album)%20+%20%27/%27%20+%20esc(track);return%20true;})(); |
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
(function() { | |
function esc(s) { | |
return s.replace(' ', '-'); | |
} | |
var track, artist, album, | |
links = document.getElementsByTagName('a'); | |
for(var i=0;l=links[i];i++) { | |
if(l.href.match(/^spotify:track:/)) { | |
track = l.innerText; | |
} | |
else if(l.href.match(/open.spotify.com\/artist/)) { | |
artist = l.title; | |
} | |
else if(l.href.match(/open.spotify.com\/album/)) { | |
album = l.title; | |
} | |
} | |
window.location.href = 'http://mog.com/music/' + esc(artist) + '/' + esc(album) + '/' + esc(track); | |
return true; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Superseded by MOGthis, a combined bookmarklet that redirects from Rdio and Spotify URLs to MOG. https://gist.github.com/714812