Created
October 10, 2013 14:56
-
-
Save uolot/6919769 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var foobar = function($x) { | |
var tb = $x('//body//table/tbody')[3] | |
var trs = $x('./tr', tb) | |
var scoreboard = []; | |
for (i = 0; i < trs.length; i += 6) { | |
var lang = $x('.//font/text()', trs[i])[0].textContent.replace(' - Like', ''); | |
var getpoints = function(tr) { return $x('.//span[@id]/text()', tr)[0].textContent.replace(' points', '') } | |
var upvotes = getpoints(trs[i+1]); | |
var downvotes = getpoints(trs[i+4]); | |
var ratio = upvotes / downvotes; | |
scoreboard.push([lang, ratio]); | |
} | |
return scoreboard | |
.sort(function(a, b) { return b[1] - a[1] }) | |
.map(function(x, i) { return "" + (i+1) + ". " + x[0] }) | |
.join('\n'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment