验证中...
本周日【珠海源创会】一起聊聊:PingCAP分布式事务、支付宝移动端实践、GSBN技术框架选型,点此报名占座
语言: JavaScript
分类: JavaScript 工具
最后更新于 2018-10-14 23:22
gistfile1.js
原始数据 复制代码
! function() {
'use strict';
var hosts = 'https://gitee.com/chenxin126/exec/raw/master/src';
thin.imports(hosts + '/tool.js');
thin.imports(hosts + '/interactive.js');
thin.use(function() {
var self = this;
var money_opt = {
v1: self.data['data-money-v1'] || 0,
v2: self.data['data-money-v2'] || 0,
vd: self.data['data-money-vd'] || 0
};
var ajax = self.ajax;
ajax.config.state({
200: true,
201: true,
204: true
});
// 记录上次打码
var lottery_code = {
v1: null,
v2: null
};
// 记录配置
var config_opt = {
issue: null,
gameId: 80,
code: {
// 单
v1_single: 8014103,
v2_single: 8014203,
// 双
v1_double: 8014104,
v2_double: 8014204,
// 冠亚单
d: 8014003
}
};
// 获取开奖结果
requestLotteryResult(function(data) {
// 计算如何打码
formatLotteryCode(data.nums);
// 下注
submitLottery();
});
// -----------------------------------------------------------------------------------
// 获取开奖结果
function requestLotteryResult(callback) {
request();
function request() {
var url = 'https://www.ys96.com/static/data/80CurIssue.json?_t=' + Date.now();
ajax.get(url, function(res) {
if(res.state) {
formatIssue(res.data.issue, res.data);
} else {
setTimeout(request, 1.6 * 1000);
}
});
}
// 检测期号
function formatIssue(issue, data) {
var times = 999999;
if(config_opt.issue == issue) {
// 隔10秒再次获取
times = 10 * 1000;
} else {
// 隔30秒再次获取
times = 30 * 1000;
// 修改issue
config_opt.issue = issue;
// 开始打码
callback(data);
}
setTimeout(request, times);
}
}
// -----------------------------------------------------------------------------------
// 计算如何打码
function formatLotteryCode(nums) {
var codes = nums.split(',');
// 判断是否第一次购买
if(lottery_code.v1 && lottery_code.v2) {
// 不是第一次,判断上次买[单|双]
if(formatIsSingle(lottery_code.v1) || formatIsSingle(lottery_code.v2)) {
// 判断上次有冇中,中一次也算中
if(formatIsSingle(lottery_code.v1) == formatIsSingle(codes[0]) || formatIsSingle(lottery_code.v2) == formatIsSingle(codes[1])) {
// 中了买单
lottery_code.v1 = config_opt.code.v1_single;
lottery_code.v2 = config_opt.code.v2_single;
} else {
// 没中买双
lottery_code.v1 = config_opt.code.v1_double;
lottery_code.v2 = config_opt.code.v2_double;
}
} else {
// 上次买了双,这次买单
lottery_code.v1 = config_opt.code.v1_single;
lottery_code.v2 = config_opt.code.v2_single;
}
} else {
// 是第一次,买单
lottery_code.v1 = config_opt.code.v1_single;
lottery_code.v2 = config_opt.code.v2_single;
}
}
// -----------------------------------------------------------------------------------
// 下注
function submitLottery() {
var issue_next = Number(config_opt.issue) + 1;
var moneys = Number(money_opt.v1) + Number(money_opt.v2) + Number(money_opt.vd);
var data_opt = {
gameId: config_opt.gameId,
totalNums: 3,
totalMoney: moneys,
betSrc: 0,
turnNum: issue_next,
'betBean[0].playId': config_opt.code.d,
'betBean[0].money': money_opt.vd,
'betBean[1].playId': lottery_code.v1,
'betBean[1].money': money_opt.v1,
'betBean[2].playId': lottery_code.v2,
'betBean[2].money': money_opt.v2
};
var again = 3;
console.group('第' + issue_next + '期下注');
submit();
function submit() {
var url = 'https://www.mtc26.com/bet/bet.do?_t=' + Date.now();
ajax.post(url, data_opt, function(res) {
if(res.state) {
console.log('下注成功');
console.groupEnd();
renderBetResult();
} else {
if(again > 0) {
setTimeout(submit, 1.6 * 1000);
--again;
console.log('下注失败');
} else {
console.groupEnd();
}
}
});
}
}
});
}();
// -----------------------------------------------------------------------------------
// 判断[是|否]单
function formatIsSingle(num) {
if(num % 2 == 0) {
return false;
} else {
return true;
}
}
// 下注后刷新数据
function renderBetResult() {
// 刷新页面数据
if(document.querySelectorAll('.show a').length > 0) {
document.querySelectorAll('.show a')[1].click();
setTimeout(function() {
document.querySelectorAll('.show a')[0].click();
}, 800);
}
}

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助

12_float_left_people 12_float_left_close