Created
February 19, 2010 17:01
-
-
Save jbgutierrez/308904 to your computer and use it in GitHub Desktop.
Sort Delicious bookmarks by times saved
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
// ==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