Skip to content

Instantly share code, notes, and snippets.

@MacLeek MacLeek/v2_lottery.js Secret
Created Sep 13, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.