Last active
December 17, 2015 14:59
-
-
Save shibayan/5627927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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