Skip to content

Instantly share code, notes, and snippets.

@yuanchuan
Created January 6, 2012 04:49
Show Gist options
  • Save yuanchuan/1569043 to your computer and use it in GitHub Desktop.
Save yuanchuan/1569043 to your computer and use it in GitHub Desktop.
play
/**
* 估算有多少人投票
*/
Math.round([].slice.call(
document.querySelectorAll(
'tbody td[bgcolor="#ffffff"]:nth-child(2)'
), 1)
.map(function(n){
return parseInt(
n.innerHTML.split(':(')[1]
);
})
.reduce(function(a, b){
return a + b;
}) / 2.7
);
/**
* 显示排名
*/
var map = [
[].slice.call(document.querySelectorAll('tbody td[bgcolor="#ffffff"]:nth-child(1)'), 1, 16)
.map(function(n){ return n.innerHTML.trim();}),
[].slice.call(document.querySelectorAll('tbody td[bgcolor="#ffffff"]:nth-child(2)'), 1)
.map(function(n){ return parseInt(n.innerHTML.split(':(')[1]);}),
[]
];
while (map[0].length && map[2].push(
{name:map[0].pop(),vote:map[1].pop()}
));
map[2]
.sort(function(a,b){return b.vote - a.vote;})
.forEach(function(s){console.log(s.name, s.vote);});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment