// ==UserScript==
// @name          Inline Google Player
// @description	  Embed Google's Flash Player inline next to every MP3 on a page.
// @namespace     http://lifehacker.com/
// @include       *

//by Adam Pash
// ==/UserScript==

(function() {

       var flashinstalled = FlashDetect.installed;
				
		var page_links = document.links;
		for (var i=0; i<page_links.length; i++)
		{
			if (page_links[i].href.match(/\.mp3$/i))
			{
				if(flashinstalled)
				{

					var toggle = document.createElement("a");
					toggle.innerHTML = " <img class='inlineplaybutton' src='/storage/images/theme/PlayButton.png; alt='Play This MP3' />";
					toggle.style.cursor = "pointer";
					toggle.style.border = "none";
					toggle.className = "mp3PlayerLink";
					var mp3_url = page_links[i].href;
			    	var link_url = '#';
			    	link_url = 'http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl='+mp3_url+'&autoPlay=true'; 
					toggle.setAttribute( "rel", "shadowbox;width=400;height=27" );
					toggle.setAttribute( "href", link_url );
					page_links[i].parentNode.insertBefore(toggle, page_links[i].nextSibling)
				}
				else
				{
				   tmphtml = page_links[i].innerHTML;
				   tmphtml += "&nbsp;&nbsp;<img class='inlineplaybutton' src='/storage/images/theme/PlayButton.png; alt='Play This MP3' />";
				   page_links[i].innerHTML = tmphtml;
				}
				
			}
		}
})();



