// ==UserScript==
// @name google news iframes
// @namespace http://www.kagami.org/
// @include http://news.google.*/*ncl=*
// ==/UserScript==
(function () {
var w = typeof unsafeWindow != 'undefined'? unsafeWindow: window;
var d = document;
var h = d.getElementsByTagName('head')[0];
var url2i = new Object;
var lhs = getElementsByTagNameWithClass(d, 'div', 'lh');
for (var i = 0; i < lhs.length; i++) {
init_lh(lhs, i);
}
createArticleIframe(lhs, 0);
function init_lh(lhs, i) {
lhs[i].iframe_loaded = false;
lhs[i].a = lhs[i].getElementsByTagName('a')[0];
url2i[escape(lhs[i].a.href)] = i;
addEvent(lhs[i].a, ['mouseover'], function(){ createArticleIframe(lhs, i); }, false);
}
function createArticleIframe(lhs, i) {
var lh = lhs[i];
if (lh.iframe_loaded) { return; }
var ifrm = d.createElement('iframe');
ifrm.style.width = '100%';
ifrm.style.height = '500px';
ifrm.src = lh.a.href;
var tbl = lh.parentNode.parentNode.parentNode.parentNode;
tbl.parentNode.insertBefore(ifrm, tbl.nextSibling);
addEvent(ifrm, ['mouseover'], function() {
if (i == lhs.length - 1) { return; }
createArticleIframe(lhs, i + 1);
}, false);
lh.iframe_loaded = true;
/* derived from http://worris.sakura.ne.jp/hbcview.html */
var script = d.createElement('script');
script.type= 'application/javascript';
script.charset= 'UTF-8';
script.src= 'http://b.hatena.ne.jp/entry/json/?url='
+ escape(ifrm.src) + '&callback=showBM';
h.appendChild(script);
}
w.showBM = function(item) { /* derived from http://worris.sakura.ne.jp/hbcview.html */
if(item.count!='0'){
var tbl = lhs[url2i[escape(item.url)]].parentNode.parentNode.parentNode.parentNode;
var div_hb_count = document.createElement('div');
text=""+item.count+" user"+(parseInt(item.count)>1 ? 's' : '')+" ";
div_hb_count.innerHTML=text;
var comment='';
for (var n = 0; n < item.bookmarks.length; n++) {
if (item.bookmarks[n].comment) {
comment += ""+item.bookmarks[n].user+": "+item.bookmarks[n].comment+"
";
}
}
if(comment!=''){
var div_hb_comment = document.createElement('div');
div_hb_comment.setAttribute('style','background-color:#C9D5F8;width:90%;');
div_hb_comment.innerHTML="