Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.