Skip to content

Instantly share code, notes, and snippets.

@shibayan
Last active December 17, 2015 14:59
Show Gist options
  • Save shibayan/5627927 to your computer and use it in GitHub Desktop.
Save shibayan/5627927 to your computer and use it in GitHub Desktop.
<ul id="hatena-bookmark" class="hatena-urllist"></ul>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.10.2.min.js"></script>
<script>
!function ($, id, url) {
var ul = $(id);
ul.parent().prev().wrapInner('<a href="http://b.hatena.ne.jp/entrylist?url=' + url + '&sort=count"></a>');
$.getJSON("http://rss2json.azurewebsites.net/hatena/bookmark?callback=?", { url: url }, function (data) {
var list = [];
$.each(data, function (i, d) {
var link = $("<a/>", { href: d.link }).append($("<span/>", { text: d.title }));
var cnt = $("<a/>", { href: "http://b.hatena.ne.jp/entry/" + d.link, text: d.count + "users" });
var container = $("<span/>", { class: "bookmark-count" }).append(d.count > 10 ? $("<strong/>").append(cnt) : d.count >= 5 ? $("<em/>").append(cnt) : cnt);
list.push($("<li/>").append(link, container));
});
ul.append(list);
});
}(jQuery, "#hatena-bookmark", "http://shiba-yan.hatenablog.jp/");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment