☆ with icon
by
yuta25
2014-12-10 [2014/12/10 14:40:44]
ブックマークについてる☆をアイコンにする
@@ -8,32 +8,32 @@
*/
(function(){
- var iconize = function () {
- var containers = document.querySelectorAll('.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|bkuma)\.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', 'height:16px;position:absolute;width:16px;');
- var star = containers[i].querySelector('.hatena-star-star');
- star.style['position'] = 'absolute';
- star.style['bottom'] = '1px';
- star.style['opacity'] = '0.7';
- // star.style['width'] = '7px';
- containers[i].insertBefore(icon, star);
- containers[i].setAttribute('iconized', '');
- containers[i].style['width'] = '16px';
- containers[i].style['height'] = '16px';
- containers[i].style['position'] = 'relative';
- containers[i].style['display'] = 'inline-block';
- containers[i].style['margin'] = '0 1px 0 1px';
- //containers[i].style['padding-top'] = '1px';
- //containers[i].style['top'] = '10px';
- }
- };
- iconize();
- var timer = 0;
+ var iconize = function () {
+ var containers = document.querySelectorAll('.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|bkuma)\.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', 'height:16px;position:absolute;width:16px;');
+ var star = containers[i].querySelector('.hatena-star-star');
+ star.style['position'] = 'absolute';
+ star.style['bottom'] = '1px';
+ star.style['opacity'] = '0.7';
+ // star.style['width'] = '7px';
+ containers[i].insertBefore(icon, star);
+ containers[i].setAttribute('iconized', '');
+ containers[i].style['width'] = '16px';
+ containers[i].style['height'] = '16px';
+ containers[i].style['position'] = 'relative';
+ containers[i].style['display'] = 'inline-block';
+ containers[i].style['margin'] = '0 1px 0 1px';
+ //containers[i].style['padding-top'] = '1px';
+ //containers[i].style['top'] = '10px';
+ }
+ };
+ iconize();
+ var timer = 0;
document.addEventListener('DOMNodeInserted', function() {
if(timer) return;
timer = setTimeout(function() {
/*
* @title ☆ with icon
* @description ブックマークについてる☆をアイコンにする
* @include http://b.hatena.ne.jp/*
* @include http://bkuma.hatena.ne.jp/*
* @license MIT License
* @require
*/
(function(){
var iconize = function () {
var containers = document.querySelectorAll('.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|bkuma)\.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', 'height:16px;position:absolute;width:16px;');
var star = containers[i].querySelector('.hatena-star-star');
star.style['position'] = 'absolute';
star.style['bottom'] = '1px';
star.style['opacity'] = '0.7';
// star.style['width'] = '7px';
containers[i].insertBefore(icon, star);
containers[i].setAttribute('iconized', '');
containers[i].style['width'] = '16px';
containers[i].style['height'] = '16px';
containers[i].style['position'] = 'relative';
containers[i].style['display'] = 'inline-block';
containers[i].style['margin'] = '0 1px 0 1px';
//containers[i].style['padding-top'] = '1px';
//containers[i].style['top'] = '10px';
}
};
iconize();
var timer = 0;
document.addEventListener('DOMNodeInserted', function() {
if(timer) return;
timer = setTimeout(function() {
iconize();
timer = 0;
}, 500);
}, false);
}());
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。