リンク先の画像をページに埋め込むブックマークレット(改)

前のバージョンには古いIEで実行できない(IE8だと大丈夫)、グローバル変数を汚染する等の問題があったので修正した

サイズを減らすことを優先した結果汚れてしまったソースコードFirefox,IE8で動作確認済み)

javascript : (function ()
{
var r = function (e, x)
{
x = x * 128 + "px";
var g = new Image();
g.src = e.src;
e.style.height = e.style.width = "auto";
if (g.width > 128 && g.height > 128) {
g.width > g.height ? e.style.width = x : e.style.height = x;
}
};
var o = document.getElementsByTagName("a");
for (i = 0; i < o.length; i++)
{
var e = o[i];
e.href = e.href.replace(/(ime.nu|pinktower.com)\//, "");
if (/\.(jpg|png|gif)$/.test(e.href))
{
var a = document.createElement("img");
a.src = e.href;
a.style.height = a.style.width = "128px";
e.appendChild(document.createElement("br"));
e.appendChild(a);
var m = e.childNodes[2];
m.onload = function ()
{
r(this, 1)
};
m.onerror = function ()
{
r(this, 0)
};
m.onmouseover = function ()
{
r(this, 2)
};
m.onmouseout = function ()
{
r(this, 1)
}
}
}
})();
ブックマークレット

(古い)IE向けのコード
マウスを乗せても拡大されないリンクの後に改行されない等の違いがある

javascript : (function ()
{
r = function (e)
{
x = "128px";
g = new Image();
g.src = e.src;
if (g.width > 128 && g.height > 128) {
g.width > g.height ? e.style.width = x : e.style.height = x;
}
};
o = document.getElementsByTagName("a");
for (i = 0; i < o.length; i++)
{
e = o[i];
e.href = e.href.replace(/(ime.nu|pinktower.com)\//, "");
if (/\.(jpg|png|gif)$/.test(e.href))
{
a = document.createElement("img");
a.src = e.href;
e.style.height = e.style.width = "auto";
e.appendChild(a);
m = e.childNodes[2];
m.onload = function ()
{
r(this)
};
m.onerror = function ()
{
r(this)
}
}
}
})();
ブックマークレット