Skip to content

Instantly share code, notes, and snippets.

@jbgutierrez
Created February 19, 2010 17:01
Show Gist options
  • Save jbgutierrez/308904 to your computer and use it in GitHub Desktop.
Save jbgutierrez/308904 to your computer and use it in GitHub Desktop.
Sort Delicious bookmarks by times saved
// ==UserScript==
// @name Sort Delicious bookmarks by times saved
// @namespace jbgutierrez.info
// @description Sort Delicious bookmarks by times saved
// @include http://delicious.com/*
// ==/UserScript==
// Add jQuery
var dependencies = ['http://jquery.com/src/jquery-latest.js', 'http://tinysort.sjeiti.com/scripts/jquery.tinysort.js'];
dependencies.forEach(function(dependency) {
var GM_JQ = document.createElement('script');
GM_JQ.src = dependency;
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
});
// Check if jQuery's loaded
function GM_wait() {
if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();
// All your GM code must be inside this function
function letsJQuery() {
$.strPad = function(i,l,s) {
var o = i.toString();
if (!s) { s = '0'; }
while (o.length < l) {
o = s + o;
}
return o;
};
$('#bmOptsLnk').before('<a id="custom_sort">Sort</div>');
$('#custom_sort').click(function() {
$(".delNavCount").each(function(i){
var amount = $(this).html();
$(this).attr('amount', $.strPad(amount, 10));
});
$('.post').tsort('.delNavCount', {order:'desc', attr:'amount', place:'bookmarklist'});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment