Sort by Length
by
nanto_vi
2011-03-09 [2011/03/09 19:16:06]
Sort bookmarks by comment length
-
/*
* @title Sort by Length
* @description Sort bookmarks by comment length
* @include http://b.hatena.ne.jp/entry/
* @license MIT License
*/
(function () {
var list = document.querySelector('#bookmarked_user');
var parent = list.parentNode;
var anchor = list.nextSibling;
var items = document.querySelectorAll('#bookmarked_user > li');
parent.removeChild(list);
[].map.call(items, function (item) {
return [item, item.querySelector('.comment').textContent.length];
}).sort(function (a, b) {
return b[1] - a[1];
}).forEach(function (e) {
list.appendChild(e[0]);
});
parent.insertBefore(list, anchor);
})();
-
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。