/*
* @title Bookmark Entry reverse bookmarklet
* @description http://tsuredureweblog.hatenadiary.jp/entry/2016/02/22/212452
* @include http://b.hatena.ne.jp/entry/*
* @license MIT License
* @private
*/
(function(){
var tab = document.querySelector('#all-bookmarks-tab');
if (!tab) return;
tab.click(); // Precisely, should check whether there is class name 'current' in the element.
var b_list = document.querySelectorAll('#all-bookmarks #public-bookmarks .bookmark-list > li');
var bookmarkers = document.querySelector('#all-bookmarks #public-bookmarks');
var b_reversed = Array.prototype.slice.call(b_list).reverse();
var blist_len = b_reversed.length;
// Exclude the number of users
if (blist_len < 5 || blist_len >= 1000) return;
// Create replasement elements
var list = document.createElement('ul');
list.setAttribute('class', 'bookmark-list');
for (var i = 0; i < blist_len; i++) {
list.appendChild(b_reversed[i]);
}
// console.log(list + ' : ' + blist_len);
bookmarkers.replaceChild(list, bookmarkers.firstChild);
})();