Skip to content

Instantly share code, notes, and snippets.

@MacLeek
Created September 13, 2018 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MacLeek/b2066f097071eea6399d0092b0aa80f5 to your computer and use it in GitHub Desktop.
Save MacLeek/b2066f097071eea6399d0092b0aa80f5 to your computer and use it in GitHub Desktop.
var names = $(".cell strong a").map(function () {
return (this.text)
}).toArray();
var distinctNames = new Set(names);
if (distinctNames.length < 80 || names.length < 100) {
console.log('重复数超过20,或者总回复不到100,本页不抽取');
} else {
var sum = 0;
distinctNames.forEach(function (name) {
for (var i in name) {
sum += name[i].charCodeAt()
}
});
var prizeNum = sum % 100 + 1;
while (1) {
console.log('中奖号:' + (prizeNum));
if (names.indexOf(names[prizeNum - 1]) === prizeNum - 1) {
console.log(names[prizeNum - 1]);
break;
} else {
console.log('中奖号非第一次回复的楼号,顺延');
if (prizeNum === 100) {
prizeNum = 1
} else {
prizeNum += 1
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment