// ==UserScript==
// @name          Automatic image unlinker
// @namespace     http://www.jordanmills.com/
// @description   Takes links to image files and replaces them with the image.
// @include       *
// ==/UserScript==


var links = document.getElementsByTagName('a');
var newImage, newBR
 
for ( var i in links )
{
	if ( typeof( links[i].href ) == 'string' )
	{
		var imageLink = links[i].href+''
		if (( imageLink.indexOf('.jpg') != -1 ) ||( imageLink.indexOf('.gif') != -1 ) ||( imageLink.indexOf('.png') != -1 ) ||( imageLink.indexOf('.JPG') != -1 ) ||( imageLink.indexOf('.GIF') != -1 ) ||( imageLink.indexOf('.PNG') != -1 ))
		{
			newImage = document.createElement('img');
			newBR = document.createElement('br');
			newImage.src = links[i].href;
			links[i].appendChild(newBR);
			links[i].appendChild(newImage);     
		}
	}
}