Skip to content

Instantly share code, notes, and snippets.

@kga
Created February 22, 2009 18:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kga/68561 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hatena::Bookmark - Highlight Favorite Users
// @namespace http://d.hatena.ne.jp/KGA/
// @include http://b.hatena.ne.jp/entry/*
// ==/UserScript==
(function() {
var th = $X('//th[contains(., "お気に入り")]')[0];
if (!th) return;
var favs = $X('./following-sibling::td/ul[@class="userlist"]/li/img', th).map(function (img) img.title);
GM_addStyle(
favs.map(function (id) '#bookmark-user-' + id).join(', ') + ' { ' +
'-moz-border-radius: 0.5em !important;' +
'border: 1px solid #CCC !important;' +
'background-color: #FFF !important;' +
' }'
);
// very simple version of $X
// $X(exp);
// $X(exp, context);
// $X(exp, context, resolver);
// @source http://gist.github.com/29681.txt
function $X (exp, context, resolver, result_type) {
context || (context = document);
var Doc = context.ownerDocument || context;
var result = Doc.evaluate(exp, context, resolver, result_type || XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (result_type) return result;
for (var i = 0, len = result.snapshotLength, res = []; i < len; i++) {
res.push(result.snapshotItem(i));
}
return res;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment