LiveJournal image placeholder replacer

By Zimzat Last update Jul 21, 2006 — Installed 388 times.
// ==UserScript==
// @name          LiveJournal image placeholder replacer
// @namespace     http://www.zimzat.com/greasemonkey/
// @description   Replaces image placeholders with the original image in-line. It also attempts to re-link images to an adjacent link tag.
// @include       http://*.livejournal.com/*
// ==/UserScript==

/* Copyright (c) 2006 Zimzat
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ or send 
 * a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
 */

(function() {
	function fnReplaceImage(varEvent) {
		varEvent.preventDefault();
		varEvent.stopPropagation();

		var varLink = varEvent.currentTarget;

		varLink.style.display = "none";
		varLink.style.visibility = "hidden;";

		varImage = document.createElement('img');
		varImage.setAttribute('src', varLink.getAttribute('href'));
		if (varLink.previousSibling && varLink.previousSibling.nodeName.toLowerCase() == 'a') {
			varLink.previousSibling.appendChild(varImage);
		} else {
			varLink.parentNode.insertBefore(varImage, varLink);
		}
	}

	var oLinks = document.evaluate("//A[@class='ljimgplaceholder']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	for (var x = 0; x < oLinks.snapshotLength; x++) {
		oLinks.snapshotItem(x).addEventListener('click', fnReplaceImage, false);
	}
})();