Skip to content

Instantly share code, notes, and snippets.

@omgmog
Created April 2, 2013 15:18
Show Gist options
  • Save omgmog/5293029 to your computer and use it in GitHub Desktop.
Save omgmog/5293029 to your computer and use it in GitHub Desktop.
A userscript that turns `spotify:album:` links into `http://youfm.org` links
// ==UserScript==
// @name Spotify album links to youfm.org links
// @namespace http://omgmog.net
// @description Turns spotify:album: links into youfm.org links
// @include *
// @version 1.0
// ==/UserScript==
function get_anchors(){
var anchors = new Array();
var elms = document.getElementsByTagName('a');
for(var i=0; i<elms.length; i++){
if(elms[i].href) anchors.push(elms[i]);
}
return anchors;
}
var allLinks, thisLink;
allLinks = get_anchors();
for (var i = 0; i < allLinks.length; i++) {
thisLink = allLinks[i];
if (thisLink.href.match('^spotify:album:')) {
thisLink.href = 'http://www.youfm.org/#/album/'+thisLink.href;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment