This repository was archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
308 lines (289 loc) · 8.8 KB
/
main.js
File metadata and controls
308 lines (289 loc) · 8.8 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
"ui";
var color = "#4390E6";
const urlGetNum = "anti-feiyoung.younnt.one:4096/numInQuery";
const urlPostAccount = "anti-feiyoung.younnt.one:4096/account";
const loginPerformer = require("./loginPerformer");
ui.layout(
<frame>
<vertical>
<appbar>
<toolbar id="toolbar" title="Anti Feiyoung" bg="#4390E6" />
<tabs id="tabs" bg="#4390E6" />
</appbar>
<viewpager id="viewpager">
<vertical>
<text text="注意" textSize="20sp" margin="20 20" textColor="black" />
<text
text="1. 🌟如果点击按钮无反应,多次点按会导致程序卡死,请在设置中设置允许显示悬浮窗!具体方法自行百度,这个问题会在后续版本修复。"
textSize="16sp"
margin="40 5"
textColor="black"
/>
<text
text="2. 🌟一键发射【悬浮窗权限】----一键让路由器有网"
textSize="16sp"
margin="40 5"
textColor="black"
/>
<text
text="3. 🌟获取燃料【悬浮窗权限】----提交账号密码,再次提交可以查看队列位置和获取并保存专用密码"
textSize="16sp"
margin="40 5"
textColor="black"
/>
<text
text="-> 查询队列长度【悬浮窗权限】----查询总共有多少人在排队"
textSize="16sp"
margin="40 5"
/>
<text
text="4. 🌟高级模式【悬浮窗权限】----一些手动操作"
textSize="16sp"
margin="40 5"
textColor="black"
/>
<text
text="-> 登陆【悬浮窗权限】----通过直拨密码和账号登陆"
textSize="16sp"
margin="40 5"
/>
<text
text="-> 手动导入 ----通过剪贴板导入密码"
textSize="16sp"
margin="40 5"
/>
</vertical>
<frame>
<img
id="launch"
w="100"
h="100"
layout_gravity="center"
src="file://./src/rocket.png"
/>
<horizontal gravity="center" marginTop="300">
<progressbar
id="progress"
w="300"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
/>
</horizontal>
</frame>
<frame>
<button
id="refreshNum"
w="*"
h="50"
style="Widget.AppCompat.Button.Colored"
text="查询队列长度"
bg="#4390E6"
textColor="#ffffff"
margin="10 10 10 10"
/>
<horizontal margin="50 200 50 10">
<text text="手机号" />
<input w="200" id="phone" singleLine="true" />
</horizontal>
<horizontal margin="50 300 50 10">
<text text="宽带密码" />
<input w="200" id="password" singleLine="true" />
</horizontal>
<button
id="postData"
w="*"
h="50"
style="Widget.AppCompat.Button.Colored"
text="提交"
bg="#4390E6"
textColor="#ffffff"
margin="10 400 10 10"
/>
</frame>
<frame>
<horizontal margin="50 100 50 10">
<text text="手机号" />
<input w="200" id="phoneLoginManually" singleLine="true" />
</horizontal>
<horizontal margin="50 200 50 10">
<text text="直拨密码" />
<input w="200" id="passwordLoginManually" singleLine="true" />
</horizontal>
<button
id="launchManually"
w="*"
h="50"
style="Widget.AppCompat.Button.Colored"
text="登陆"
bg="#4390E6"
textColor="#ffffff"
margin="10 300 10 10"
/>
<button
id="loadManually"
w="*"
h="50"
style="Widget.AppCompat.Button.Borderless.Colored"
text="手动导入"
margin="10 420 10 10"
/>
<horizontal gravity="center" marginTop="300">
<progressbar
id="progress"
w="300"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
loyout_gravity="center"
/>
</horizontal>
</frame>
<vertical>
<text
text="版本发布"
textSize="20sp"
margin="20 20"
textColor="black"
/>
<button
id="download"
gravity="left"
h="70"
style="Widget.AppCompat.Button.Borderless.Colored"
text="以微云文件夹形式发布,前往选择最新版本安装"
textSize="16sp"
margin="40 0"
/>
<text text="关于" textSize="20sp" margin="20 0" textColor="black" />
<text id="about" margin="40 10" />
<button
id="sendEmail"
gravity="left"
h="50"
style="Widget.AppCompat.Button.Borderless.Colored"
text="发送邮件"
textSize="16sp"
margin="40 0"
/>
<text
text="请开发者爆肝"
textSize="20sp"
margin="20 0"
textColor="black"
/>
<img
src="file://./src/coffee.png"
margin="20 0"
scaleType="centerInside"
/>
</vertical>
</viewpager>
</vertical>
</frame>
);
/**
* Init Data
*/
/**
* Define UI
*/
ui.about.setText(
"1. 本软件仅供测试使用\n2. 本软件由Younntone公益开发,如果你通过购买获得,说明你被坑了!\n3. 本软件不提供任何使用保障,有建议或者BUG反馈可以发邮件给开发者。\n"
);
activity.setSupportActionBar(ui.toolbar);
ui.statusBarColor(color);
ui.viewpager.setTitles(["说明", "一键发射", "获取燃料", "高级模式", "关于"]);
ui.tabs.setupWithViewPager(ui.viewpager);
/**
* Button Action
*/
// Check version
ui.download.click(function() {
app.openUrl("https://share.weiyun.com/5Zg68Nc");
});
// Send email
ui.sendEmail.click(function() {
app.sendEmail({
email: "younntone@gmail.com",
subject: "Anti Feiyoung APP 反馈/建议"
});
});
// * Launch
ui.launch.click(function() {
let date = new Date();
let account = storages.create("account");
let ciphers = account.get("ciphers");
let phone = account.get("phone");
if (ciphers) {
loginPerformer(phone, ciphers[date.getDate()-1]);
log(ciphers[date.getDate()-1]);
} else {
alert("提示", "油箱空空,请前往获取燃料!");
}
});
// * Get query lenght
ui.refreshNum.click(function() {
let code = 0;
let request = threads.start(function() {
let res = http.get(urlGetNum);
let result = res.body.json();
code = res.statusCode;
alert("队列长度", "队列中还有 " + result.code + " 位");
let initStorage = storages.create("rawAccount");
let phone = new String();
let password = new String();
for (let index = 0; index < 11; index++) {
var element = initStorage.get("phone").mText[index];
phone = phone.concat(element);
}
for (let index = 0; index < 6; index++) {
var element = initStorage.get("password").mText[index];
password = password.concat(element);
}
setText(0, phone);
setText(1, password);
});
request.join(3000);
if (code === 0) {
request.interrupt();
toast("服务器连接超时!");
}
});
// * Commit accuont
ui.postData.click(function() {
let code = 0;
let request = threads.start(function() {
let res = http.post(urlPostAccount, {
phone: ui.phone.getText(),
password: ui.password.getText()
});
let result = res.body.json();
code = res.statusCode;
if (result.code === 0) {
let storage = storages.create("account");
storage.put("phone", result.data.phone);
storage.put("ciphers", result.data.ciphers);
} else if (result.code === 1 || result.code === -1) {
let storage = storages.create("rawAccount");
storage.put("phone", ui.phone.getText());
storage.put("password", ui.password.getText());
}
alert("提交账号", result.message);
});
request.join(3000);
if (code === 0) {
request.interrupt();
toast("服务器连接超时!");
}
});
// * Launch manually
ui.launchManually.click(function() {
let phone = ui.phoneLoginManually.getText();
let cipher = ui.passwordLoginManually.getText();
if (phone && cipher) {
loginPerformer(phone, cipher);
} else {
toast("请填写正确的是手机号和密码!");
}
});
// * Load Manually
ui.loadManually.click(function() {
toast("TODO");
});