Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
☆をハッピィにするGreasemonkey
// ==UserScript==
// @name hatena-star-happie
// @namespace http://www.hatena.ne.jp/hitode909
// @include *
// ==/UserScript==
(function(){
var user_icon = function(name) {
return "http://www.st-hatena.com/users/" + name.slice(0, 2) + "/" + name + "/happie.gif";
}
setInterval(function() {
Array.prototype.slice.call(document.querySelectorAll("span.hatena-star-star-container a")).forEach(function(star) {
try {
if (star.className.match(/user-icon/)) return;
star.className += 'user-icon';
var img = star.querySelector('img');
s = img.style;
s.position = 'absolute';
s.top = '0px';
s.left = '0px'
s.margin = '0px';
s.padding = '0px'
s.marginBottom = '0px !important';
s.width = '64px';
s.height = '148px';
var new_img = img.cloneNode(false);
var name = star.href.match(/hatena\.ne\.jp\/([^\/]+)\/?/)[1];
s = new_img.style;
new_img.src = user_icon(name);
img.style.margin = '0px';
img.style.opacity = 1.0;
img.className += ' hatena-star-star-img';
img.style.height = '64px';
var container = document.createElement('span');
s = container.style;
s.position = 'relative';
s.display = 'inline-block';
s.width = '64px';
s.height = '148px';
s.verticalAlign = 'middle';
star.appendChild(container);
container.appendChild(new_img);
container.appendChild(img);
} catch(e) { };
});
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment