-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_purchase.js
72 lines (60 loc) · 1.6 KB
/
auto_purchase.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
var autoPurchase = function(retry_interval, date, time, ticket_count) {
//page 1
var firstSubmit = submitData;
submitData(window.location.search.substr(6), '');
var page2_done = false;
$(document).ajaxComplete(function() {
if (page2_done) return;
console.log('page 2 callback');
$("#game_page").find('td').each(function(td, el) {
if (!el.onclick) {
return true;
}
if (date && el.parentNode.firstChild.innerHTML.search(date) < 0) {
return true;
}
if (time && el.parentNode.children[1].innerHTML.search(time) < 0) {
return true;
}
el.onclick();
page2_done = true;
return false;
});
if (!page2_done) {
window.setTimeout (function() {
firstSubmit(window.location.search.substr(6), '');
console.log('retry');
}, retry_interval || 1000);
return;
}
var page3_done = false;
$(document).ajaxComplete(function() {
if (page3_done) return;
console.log('page 3 callback');
$("#game_page").find('tr').each(function(td, obj) {
if (obj.onclick) {
obj.onclick();
page3_done = true;
return false;
}
});
if (!page3_done) {
window.setTimeout (function() {
firstSubmit(window.location.search.substr(6), '');
console.log('retry');
}, retry_interval || 1000);
return;
}
$(document).ajaxComplete(function() {
console.log('page 4 callback');
$("#game_page").find('select')[0].value = ticket_count || 1;
$("#game_page").find('select')[0].onchange();
$("#game_page").find('a')[1].onclick();
});
});
});
};
//first date, first seat, one ticket
autoPurchase(1000);
//select date, no time, 2 ticket
//autoPurchase(1000, '4/07', '', 2)