// ==UserScript== // @name highlightOwnStar // @namespace kurain.net // @include http://* // @include https://* // ==/UserScript== (function(){ function main() { GM_xmlhttpRequest({ method:"GET", url:"http://b.hatena.ne.jp/my.name", onload:highlight }); } function highlight (json) { owner_id = eval("(" + json.responseText + ")").name var randomColor = function() { return 'rgb(' + (Math.random() > 0.5 ? 255 : 0) + ', ' + (Math.random() > 0.5 ? 255 : 0) + ', ' + (Math.random() > 0.5 ? 255 : 0) + ')'; }; var style = document.createElement('style'); document.body.appendChild(style); var stars = document.querySelectorAll('span.hatena-star-star-container a'); var classes = []; for( var i=0; i < stars.length; i++ ) { if ( stars[i].href.indexOf( owner_id ) > 0 ) { var ownStarClass = 'ownHatenaStar-' + i; classes.push(ownStarClass); stars[i].className = stars[i].className + ' ' + ownStarClass; } } var apply = function() { style.textContent = classes.map(function(selector) { if (!selector) return ''; return '.' + selector + ' { background: ' + randomColor() + ' }'; }).join("\n"); }; setInterval(apply, 0); } window.addEventListener('load', main , false); })();