跳.jp化してtweetするbookmarklet
http://d.hatena.ne.jp/CenterC/20101220/1292846019 を魔改造。
Chromeっていつの間にか結構長いbookmarkletでも動くようになってた。以前は結構制限厳しい時期があったような……
javascript:function cbac(res){var d=document;var v=d.createElement('div');var a=d.createElement('a');a.href=encodeURI('http://twitter.com/?status= '+res.shorten+' "'+d.title+'"');a.target='_blank';a.onclick=function(){d.body.removeChild(v)};a.style.margen='50% 0px';a.style.backgroundColor='white';a.style.color='blue';a.style.fontSize='xx-large';a.style.textAlign='center';a.appendChild(d.createTextNode('tweet for "'+d.title+'"'));v.style.position='absolute';v.style.top=d.body.scrollTop;v.style.left=0;v.style.zIndex=256;v.style.width='100%';v.appendChild(a);d.body.appendChild(v);}(function(d){var s=d.createElement('script');s.setAttribute('src','http://跳.jp/api.jsonp?url='+location.href+'&callback=cbac');d.head.appendChild(s);})(document);
無駄な装飾が入ってるから長くなるのだけど。
実行するとページの一番上に、白背景に青文字の"tweet for なんちゃら"という(font-size:xx-largeの)リンクが出てくるので、クリックするとついったーが別窓で開く。
クリックとともに出てきたリンクは消える。
それだけ。
style関連いじってるあたりをテキトーに書き換えれば見た目も変えられる。
一応、同内容で見やすくしたもの。
javascript: function cbac(res){ var d=document; var v=d.createElement('div'); var a=d.createElement('a'); a.href=encodeURI('http://twitter.com/?status= '+res.shorten+' "'+d.title+'"'); a.target='_blank'; a.onclick=function(){d.body.removeChild(v)}; a.style.margen='50% 0px'; a.style.backgroundColor='white'; a.style.color='blue'; a.style.fontSize='xx-large'; a.style.textAlign='center'; a.appendChild(d.createTextNode('tweet for "'+d.title+'"')); v.style.position='absolute'; v.style.top=d.body.scrollTop; v.style.left=0; v.style.zIndex=256; v.style.width='100%'; v.appendChild(a); d.body.appendChild(v); } (function(d){ var s=d.createElement('script'); s.setAttribute('src','http://跳.jp/api.jsonp?url='+location.href+'&callback=cbac'); d.head.appendChild(s); })(document);
追記
書き忘れてたけどChrome10以外では動作確認してないので、動かなかったら動くように各自で書き換えてくださいね(ぉ
追記(2011/04/01)
表示位置の一番上にリンクを出すように変更。