-
Notifications
You must be signed in to change notification settings - Fork 4
/
jd.js
95 lines (75 loc) · 2.84 KB
/
jd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var aboutme = "***京东夺宝岛抢拍-V 2.0-谁与争锋***\n"
console.log(aboutme);
console.log("有任何问题 %c QQ 244320233 Email:[email protected]", "color:red");
console.log("个人主页:http://zhanghang.org");
var code = "<div id='qp_div'>"
+ "最高出价<input type='text' id='qp_max_price' /> "
+ "单次加价<input type='text' id='qp_add_price' value='1' /> "
+ "<input type='button' value='自动抢拍' id='qp_btn_begin' class='qp_btn'/> "
+ "【程序倒计时有误差,so请在拍卖剩下30秒内再启动自动抢拍】<span id='say' style='color:red;'></span></div>";
$('body').prepend(code);
// 取商品拍卖编号
var num = queryNum();
var int = 0;
var remainTime = 0;
var host = "http://dbditem.jd.com"
$('#qp_btn_begin').on('click', function(){
setTimeout(function repeatMe(){
queryStatus(num);
var offset = new Date().getTime() % 100;
if (offset<50) {
setTimeout(repeatMe,100+offset);
} else{
setTimeout(repeatMe, offset);
}
},100);
});
function queryNum() {
var addr = window.location.href;
var ind = addr.lastIndexOf('/');
var num = addr.substring(ind+1)
return num;
}
function bid(paimaiId, price) {
console.info("抢拍中:" + price)
var max = $('#qp_max_price').val()
if (price*1.00 < max*1.00) {
var url = "/services/bid.action?t=" + getRamdomNumber();
var data = {paimaiId:paimaiId,price:price,proxyFlag:0,bidSource:0};
jQuery.getJSON(url,data,function(jqXHR){
if(jqXHR!=undefined){
if(jqXHR.result=='200'){
console.info("恭喜您,出价成功:" + price);
}else if(jqXHR.result=='login'){
window.location.href='http://passport.jd.com/new/login.aspx?ReturnUrl='+window.location.href;
}else{
console.info("很抱歉,出价失败" + jqXHR.message);
}
}
});
} else {
console.info("当前价:" + price +", 已超出你的报价最大值" + max)
}
}
function getRamdomNumber(){
var num="";
for(var i=0;i<6;i++)
{
num+=Math.floor(Math.random()*10);
}
return num;
}
// 查询商品状态
function queryStatus(num) {
var queryIF = host + "/json/current/queryList.action?paimaiIds="+num;
$.get(queryIF, function(data) {
var objs = $.parseJSON(data);
var remainTime = objs[0].remainTime;
var priceCurrent = objs[0].currentPrice;
console.info("####"+remainTime+"#####"+priceCurrent);
if (remainTime<201 && remainTime>0) {
var addPrice = $('#qp_add_price').val()*1.00
bid(num, priceCurrent * 1 + addPrice)
}
});
}