// ==UserScript==
// @name Resize Lucifer's super big picture
// @namespace http://www.darkthread.net
// @include http://blogs.myoops.org/*
// ==/UserScript==
// Add jQuery, ref http://joanpiedra.com/jquery/greasemonkey/
var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded
function GM_wait() { if(typeof unsafeWindow.jQuery == 'undefined')
window.setTimeout(GM_wait,100);
else { $ = unsafeWindow.jQuery; resizeHugeImage(); } }
GM_wait();
// All your GM code must be inside this function
function resizeHugeImage() { $("img").each(function() { if (this.complete) //if already loaded
proc.call(this);
else //hook load event
$(this).load(proc);
});
function proc() { var img = $(this);
var w = img.width(), h = img.height();
var longSide = (w > h ? w : h);
if (longSide > 800) { var ratio = 800.0 / longSide;
var nw = w * ratio;
var nh = h * ratio;
img.data("h", h).data("w", w) .width(nw).height(nh)
.css("cursor", "pointer") .hover(
function() { $(this).css("border", "solid 2px red"); }, function() { $(this).css("border", "solid 2px black"); }) .dblclick(function() { var x = $(this);
x.width(x.data("w")) .height(x.data("h")); });
}
}
}