index of pages

Subscribe to index of pages 2 posts, 2 voices

 
alex. User

Could someone make a script that converts image links into pictures only on index of pages?

 
dob Scriptwright

Array.prototype.haskey = function(key) {
	for (var x=0; x<this.length; x++) {
		if (this[x] === key) {
			return true;
		}
	}
	return false;
}
var allowed = ["jpg","jpeg","gif","png","bmp"];

var links = document.getElementsByTagName("a");
for (var i=0; i<links.length; i++) {
	if (allowed.haskey(links[i].href.toLowerCase().split(".").pop())) {
		var image = document.createElement("img");
		image.src = links[i].href;
		links[i].parentNode.replaceChild(links[i], image);
	}
}

This is just on-the-fly, you'll still have to look when a page is indexing and stuff.
Also, I'm pretty sure there is an error in my code ;)