// Copyright (c) 2007, 2008 Jordon Kalilich (http://theworldofstuff.com/)
//
// This program is free software: you may redistribute and/or modify
// it under the terms of the GNU GPL version 3 or any later version.
// http://www.gnu.org/copyleft/gpl.html
//
// Original script: http://userscripts.org/scripts/show/30982
// ==UserScript==
// @name          Jamendo Direct Ogg Download (simplified)
// @namespace     http://nullprogram.com
// @version       0.1
// @description   Rewrites download links to direct-download Ogg Vorbis.
// @include       http://www.jamendo.com/*
// ==/UserScript==

var links = document.getElementsByTagName('a');
for (i = 0; i < links.length; i++) {
   if ( (links[i].href) && (/\/download\/album\/\d+$/i.test(links[i].href)) ) {
      var albumID = links[i].href.match(/\d+/);
      links[i].setAttribute('href', 'http://www.jamendo.com/get/album/id/' + 
			    'album/archiverestricted/redirect/' +
			    albumID + '/?are=ogg3');
      links[i].setAttribute('onclick', null);
   }
}