Skip to content

Instantly share code, notes, and snippets.

@ejoubaud
Last active December 29, 2015 04:09
Show Gist options
  • Save ejoubaud/7613155 to your computer and use it in GitHub Desktop.
Save ejoubaud/7613155 to your computer and use it in GitHub Desktop.
Bookmarklet that loads jQuery + tinysort, so it's easy to order search results from the browser's JS console: $('.containers-to-sort').tsort('.childnode-criteria-to-sort-by', {order: 'desc'});
javascript:(function(){var v="1.10.2";if(window.jQuery===undefined||window.jQuery.fn.jquery<v){var done=false;var script=document.createElement("script");script.src="//ajax.googleapis.com/ajax/libs/jquery/"+v+"/jquery.min.js"; script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;initMyBookmarklet();}};document.getElementsByTagName("head")[0].appendChild(script);}else{initMyBookmarklet();}function initMyBookmarklet(){(window.myBookmarklet=function(){function getSelText(){var s='';if(window.getSelection){s=window.getSelection();}else if(document.getSelection){s=document.getSelection();}else if(document.selection){s=document.selection.createRange().text;}return s;};$.getScript('//tinysort.sjeiti.com/dist/jquery.tinysort.min.js',function(){alert("loaded.\n\n$('.tosort').tsort('.subclass-to-sort-by', {order: 'desc'});\n\n$('#ctl00_ContentMain_CitySearchResult_v2_upResultData>div').tsort('.fontxlargeb.purple', {sortFunction:function(a,b){var a1,b1; return (a1=parseInt(a.s,10))===(b1=parseInt(b.s,10))?0:(a1>b1?1:-1)}});\n\nGo nuts")})})();}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment