Last active
December 24, 2015 08:59
-
-
Save totakke/6773809 to your computer and use it in GitHub Desktop.
Sorts Clojure Cup apps by voting counts.
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
// Sort Clojure Cup 2014 apps by voting counts. | |
// | |
// Usage: | |
// Open `http://clojurecup.com/apps.html`. | |
// Input the address bar | |
// `javascript: var addScript=function(src){var script=document.createElement('script');script.src=src;script.type='text/javascript';document.querySelector('head').appendChild(script)};addScript('https://code.jquery.com/jquery-2.1.1.js');setTimeout(function(){addScript('https://rawgit.com/totakke/6773809/raw/********/sort-clojurecup-apps.js');},1000);" type="text/javascript"></script>');`. | |
(function() { | |
var countVotes = function(text) { | |
return parseInt(text.match(/\d/g).join('')); | |
}; | |
$('div[data-reactid=".0.1.0.1"]').html( | |
$('div[data-reactid=".0.1.0.1"] > div').sort(function(a, b) { | |
return countVotes($(b).find('div.small').html()) - countVotes($(a).find('div.small').html()); | |
}) | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
javascript: var addScript=function(src){var script=document.createElement('script');script.src=src;script.type='text/javascript';document.querySelector('head').appendChild(script)};addScript('https://code.jquery.com/jquery-2.1.1.js');setTimeout(function(){addScript('https://rawgit.com/totakke/6773809/raw/5911024f5b5bc80f1819d28b3e824ee6a0808d00/sort-clojurecup-apps.js');},1000);
.