Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created January 5, 2009 06:00
Show Gist options
  • Save hotchpotch/43275 to your computer and use it in GitHub Desktop.
Save hotchpotch/43275 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Expand star
// @namespace http://rails2u.com/
// @include http://*
// @include https://*
// ==/UserScript==
location.href = "javascript:"+encodeURIComponent(uneval(function () {
(function (Global) {
if (!(typeof Hatena != 'undefined' && typeof Hatena.Star != 'undefined'))
return;
var CLICK_COUNT = 4;
var TIMEOUT = 1000;
var EXPAND_ALL_TIMEOUT = 1000;
var expand, expandAll;
var click_count = 0;
document.body.addEventListener('mousedown', function(e) {
setTimeout(function() {
click_count = 0;
}, TIMEOUT);
if (++click_count >= CLICK_COUNT)
expandAll();
}, false);
expandAll = function() {
var innerStars = Ten.DOM.getElementsByTagAndClassName('span', 'hatena-star-inner-count');
var iLen = innerStars.length;
for (var i = 0; i < innerStars.length; i++) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent('click',true,true);
innerStars[i].dispatchEvent(clickEvent);
}
if (iLen) {
setTimeout(expand, EXPAND_ALL_TIMEOUT);
} else {
expand();
}
}
expand = function() {
var stars = Ten.DOM.getElementsByTagAndClassName('img', 'hatena-star-star');
var currentStar;
var showName = function(name, quote, pos, src) {
var container = new Ten.Element('div', {
style: {
display: 'inline',
fontSize: '90%',
padding: '1px',
margin: '0px 0px 0px 1px',
color: '#000',
backgroundColor: '#FFF',
}
});
container.appendChild(Hatena.Star.User.getProfileIcon(name, src));
var s = document.createElement('span');
s.innerHTML = name;
container.appendChild(s);
if (quote) {
var blockquote = document.createElement('blockquote');
Ten.Style.applyStyle(blockquote, {
display: 'inline',
fontSize: '90%',
padding: '0px',
margin: '0px',
color: '#000',
backgroundColor: '#DDD',
});
blockquote.innerHTML = '" ' + quote + ' "';
container.appendChild(blockquote);
}
currentStar._p_q_loaded = true;
Ten.DOM.replaceNode(container, currentStar);
Ten.DOM.unshiftChild(container, currentStar);
}
var origShowName = Hatena.Star.NameScreen.prototype.showName;
Hatena.Star.NameScreen.prototype.showName = showName;
for (var i = 0; i < stars.length; i++) {
var s = stars[i];
if (s._p_q_loaded) continue;
currentStar = s;
var mouseoverEvent = document.createEvent('MouseEvents');
mouseoverEvent.initMouseEvent('mouseover',true,true, window, 1,1,1,1,1,false,false,false,false,true,s);
s.dispatchEvent(mouseoverEvent);
var mouseoutEvent = document.createEvent('MouseEvents');
mouseoutEvent.initEvent('mouseout',true,true);
s.dispatchEvent(mouseoutEvent);
}
Hatena.Star.NameScreen.prototype.showName = origShowName;
}
})(this);
}))+"()";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment