// ==UserScript==
// @name Hatena Bookmark twimg tool
// @description はてなブックマークでtwimgのURLだったらなんかいろいろする
// @include http://b.hatena.ne.jp/*
// ==/UserScript==
/*
* @title Hatena Bookmark twimg tool
* @description はてなブックマークでtwimgのURLだったらなんかいろいろする
* @include http://b.hatena.ne.jp/*
* @license MIT License.
*/
(function() {
function hbtwimg(doc) {
var entry = doc.getElementsByClassName('entrylist-unit');
for (i in entry) {
/* twimgのURLを取る */
var image = entry[i].getElementsByClassName('entry-link')[0];
if ( ! /twimg/.test(image) ) { continue; }
/* ブコメブックスをサムネ対応に変える */
var box = entry[i].getElementsByClassName('curvebox-body')[0];
box.childNodes[0] = 'comment with-thumbnail';
/* サムネ追加 */
var tmb = document.createElement('span');
tmb.className = 'thumbnail';
tmb.innerHTML = '';
box.childNodes[0] = 'comment with-thumbnail';
box.insertBefore(tmb, box.childNodes[0]);
/* TODO:コピペボックスの設置 */
var box2 = box.getElementsByClassName('comment')[0];
var clipbox = document.createElement('li');
clipbox.className = 'clipbox';
clipbox.innerHTML = '';
box2.appendChild(clipbox);
}
}
if (typeof unsafeWindow == 'undefined') {
/* Bookmarklet, etc... */
var TEN = Ten;
} else {
/* Greasemonkey */
var TEN = unsafeWindow.Ten;
}
Ten.DOM.addEventListener('DOMContentLoaded', function () {
hbtwimg(document.body);
});
})();