Bookmarkletで画像ビューア

Bookmarklet用の簡単なビューアVersion0.1(といっても1066文字もある・・・)


機能:

  • 実行すると、ページ内の<img>要素を順番に表示。
  • <img>要素が<a>要素に囲まれている場合は、<a>要素ごと表示。
  • Right, Leftで画像切り替え、Escでビューア終了。ビューア終了後、vで再度実行。
  • Rightで最初の画像より前に戻るか、Leftで最後の画像より先に進むとビューア終了。


テスト環境:Windows Vista SP2, Chrome 7.0.517.44

javascript:(function(a){function $(a,b,c){c=_.createElement(a);c.a=function(a){this.style.cssText=a};if(b)c.a(b);return c}var _=document,b=_.images,c=arguments.callee,d=_.body.appendChild($('div','position:fixed;left:0px;top:0px;width:100%;height:100%;background-color:rgba(0,0,0,.6);z-index:65535')),e=d.appendChild($('div','position:absolute;left:50%;top:50%;z-index:65535')),z='keydown',w=window,g=function(a){w.addEventListener(z,a,!1)},h=function(a){w.removeEventListener(z,a,!1)},j='U+001B';if(b.length==0)return;e.appendChild($('span'));function f(a,c){c=b.item(a);e.style.marginLeft=-c.width/2+'px';e.style.marginTop=-c.height/2+'px';e.replaceChild((/^a$/i.test(c.parentNode.tagName)?c.parentNode:c).cloneNode(true),e.firstElementChild)}f(a);g(function(e,k){k=e.keyIdentifier;if(k=='Left'?--a-a:k=='Right'?++a-a:k==j?0:1)return;e.preventDefault();if(a<0||b.length<=a||k==j){h(arguments.callee);_.body.removeChild(d);g(function(b){if(b.keyIdentifier=='U+0056'){b.preventDefault();h(arguments.callee);setTimeout(function(){c(k==j?a:0)},0)}});return}f(a)})})(0)

変数名・関数名・プロパティ名の短縮化をしてくれるJavaScriptコード圧縮機ってないかな。。。