/*
* @title ☆ with icon
* @description ブッコメークについてる☆をアイコンにする
* @include http://b.hatena.ne.jp/entry/*
* @license MIT License
* @require
*/
(function(){
var iconize = function () {
var containers = document.querySelectorAll('.bookmark-list .hatena-star-star-container a');
for (var i = 0, length = containers.length; i < length; i++) {
if (containers[i].hasAttribute('iconized')) continue;
var user = containers[i].href.replace('http://b.hatena.ne.jp/', '').replace('/', '');
var icon = document.createElement('img');
icon.src = 'http://cdn1.www.st-hatena.com/users/' + user.substr(0, 2) + '/' + user + '/profile.gif';
icon.setAttribute('style', 'bottom:-2px;height:20px;position:absolute;width:20px;');
var star = containers[i].querySelector('.hatena-star-star');
star.style['position'] = 'absolute';
star.style['bottom'] = '-1px';
containers[i].insertBefore(icon, star);
containers[i].setAttribute('iconized', '');
containers[i].style['width'] = '22px';
containers[i].style['position'] = 'relative';
containers[i].style['display'] = 'inline-block';
}
}
iconize();
var timer = 0;
document.addEventListener('DOMNodeInserted', function() {
if(timer) return;
timer = setTimeout(function() {
iconize();
timer = 0;
}, 500);
}, false);
}());