Hatena::ブログ(Diary)

by edvakf in hatena

2010-01-15

英語のニュースを読みやすくするブックマークレット

英語のニュースサイトって、文字が小さくてびっしり書いてあって読みにくいんだけど、大抵は専門家のインタビューが引用されてて、そこだけ読めば要点はわかる場合が多い。

というわけで、引用符で囲まれているところを強調するブックマークレットを作った。(非 IE 用)

javascript:(function(){var r=document.evaluate('//body//text()[(contains(., \'\') and contains(., \'\')) or (contains(., \'"\') and contains(., \'"\')) and not (local-name(./ancestor::*[1])="script" or local-name(./ancestor::*[1])="style" or local-name(./ancestor::*[1])="SCRIPT" or local-name(./ancestor::*[1])="STYLE")]', document, null, 7, null);for(var i=0,n;n=r.snapshotItem(i++);){var df=document.createDocumentFragment();n.nodeValue.split(/([“"][\s\S]*?[”"])/).forEach(function(s,i){if(i%2==0){var t=document.createTextNode(s);}else{var t=document.createElement('span');t.textContent=s;t.style.color='hotpink';t.style.fontSize='large';}df.appendChild(t);});n.parentNode.replaceChild(df,n);};})();

例えばこの記事だと、

f:id:edvakf:20100115160827p:image

f:id:edvakf:20100115160854p:image

になる。

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/edvakf/20100115/1263539415