forked from sawdjh010/jianya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UI.js
1965 lines (1883 loc) · 102 KB
/
UI.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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"ui";
importClass(java.net.HttpURLConnection);
importClass(java.net.URL);
importClass(java.io.File);
importClass(java.io.FileOutputStream);
importClass(android.graphics.Color);
console.clear();
ui.主题颜色 = "#FFC0CB";
ui.标题 = "学习四合一测试版pro(从疫情中走出,专心于工作)";
ui.副标题 = "让各位从疫情走出来专心于工作";
ui.启动赞助公告 = "1.[VIP支持多账号]每次启动先至 'VIP卡密'栏点击'登录/试用'-----'脚本配置'(保存配置)-----再点击'开始学习'按钮;\n2.试用期5天,联系群主(支持)赞助后获得卡密(月/季/年);\n3.感谢您的支持!!!\n'技术人员'每次熬夜+发量减少的修改、调试……,给予点点欣慰!"
ui.公告 = "1.仅供个人测试(内部测试)使用(四合一)pro全新上线;\n2.新增网络验证系统;\n3.不同情况选择设置和对应脚本运行;\n4.新增新验证震动提醒提示;\n5.试用期过后,请赞助获取卡密(新Q群:758116397,加群获得最新apk和资料);\n6.脚本(QG最新版)去截图权限版,适用于手机root或虚拟机或模拟器通过模块去除截图限制等;\n7.(QG最新版)去截图权限版,支持四人/双人赛(OCR),支持订阅、支持运动步数、支持未作答的每周答题等;\n8.除首页中'(QG最新版)去截图权限版'脚本外,其它脚本则推荐用强国V2.33版.";
const PJYSDK = (function(){
function PJYSDK(app_key, app_secret){
http.__okhttp__.setMaxRetries(0);
http.__okhttp__.setTimeout(5*1000);
this.event = events.emitter();
this.debug = true;
this._lib_version = "v1.13";
this._protocol = "http";
this._hosts = ["api3.paojiaoyun.com", "api2.paojiaoyun.com", "api.paojiaoyun.com"];
this._host = this._hosts[0];
this._device_id = this.getDeviceID();
this._retry_count = 9;
this._switch_count = 0;
this._app_key = app_key;
this._app_secret = app_secret;
this._card = null;
this._username = null;
this._password = null;
this._token = null;
this.is_trial = false; // 是否是试用用户
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
this._auto_heartbeat = true; // 是否自动开启心跳任务
this._heartbeat_gap = 120 * 1000; // 默认120秒
this._heartbeat_task = null;
this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};
this._prev_nonce = null;
this._is_ping = false;
}
PJYSDK.prototype.SetBackupHosts = function(hosts) { // 设置备用 api host
this._hosts.concat(hosts);
}
PJYSDK.prototype.switchHost = function() { // 切换备用 api host
this._switch_count++;
this._host = this._hosts[this._switch_count%this._hosts.length];
}
PJYSDK.prototype.SetCard = function(card) {
this._card = card.trim();
}
PJYSDK.prototype.SetUser = function(username, password) {
this._username = username.trim();
this._password = password;
}
PJYSDK.prototype.getDeviceID = function() {
let id = device.serial;
if (id == null || id == "" || id == "unknown") {
id = device.getAndroidId();
}
if (id == null || id == "" || id == "unknown") {
id = device.getIMEI();
}
return id;
}
PJYSDK.prototype.MD5 = function(str) {
try {
let digest = java.security.MessageDigest.getInstance("md5");
let result = digest.digest(new java.lang.String(str).getBytes("UTF-8"));
let buffer = new java.lang.StringBuffer();
for (let index = 0; index < result.length; index++) {
let b = result[index];
let number = b & 0xff;
let str = java.lang.Integer.toHexString(number);
if (str.length == 1) {
buffer.append("0");
}
buffer.append(str);
}
return buffer.toString();
} catch (error) {
alert(error);
return "";
}
}
PJYSDK.prototype.getTimestamp = function() {
try {
let res = http.get("http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp");
let data = res.body.json();
return Math.floor(data["data"]["t"]/1000)-3;
} catch (error) {
try {
let res = http.get("https://tptm.hd.mi.com/gettimestamp");
let data = res.body.string();
return parseInt(data.replace('var servertime=', ''))-3;
} catch (error) {
return Math.floor(new Date().getTime()/1000) - 3;
}
}
}
PJYSDK.prototype._draw_cc_params = function(body) {
if (!body) return "";
start = body.indexOf('?');
if (start < 0) return "";
end = body.indexOf('";');
if (end < 0 || end < start) return "";
return body.substring(start, end);
}
PJYSDK.prototype.Ping = function() {
if (this._is_ping) return;
try {
let path = "/v1/ping"
let url = this._protocol + "://" + this._host + path;
let resp = http.get(url);
let body = resp.body.string();
if (body == "Pong") {
log("api连接成功")
this._is_ping = true;
return
}
let params = this._draw_cc_params(body);
if (params) {
let resp2 = http.get(url + params);
if (resp2.body.string() == "Pong") {
log("api连接成功")
this._is_ping = true;
}
} else {
this.switchHost();
}
} catch (error) {
this.switchHost();
}
}
PJYSDK.prototype.genNonce = function() {
const ascii_str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let tmp = '';
for(let i = 0; i < 20; i++) {
tmp += ascii_str.charAt(Math.round(Math.random()*ascii_str.length));
}
return this.MD5(this.getDeviceID() + this._prev_nonce + new Date().getTime() + tmp);
}
PJYSDK.prototype.joinParams = function(params) {
let ps = [];
for (let k in params) {
ps.push(k + "=" + params[k])
}
ps.sort()
return ps.join("&")
}
PJYSDK.prototype.CheckRespSign = function(resp) {
if (resp.code != 0 && resp.nonce === "" && resp.sign === "") {
return resp
}
let ps = "";
if (resp["result"]) {
ps = this.joinParams(resp["result"]);
}
let s = resp["code"] + resp["message"] + ps + resp["nonce"] + this._app_secret;
let sign = this.MD5(s);
if (sign === resp["sign"]) {
if (this._prev_nonce === null) {
this._prev_nonce = resp["nonce"];
return {"code":0, "message":"OK"};
} else {
if (resp["nonce"] > this._prev_nonce) {
this._prev_nonce = resp["nonce"];
return {"code": 0, "message": "OK"};
} else {
return {"code": -98, "message": "CRS:nonce校验失败"};
}
}
}
return {"code": -99, "message": "CRS:签名校验失败"};
}
PJYSDK.prototype.retry_fib = function(num) {
if (num > 9) {
return 34
}
let a = 0;
let b = 1;
for (let i = 0; i < num; i++) {
let tmp = a + b;
a = b
b = tmp
}
return a
}
PJYSDK.prototype._debug = function(path, params, result) {
if (this.debug) {
log("\n" + path, "\nparams:", params, "\nresult:", result);
}
}
PJYSDK.prototype.Request = function(method, path, params) {
this.Ping();
// 构建公共参数
params["app_key"] = this._app_key;
method = method.toUpperCase();
let max_retries = this._retry_count;
let retries_count = 0;
let data = {"code": -1, "message": "连接服务器失败"};
do {
let url = this._protocol + "://" + this._host + path;
retries_count++;
let sec = this.retry_fib(retries_count);
delete params["sign"]
params["nonce"] = this.genNonce();
params["timestamp"] = this.getTimestamp();
let ps = this.joinParams(params);
let s = method + this._host + path + ps + this._app_secret;
let sign = this.MD5(s);
params["sign"] = sign;
let resp, body;
try {
if (method === "GET") {
resp = http.get(url + "?" + ps + "&sign=" + sign);
} else { // POST
resp = http.post(url, params);
}
body = resp.body.string();
data = JSON.parse(body);
this._debug(method+'-'+path+':', params, data);
let crs = this.CheckRespSign(data);
if (crs.code !== 0) {
return crs;
} else {
return data;
}
} catch (error) {
if (this.debug) {
log("[*] request error: ", error, sec + "s后重试");
}
this._debug(method+'-'+path+':', params, body);
this.switchHost();
sleep(sec*1000);
}
} while (retries_count < max_retries);
return data;
}
/* 通用 */
PJYSDK.prototype.GetHeartbeatResult = function() {
return this._heartbeat_ret;
}
PJYSDK.prototype.GetTimeRemaining = function() {
let g = this.login_result.expires_ts - this.getTimestamp();
if (g < 0) {
return 0;
}
return g;
}
/* 卡密相关 */
PJYSDK.prototype.CardLogin = function() { // 卡密登录
if (!this._card) {
return {"code": -4, "message": "请先设置卡密"};
}
let method = "POST";
let path = "/v1/card/login";
let data = {"card": this._card, "device_id": this._device_id};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this._token = ret.result.token;
this.login_result = ret.result;
if (this._auto_heartbeat) {
this._startCardHeartbeat();
}
}
return ret;
}
PJYSDK.prototype.CardHeartbeat = function() { // 卡密心跳,默认会自动调用
if (!this._token) {
return {"code": -2, "message": "请在卡密登录成功后调用"};
}
let method = "POST";
let path = "/v1/card/heartbeat";
let data = {"card": this._card, "token": this._token};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.login_result.expires = ret.result.expires;
this.login_result.expires_ts = ret.result.expires_ts;
}
return ret;
}
PJYSDK.prototype._startCardHeartbeat = function() { // 开启卡密心跳任务
if (this._heartbeat_task) {
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
this._heartbeat_task = threads.start(function(){
setInterval(function(){}, 10000);
});
this._heartbeat_ret = this.CardHeartbeat();
this._heartbeat_task.setInterval((self) => {
self._heartbeat_ret = self.CardHeartbeat();
if (self._heartbeat_ret.code != 0) {
self.event.emit("heartbeat_failed", self._heartbeat_ret);
}
}, this._heartbeat_gap, this);
this._heartbeat_task.setInterval((self) => {
if (self.GetTimeRemaining() == 0) {
self.event.emit("heartbeat_failed", {"code": 10210, "message": "卡密已过期!"});
}
}, 1000, this);
}
PJYSDK.prototype.CardLogout = function() { // 卡密退出登录
this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};
if (this._heartbeat_task) { // 结束心跳任务
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
if (!this._token) {
return {"code": 0, "message": "OK"};
}
let method = "POST";
let path = "/v1/card/logout";
let data = {"card": this._card, "token": this._token};
let ret = this.Request(method, path, data);
// 清理
this._token = null;
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
return ret;
}
PJYSDK.prototype.CardUnbindDevice = function() { // 卡密解绑设备,需开发者后台配置
if (!this._token) {
return {"code": -2, "message": "请在卡密登录成功后调用"};
}
let method = "POST";
let path = "/v1/card/unbind_device";
let data = {"card": this._card, "device_id": this._device_id, "token": this._token};
return this.Request(method, path, data);
}
PJYSDK.prototype.SetCardUnbindPassword = function(password) { // 自定义设置解绑密码
if (!this._token) {
return {"code": -2, "message": "请在卡密登录成功后调用"};
}
let method = "POST";
let path = "/v1/card/unbind_password";
let data = {"card": this._card, "password": password, "token": this._token};
return this.Request(method, path, data);
}
PJYSDK.prototype.CardUnbindDeviceByPassword = function(password) { // 用户通过解绑密码解绑设备
let method = "POST";
let path = "/v1/card/unbind_device/by_password";
let data = {"card": this._card, "password": password};
return this.Request(method, path, data);
}
PJYSDK.prototype.CardRecharge = function(card, use_card) { // 以卡充卡
let method = "POST";
let path = "/v1/card/recharge";
let data = {"card": card, "use_card": use_card};
return this.Request(method, path, data);
}
/* 用户相关 */
PJYSDK.prototype.UserRegister = function(username, password, card) { // 用户注册(通过卡密)
let method = "POST";
let path = "/v1/user/register";
let data = {"username": username, "password": password, "card": card, "device_id": this._device_id};
return this.Request(method, path, data);
}
PJYSDK.prototype.UserLogin = function() { // 用户账号登录
if (!this._username || !this._password) {
return {"code": -4, "message": "请先设置用户账号密码"};
}
let method = "POST";
let path = "/v1/user/login";
let data = {"username": this._username, "password": this._password, "device_id": this._device_id};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this._token = ret.result.token;
this.login_result = ret.result;
if (this._auto_heartbeat) {
this._startUserHeartbeat();
}
}
return ret;
}
PJYSDK.prototype.UserHeartbeat = function() { // 用户心跳,默认会自动开启
if (!this._token) {
return {"code": -2, "message": "请在用户登录成功后调用"};
}
let method = "POST";
let path = "/v1/user/heartbeat";
let data = {"username": this._username, "token": this._token};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.login_result.expires = ret.result.expires;
this.login_result.expires_ts = ret.result.expires_ts;
}
return ret;
}
PJYSDK.prototype._startUserHeartbeat = function() { // 开启用户心跳任务
if (this._heartbeat_task) {
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
this._heartbeat_task = threads.start(function(){
setInterval(function(){}, 10000);
});
this._heartbeat_ret = this.UserHeartbeat();
this._heartbeat_task.setInterval((self) => {
self._heartbeat_ret = self.UserHeartbeat();
if (self._heartbeat_ret.code != 0) {
self.event.emit("heartbeat_failed", self._heartbeat_ret);
}
}, this._heartbeat_gap, this);
this._heartbeat_task.setInterval((self) => {
if (self.GetTimeRemaining() == 0) {
self.event.emit("heartbeat_failed", {"code": 10250, "message": "用户已到期!"});
}
}, 1000, this);
}
PJYSDK.prototype.UserLogout = function() { // 用户退出登录
this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};
if (this._heartbeat_task) { // 结束心跳任务
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
if (!this._token) {
return {"code": 0, "message": "OK"};
}
let method = "POST";
let path = "/v1/user/logout";
let data = {"username": this._username, "token": this._token};
let ret = this.Request(method, path, data);
// 清理
this._token = null;
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
return ret;
}
PJYSDK.prototype.UserChangePassword = function(username, password, new_password) { // 用户修改密码
let method = "POST";
let path = "/v1/user/password";
let data = {"username": username, "password": password, "new_password": new_password};
return this.Request(method, path, data);
}
PJYSDK.prototype.UserRecharge = function(username, card) { // 用户通过卡密充值
let method = "POST";
let path = "/v1/user/recharge";
let data = {"username": username, "card": card};
return this.Request(method, path, data);
}
PJYSDK.prototype.UserUnbindDevice = function() { // 用户解绑设备,需开发者后台配置
if (!this._token) {
return {"code": -2, "message": "请在用户登录成功后调用"};
}
let method = "POST";
let path = "/v1/user/unbind_device";
let data = {"username": this._username, "device_id": this._device_id, "token": this._token};
return this.Request(method, path, data);
}
/* 配置相关 */
PJYSDK.prototype.GetCardConfig = function() { // 获取卡密配置
let method = "GET";
let path = "/v1/card/config";
let data = {"card": this._card};
return this.Request(method, path, data);
}
PJYSDK.prototype.UpdateCardConfig = function(config) { // 更新卡密配置
let method = "POST";
let path = "/v1/card/config";
let data = {"card": this._card, "config": config};
return this.Request(method, path, data);
}
PJYSDK.prototype.GetUserConfig = function() { // 获取用户配置
let method = "GET";
let path = "/v1/user/config";
let data = {"user": this._username};
return this.Request(method, path, data);
}
PJYSDK.prototype.UpdateUserConfig = function(config) { // 更新用户配置
let method = "POST";
let path = "/v1/user/config";
let data = {"username": this._username, "config": config};
return this.Request(method, path, data);
}
/* 软件相关 */
PJYSDK.prototype.GetSoftwareConfig = function() { // 获取软件配置
let method = "GET";
let path = "/v1/software/config";
return this.Request(method, path, {});
}
PJYSDK.prototype.GetSoftwareNotice = function() { // 获取软件通知
let method = "GET";
let path = "/v1/software/notice";
return this.Request(method, path, {});
}
PJYSDK.prototype.GetSoftwareLatestVersion = function(current_ver) { // 获取软件最新版本
let method = "GET";
let path = "/v1/software/latest_ver";
let data = {"version": current_ver};
return this.Request(method, path, data);
}
/* 试用功能 */
PJYSDK.prototype.TrialLogin = function() { // 试用登录
let method = "POST";
let path = "/v1/trial/login";
let data = {"device_id": this._device_id};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.is_trial = true;
this.login_result = ret.result;
if (this._auto_heartbeat) {
this._startTrialHeartbeat();
}
}
return ret;
}
PJYSDK.prototype.TrialHeartbeat = function() { // 试用心跳,默认会自动调用
let method = "POST";
let path = "/v1/trial/heartbeat";
let data = {"device_id": this._device_id};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.login_result.expires = ret.result.expires;
this.login_result.expires_ts = ret.result.expires_ts;
}
return ret;
}
PJYSDK.prototype._startTrialHeartbeat = function() { // 开启试用心跳任务
if (this._heartbeat_task) {
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
this._heartbeat_task = threads.start(function(){
setInterval(function(){}, 10000);
});
this._heartbeat_ret = this.TrialHeartbeat();
this._heartbeat_task.setInterval((self) => {
self._heartbeat_ret = self.TrialHeartbeat();
if (self._heartbeat_ret.code != 0) {
self.event.emit("heartbeat_failed", self._heartbeat_ret);
// vip = 1;
}
}, this._heartbeat_gap, this);
this._heartbeat_task.setInterval((self) => {
if (self.GetTimeRemaining() == 0) {vip=0;
self.event.emit("heartbeat_failed", {"code": 10407, "message": "试用已到期!"});
}else vip = 1; //toast("可以继续试用,请点击开始学习")}
}, 1000, this);
if(vip==1) toast("可以继续试用,请点击开始学习");
}
PJYSDK.prototype.TrialLogout = function() { // 试用退出登录,没有http请求,只是清理本地记录
this.is_trial = false;
this._heartbeat_ret = {"code": -9, "message": "还未开始验证"};
if (this._heartbeat_task) { // 结束心跳任务
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
// 清理
this._token = null;
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
return {"code": 0, "message": "OK"};
}
/* 高级功能 */
PJYSDK.prototype.GetRemoteVar = function(key) { // 获取远程变量
let method = "GET";
let path = "/v1/af/remote_var";
let data = {"key": key};
return this.Request(method, path, data);
}
PJYSDK.prototype.GetRemoteData = function(key) { // 获取远程数据
let method = "GET";
let path = "/v1/af/remote_data";
let data = {"key": key};
return this.Request(method, path, data);
}
PJYSDK.prototype.CreateRemoteData = function(key, value) { // 创建远程数据
let method = "POST";
let path = "/v1/af/remote_data";
let data = {"action": "create", "key": key, "value": value};
return this.Request(method, path, data);
}
PJYSDK.prototype.UpdateRemoteData = function(key, value) { // 修改远程数据
let method = "POST";
let path = "/v1/af/remote_data";
let data = {"action": "update", "key": key, "value": value};
return this.Request(method, path, data);
}
PJYSDK.prototype.DeleteRemoteData = function(key) { // 删除远程数据
let method = "POST";
let path = "/v1/af/remote_data";
let data = {"action": "delete", "key": key};
return this.Request(method, path, data);
}
PJYSDK.prototype.CallRemoteFunc = function(func_name, params) { // 执行远程函数
let method = "POST";
let path = "/v1/af/call_remote_func";
let ps = JSON.stringify(params);
let data = {"func_name": func_name, "params": ps};
let ret = this.Request(method, path, data);
if (ret.code == 0 && ret.result.return) {
ret.result = JSON.parse(ret.result.return);
}
return ret;
}
return PJYSDK;
})();
/* 将PJYSDK.js文件中的代码复制粘贴到上面 */
// AppKey 和 AppSecret 在泡椒云开发者后台获取
let pjysdk = new PJYSDK("cfh8he3dqusul232gs60", "vPlS2036kID2IkVDqzFPGiojS6p7WeTD");
pjysdk.debug = true;
var vip = 0;//VIP权限自由开关
var color = "#FF4FB3FF";
ui.statusBarColor("#FF4FB3FF")
ui.layout(
<drawer id="drawer">
<vertical>
<appbar>
<toolbar id="toolbar" bg="#ff4fb3ff" title="学习减压四合一PRO"/>
<tabs id="tabs" bg="#ff4fb3ff"/>
</appbar>
<viewpager id="viewpager">
<ScrollView>
<frame>
<vertical>
<vertical gravity="center" layout_weight="1">
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
<horizontal gravity="center_vertical">
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text text="脚本选择" textColor="#222222" textSize="16sp" maxLines="1" />
<text text="共4脚本可按需选择" textColor="#999999" textSize="12sp" maxLines="1" />
<text text="切换脚本后需在配置页设置" textColor="#999999" textSize="12sp" maxLines="1" />
<text text="(QG最新版)去截图权限版,需配合root或虚拟机等使用" textColor="#999999" textSize="10sp" maxLines="1" />
</vertical>
<spinner id="script_chosen" marginLeft="4" marginRight="6" entries="(QG最新版)去截图权限版|天天向上Pro|天天向上|Study改" />
</horizontal>
</card>
<card w="*" h="60" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
<horizontal gravity="center_vertical">
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text text="无障碍服务" textColor="#222222" textSize="16sp" maxLines="1" />
<text text="请确保开启" textColor="#999999" textSize="12sp" maxLines="1" />
</vertical>
<checkbox id="autoService" marginLeft="4" marginRight="6" checked="{{auto.service != null}}" />
</horizontal>
</card>
<card w="*" h="60" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
<horizontal gravity="center_vertical">
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text text="悬浮窗权限" textColor="#222222" textSize="16sp" maxLines="1" />
<text text="请确保开启" textColor="#999999" textSize="12sp" maxLines="1" />
</vertical>
<checkbox id="consoleshow" marginLeft="4" marginRight="6" checked="{{floaty.checkPermission()}}" />
</horizontal>
</card>
<card w="*" h="40" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
<horizontal gravity="center_vertical">
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text text="音量上键可以停止所有脚本运行" textColor="#222222" textSize="16sp" maxLines="1" />
</vertical>
</horizontal>
</card>
</vertical>
<vertical>
<horizontal>
<vertical>
{/* 脚本公告配置区域 */}
<vertical>
<text gravity='center' text='公告' w='*' h='auto' textSize='18sp' textColor='#ffffff' padding='10dp' bg='{{ui.主题颜色}}'></text>
<text padding='10dp' text='{{ui.启动赞助公告}}'></text>
<text w="auto" textColor="#999999" textSize="12sp" text=" 卡密用户先至上方'VIP卡密'栏--'绑定/保存卡密',再至'脚本配置'--'保存配置';---------首次须先点击下方'VIP登录',再点击'开始学习'-----以后脚本启动后只需直接点击'开始学习'即可" />
</vertical>
</vertical>
</horizontal>
</vertical>
<horizontal>
<button id="denglu_1" text="VIP登录" textSize="18sp" color="#ffffff" bg="#FF4FB3FF" layout_weight='1'></button>
<button h="50" layout_gravity="center" id="log" textSize="17sp" text="查看日志" ></button>
</horizontal>
<button h="60" layout_gravity="center" id="update" textSize="18sp" />
<button id="start" text="开 始 学 习" textSize="25sp" color="#ffffff" bg="#FF4FB3FF" foreground="?selectableItemBackground"/>
</vertical>
</frame>
</ScrollView>
<ScrollView>
<frame>
<vertical id="ttxs_pro" gravity="center">
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="看门狗(秒)" />
<text w="auto" textColor="#999999" textSize="12sp" text="填1800就是超过30分钟重试" />
<text w="auto" textColor="#999999" textSize="12sp" text="空着或0默认5400秒,超过即重新执行" />
</vertical>
<input id="ttxs_pro_watchdog" marginLeft="4" marginRight="6" text="1800" hint="秒" textSize="13sp" inputType="number" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="滑动验证的滑动时间(ms)" />
<text w="auto" textColor="#999999" textSize="12sp" text="空着或0不开启自动滑动验证,滑动分3段" />
<text w="auto" textColor="#999999" textSize="12sp" text="中间会折返一下,总时间是填的数值*3" />
<text w="auto" textColor="#999999" textSize="12sp" text="【新滑块验证--震动提醒,须手动完成】" />
</vertical>
<input id="ttxs_pro_slide_verify" marginLeft="4" marginRight="6" text="300" textSize="13sp" inputType="number" />
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="12sp" text="纯手动:有震动提醒但需要手动来完成" />
<text w="auto" textColor="#999999" textSize="12sp" text="自动+手动:随机自动滑,也可以手动来滑,并伴有震动提醒," />
<spinner id="ttxs_pro_slide_verify_on" marginLeft="4" marginRight="6" entries="纯手动|自动+手动" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="无障碍模式2" />
<text w="auto" textColor="#999999" textSize="12sp" text="无障碍服务没问题就不勾选" />
</vertical>
<checkbox id="ttxs_pro_fast_mode" marginLeft="4" marginRight="6" checked="false" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="点点通功能" />
</vertical>
<checkbox id="ttxs_pro_ddtong" marginLeft="4" marginRight="6" checked="false" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="开始前强制结束强国" />
<text w="auto" textColor="#999999" textSize="12sp" text="如果关闭,请确保强国已退出或在首页" />
</vertical>
<checkbox id="ttxs_pro_is_exit" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="评论" />
</vertical>
<checkbox id="ttxs_pro_pinglun" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="视听学习次数" />
</vertical>
<checkbox id="ttxs_pro_shipin" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="文章次数与时长" />
</vertical>
<checkbox id="ttxs_pro_wenzhang" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="每日答题" />
</vertical>
<checkbox id="ttxs_pro_meiri" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="每周答题(新版已弃,若已做完选不做)" />
<text w="auto" textColor="#999999" textSize="12sp" text="若有每周题目未做,可选" />
<spinner id="ttxs_pro_meizhou" marginLeft="4" marginRight="6" entries="最近一次已作答开始倒序|正序答题|不做" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="专项答题" />
<spinner id="ttxs_pro_zhuanxiang" marginLeft="4" marginRight="6" entries="最近一次已作答开始倒序|正序答题|不做" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="挑战答题" />
</vertical>
<checkbox id="ttxs_pro_tiaozhan" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="OCR选择" />
<spinner id="ttxs_pro_ocr_choice" marginLeft="4" marginRight="6" entries="GoogleMLKit|PaddleOCR|第三方插件" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="ocr识别跳过阈值(ms)" />
<text w="auto" textColor="#999999" textSize="12sp" text="空着或0默认5000,超过此时间会跳过多人对战" />
<text w="auto" textColor="#999999" textSize="12sp" text="建议按照平时正常的ocr识别时间设置" />
</vertical>
<input id="ttxs_pro_ocr_maxtime" marginLeft="4" marginRight="6" text="5000" textSize="13sp" inputType="number" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="对战选项模式" />
<spinner id="ttxs_pro_duizhan_mode" marginLeft="4" marginRight="6" entries="随机顺序(等选项显示后识别答案)|固定顺序(历史遗留选项)|手动答题(识别答案后等待用户手动点击)" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="对战极速模式延迟(历史遗留选项)" />
<text w="auto" textColor="#999999" textSize="12sp" text="只在选项固定顺序时生效" />
</vertical>
<input id="ttxs_pro_jisu" marginLeft="4" marginRight="6" text="0" textSize="13sp" inputType="number" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="是否挂机跳过四人赛首局" />
<text w="auto" textColor="#999999" textSize="12sp" text="首局匹配对手较强,挂机不会扣积分局数" />
</vertical>
<checkbox id="ttxs_pro_guaji" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="四人赛" />
</vertical>
<checkbox id="ttxs_pro_siren" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="平衡胜率(答错)次数" />
</vertical>
<input id="ttxs_pro_dacuo_num" marginLeft="4" marginRight="6" text="2" textSize="13sp" inputType="number" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="双人对战" />
</vertical>
<checkbox id="ttxs_pro_shuangren" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="本地" />
</vertical>
<checkbox id="ttxs_pro_bendi" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="运动" />
<text w="auto" textColor="#999999" textSize="12sp" text="没问题者不用选,仅为不点击查看不计运动步数而设,首次需要手动查看" />
</vertical>
<checkbox id="ttxs_pro_yundong" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="订阅" />
<text w="auto" textColor="#999999" textSize="12sp" text="若已root或虚拟机等去除截图限制的参照()内容选择,QG旧版的忽略()内容" />
<spinner id="ttxs_pro_dingyue" marginLeft="4" marginRight="6" entries="不做|正序订阅(若已去限制--表示遍历搜索‘强国号’,较费时)|只订阅年度上新(若已去限制--表示只看‘上新或2023年上线’)" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="pushplus_token(微信推送)开关" />
<text w="auto" textColor="#999999" textSize="12sp" text="选推送,需要勾选并填写下方token" />
</vertical>
<checkbox id="ttxs_pro_kaiguan" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="pushplus_token(微信推送)" />
<text w="auto" textColor="#999999" textSize="12sp" text="微信关注pushplus推送加,复制token填入" />
<text w="auto" textColor="#999999" textSize="12sp" text="注意!搜索结果有两个,一定要关注正确" />
<input id="ttxs_pro_pushplus" text="" textSize="13sp" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="是否启用音量调节" />
<text w="auto" textColor="#999999" textSize="12sp" text="每次运行脚本后调节音量百分比" />
</vertical>
<checkbox id="ttxs_pro_yl_on" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="音量" />
<text w="auto" textColor="#999999" textSize="12sp" text="调节音量百分比(只填数字)" />
</vertical>
<input id="ttxs_pro_yinliang" marginLeft="4" marginRight="6" text="0" textSize="13sp" inputType="number" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="多账号(仅支持VIP卡密用户。选填,不限个数)" />
<text w="auto" textColor="#999999" textSize="12sp" text="使用前确保所有账号都已完成短信验证" />
<text w="auto" textColor="#999999" textSize="12sp" text="账号1:密码1:token1(换行/回车)账号2:密码2:token2(换行/回车)账号3:密码3:token3" />
<text w="auto" textColor="#999999" textSize="10sp" text=" [例]13xxxxxxxxx:12xxxx(换行/回车后下一组)" />
<text w="auto" textColor="#999999" textSize="12sp" text="结束后会自动登录回账号1" />
<text w="auto" textColor="#999999" textSize="12sp" text="新增多账号1对1微信推送,按格式配置即可" />
<text w="auto" textColor="#999999" textSize="12sp" text="没有则根据上面配置的pushplus_token为主" />
<text w="auto" textColor="#999999" textSize="10sp" text="(已登录的不用重复填写。开多账号,建议尽量关闭qg软件的所有权限,尽量减少上传手机信息)" />
<input id="ttxs_pro_zhanghao" text="" textSize="13sp" />
</vertical>
</horizontal>
<horizontal>
<button style="Widget.AppCompat.Button.Colored" id="ttxs_pro_save" text="保存配置" padding="12dp" w="*" />
</horizontal>
<horizontal>
<button style="Widget.AppCompat.Button.Colored" id="ttxs_pro_reset" text="恢复默认" padding="12dp" w="*" />
</horizontal>
</vertical>
<vertical id="ttxs" gravity="center">
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="测试" />
</vertical>
<checkbox id="test_article1" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
</vertical>
<vertical id="study" gravity="center">
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="文章学习和广播收听" />
</vertical>
<checkbox id="study_article" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="视频学习" />
<spinner id="study_video" marginLeft="4" marginRight="6" entries="新百灵视频学习|看电视视频学习|百灵视频学习|不进行学习" />
</vertical>
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="每日答题" />
</vertical>
<checkbox id="study_meiri" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="挑战答题" />
</vertical>
<checkbox id="study_tiaozhan" marginLeft="4" marginRight="6" checked="true" />
</horizontal>
<horizontal gravity="center_vertical" padding="5 5" >
<View bg="#00BFFF" h="*" w="10" ></View>
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text w="auto" textColor="#222222" textSize="15sp" text="专项答题" />
<text w="auto" textColor="#999999" textSize="12sp" text="建议手动答题,否则不保证全对" />