blog.handlena.me

コード書いたりゲームしたり

閲覧ページのはてなブックマーク数を表示するGreasemonkeyスクリプト

(function() { var uri = location.href.replace(/#/, ’%23');

<span class="synIdentifier">var</span> span = <span class="synStatement">document</span>.createElement(<span class="synConstant">'span'</span>);
span.style.position = <span class="synConstant">'fixed'</span>;
span.style.<span class="synStatement">top</span> = <span class="synConstant">'0'</span>;
span.style.left = <span class="synConstant">'0'</span>;
span.style.maxHeight = <span class="synConstant">'13px'</span>;
span.style.opacity = <span class="synConstant">'0.3'</span>;
span.addEventListener(<span class="synConstant">'mouseover'</span>, <span class="synIdentifier">function</span>() <span class="synIdentifier">{</span>
    <span class="synIdentifier">this</span>.style.opacity = <span class="synConstant">'1.0'</span>;
<span class="synIdentifier">}</span>, <span class="synConstant">false</span>);
span.addEventListener(<span class="synConstant">'mouseout'</span>, <span class="synIdentifier">function</span>() <span class="synIdentifier">{</span>
    <span class="synIdentifier">this</span>.style.opacity = <span class="synConstant">'0.3'</span>;
<span class="synIdentifier">}</span>, <span class="synConstant">false</span>);

<span class="synIdentifier">var</span> img = <span class="synStatement">document</span>.createElement(<span class="synConstant">'img'</span>);
img.setAttribute(<span class="synConstant">'src'</span>, <span class="synConstant">'http://b.hatena.ne.jp/entry/image/'</span> + uri);

<span class="synIdentifier">var</span> a = <span class="synStatement">document</span>.createElement(<span class="synConstant">'a'</span>);
a.setAttribute(<span class="synConstant">'href'</span>, <span class="synConstant">'http://b.hatena.ne.jp/entry/'</span> + uri);

a.appendChild(img);
span.appendChild(a);
<span class="synStatement">document</span>.body.appendChild(span);

})(); [Javascript]