forked from wanghsinche/GM_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
haitao_autoscript
183 lines (163 loc) · 5.34 KB
/
haitao_autoscript
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// ==UserScript==
// @name haitao
// @version 0.2.4
// @description 惠惠海淘自动脚本,使用时打开脚本就行,自动运行的。抢到单就自动停止,否则会一直抢。保留一切版权。
// @author Wanghsinche
// @include http://buyers.youdao.com/list*
// @include http://buyers.youdao.com/lis*
// @grant none
// @namespace https://greasyfork.org/users/326
// ==/UserScript==
var timer;
var success = false;
var order=false;
var showout=false;
var btnlst=[];
var btnposition="right";//选项为 left right 和 center
var positive=true;//true是点击第一个符合条件的账单,改为false就是点最后一个账单
//账号密码在这里添加
var judgeTime=500;//判断时间的间隔
var accountlst=[
{username:'[email protected]',password:'ilovechina..',oname:'杜子腾'},
{username:'[email protected]',password:'ilovechina..',oname:'杜琪琪'}
];
function insertHtml(accountlst){
var html='<form action="https://buyers.youdao.com/auth/login" method="post" style="display:inline-block;margin:5px;">'+
'<input name="username" type="Hidden" placeholder="Email" value=[un]>'+
'<input name="password" type="Hidden" placeholder="password" value=[pw]>'+
'<input type="submit" style="padding: 5px;border-radius: 5px;"class="button postfix margin-top-small login-button" value="[na]">'+
'</form>';
var finalhtml="";
$.each(accountlst,function(index,val){
finalhtml+=html.replace(/\[un\]/g,val.username).replace(/\[pw\]/g,val.password).replace(/\[na\]/g,val.oname);
});
//$('.pagination').before(finalhtml);
$('.breadcrumbs').append('<li style="float:'+btnposition+';">'+finalhtml+'</li>');
}
function extend2(p) {
var parent = p.prototype;
var c = {};
for (var i in parent) {
c[i] = parent[i];
}
c.uber = parent;
return c;
}
function extend(Parent) {
var F = function(){};
// var Child={};
F.prototype = Parent.prototype;
// Child.prototype = new F();
// Child.prototype.constructor = Child;
// Child.uber = Parent.prototype;
return new F();
}
function judgeHasOrder() {
//var only6pn=false;
if ($('.all-list-tbody').children().length !== 0) {
console.log('it should be click');
order=true;
btnlst=$(".-order-compete-button");
only6pn=true;
if (positive) {
for (var i = 0; i < btnlst.length; i++) {
if($(btnlst[i]).closest('tr').find('td').eq(2).text()==='amazon.com'){
// only6pn=false;
$(btnlst[i]).trigger('click');
break;
}
}
}else{
for (var i = btnlst.length - 1; i >= 0; i--) {
if($(btnlst[i]).closest('tr').find('td').eq(2).text()==='amazon.com'){
// only6pn=false;
$(btnlst[i]).trigger('click');
break;
}
}
}
//if(only6pn===true){
// location.reload();
//}
$.each(btnlst,function(index,val){
if($(index).closest('tr').find('td').eq(2).text()==='success'){
console.log('click');
return false;
}
});
define(['jquery'],function($){
var ModalClass=function(id){
this.id=id;
$('.modal-content').append('<div class="modal-content-body" id="'+this.id+'"></div>');
$('body').on('click','.modal-background, .modal-close',this, function(e) {
e.preventDefault();
if (e.target === e.currentTarget){
e.data.hide();
}
});
this.modalContent=$('.modal-content');
};
ModalClass.prototype.insertHtml=function(html){
$('#'+this.id).html(html);
};
ModalClass.prototype.show=function(){
$('.modal-background,.modal-content,#'+this.id).addClass('active');
this.modalContent.css({'margin-top':-this.modalContent.height()/2,'margin-left':-this.modalContent.width()/2});
};
ModalClass.prototype.hide=function(){
$('.modal-background,.modal-content,#'+this.id).removeClass('active');
};
return ModalClass;
});
// $(".-order-compete-button:last").trigger('click'); //click last one
//$(".-order-compete-button:first").trigger('click');//click first one
} else {
console.log("finding...");
timer = setTimeout(function() {
judgeHasOrder();
}, judgeTime);
}
}
function judgeSuccess() {
$.each($('.-order-release-anchor'), function(i, e) {
if ($(e).css('display') === 'inline') {
success = true;
}
});
if (success) {
console.log('judgeSuccess success');
$('label').trigger('click');
$('body').prepend("<div id='alart' style='height:300px;text-align:center;background: yellow;'>好了</div>");
$('body').prepend('<audio autoplay loop hidden><source src="https://kyfw.12306.cn/otn/resources/js/framework/audio/message.wav"></audio>');
} else {
setTimeout(function() {
judgeSuccess();
}, 5000);
}
}
function judgeShowOut(){
if ($('.lightRedText').length !== 0){
$.each($('.lightRedText'),function(i,e){
if($(e).text()==='错误!'){
showout=true;
}
});
}
if(showout){
console.log('judgeShowOut success');
setTimeout(function(){location.reload();},2000);
}
else{
setTimeout(function(){
judgeShowOut();
},2000);
}
}
var wxzscript = "<script type='text/javascript'>window.alert = function alert(msg) {console.log('Hidden Alert ' + msg);};</script>";
$('script[src="/script/list.js"]').after(wxzscript);
$('label').trigger('click');
console.log('v0.2.2');
insertHtml(accountlst);
judgeSuccess(); /* ring tone */
judgeShowOut();
judgeHasOrder(); /* Act on the event */