-
Notifications
You must be signed in to change notification settings - Fork 1
/
10.js
1318 lines (1239 loc) · 46.3 KB
/
10.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
auto.waitFor(); //mode = "fast"
var delay_time = 3000;
var myScores = {}; //分数
device.wakeUpIfNeeded();
var meizhou_0 = true;
var meizhou_end = 1;
// 读取自定义配置
var BH_KAMI_CONFIG = storages.create("BH_KAMI_CONFIG");
var TTXS_PRO_CONFIG = storages.create("TTXS_PRO_CONFIG");
var watchdog = TTXS_PRO_CONFIG.get("watchdog", "1800");
var slide_verify = TTXS_PRO_CONFIG.get("slide_verify", "300");
var fast_mode = TTXS_PRO_CONFIG.get("fast_mode", false);
var ddtong = TTXS_PRO_CONFIG.get("ddtong", false);
var weixin_kaiguan = TTXS_PRO_CONFIG.get("weixin_kaiguan", true);
var is_exit = TTXS_PRO_CONFIG.get("is_exit", true);
var pinglun = TTXS_PRO_CONFIG.get("pinglun", true);
var shipin = TTXS_PRO_CONFIG.get("shipin", true);
var wenzhang = TTXS_PRO_CONFIG.get("wenzhang", true);
var meiri = TTXS_PRO_CONFIG.get("meiri", true);
var meizhou = TTXS_PRO_CONFIG.get("meizhou", 0);
var zhuanxiang = TTXS_PRO_CONFIG.get("zhuanxiang", 0);
var tiaozhan = TTXS_PRO_CONFIG.get("tiaozhan", true);
var ocr_choice = TTXS_PRO_CONFIG.get("ocr_choice", 0);
var ocr_maxtime = TTXS_PRO_CONFIG.get("ocr_maxtime", "5000");
var duizhan_mode = TTXS_PRO_CONFIG.get("duizhan_mode", 0);
var jisu = TTXS_PRO_CONFIG.get("jisu", "0");
var guaji = TTXS_PRO_CONFIG.get("guaji", true);
var siren = TTXS_PRO_CONFIG.get("siren", true);
var dacuo_num = TTXS_PRO_CONFIG.get("dacuo_num", "2");
var shuangren = TTXS_PRO_CONFIG.get("shuangren", true);
var bendi = TTXS_PRO_CONFIG.get("bendi", true);
var yundong = TTXS_PRO_CONFIG.get("yundong", true);
var dingyue = TTXS_PRO_CONFIG.get("dingyue", 0);
var pushplus = TTXS_PRO_CONFIG.get("pushplus", "");
var yl_on = TTXS_PRO_CONFIG.get("yl_on", true);
var yinliang = TTXS_PRO_CONFIG.get("yinliang", "0");
var zhanghao = TTXS_PRO_CONFIG.get("zhanghao", "");
var vip = BH_KAMI_CONFIG.get("bh_kami", "");
var isPrivateModes = getVersion("cn.xuexi.android").match(/[0-9][0-9]*/g).join('');
var isPrivateMode_1 = isPrivateModes-2380;
var privateModeStartVersion = "2.39.0";
var isPrivateMode = version1GreaterVersion2(getVersion("cn.xuexi.android"), privateModeStartVersion);
function getVersion(package_name) {
// 该函数来源:https://blog.csdn.net/aa490791706/article/details/122863666
let pkgs = context.getPackageManager().getInstalledPackages(0).toArray();
for (let i in pkgs) {
if (pkgs[i].packageName.toString() === package_name) {
return pkgs[i].versionName;
}
}
}
function version1GreaterVersion2(version1, version2, equal) {
// 该函数来源:https://blog.csdn.net/aa490791706/article/details/122863666
if (equal && version1 === version2) {
return true;
}
let versionArr1 = version1.split('.');
let versionArr2 = version2.split('.');
let result = false;
for (var i = 0; i < versionArr1.length; i++) {
if (versionArr1[i] > versionArr2[i]) {
result = true;
break;
}
}
return result;
}
//(找)图片点击
var url_xuexijifen_jpg = 'https://ghproxy.com/https://github.com/01buluo/zuguo/blob/main/xuexijifen_jpg.jpg'
var url_xuexijifen_1_jpg = 'https://ghproxy.com/https://github.com/01buluo/zuguo/blob/main/xuexijifen_1_jpg.jpg'
var path_xuexijifen_jpg = '/sdcard/xuexijifen_jpg.jpg'; //学习积分---qg2.39图标位置
var path_xuexijifen_1_jpg = '/sdcard/xuexijifen_1_jpg.jpg'; //学习积分---qg2.43/2.44图标位置
// var path_jpg_2 = '/sdcard/2022_shangxian.jpg'; //2022上线--图片位置
// var path_jpg_3 = '/sdcard/2022_shangxian_end.jpg';//2022上线最新更新图标位置
// var path_jpg_4 = '/sdcard/shangxin_1.jpg';//最近上线--图片位置
function pic_click(path_jpg_y, url_jpg_y, x_1, x_2){
if(!files.exists(path_jpg_y)) {
fClear();
fInfo('重要点击参数不存在,准备下载,若此次报错无法运行,不要勾选订阅重新运行脚本');
var img_small = images.load(url_jpg_y);
sleep(3000);
//保存图片 这一步保存完图片后,相册里不会显示图片
images.save(img_small, path_xuexijifen_jpg);
}
setScreenMetrics(1080, 1920);
sleep(1000);
if(files.exists(path_jpg_y)) fInfo('找到本地文文本点击参考');
var path_jpg_x = 0;
//requestScreenCapture();
// while (true && path_jpg_x != 2){
for(let i = 0; i < 6; i++){
fClear();
setScreenMetrics(1080, 1920);
let img_small_t = images.read(path_jpg_y);
let img_big_t = captureScreen();
// let result_0 = images.matchTemplate(img_big_t, img_small_t, {
// // threshold: 0.8,
// // region:[400, 1100, 100, 550],
// max: 2
// });
// fInfo(result_0);
sleep(2000);
// var pic_0 = images.findMultiColors(img_big_t, "#ffa837a", [[11, 20, "#ffff978f"], [10, 36, "#fffffff"], [1, -42, "#fffffff"], [-2, 109, "#fffffff"], [-42, 96, "#fffffff"], [-58, 15, "#ffe73426"], [-18, 13, "#fff57066"]], {
// region: [400, 1100, 100, 550]
// });
var pic_0 = findImage(img_big_t, img_small_t);
// var pic_0 = findImage(img_big_t, img_small_t, {
// region: [400, 1100, 100, 550],
// threshold: 0.8
// });
sleep(2000);
if (pic_0) {
fInfo("'学习积分'---找到了,坐标:" + pic_0.x+"----" + pic_0.y);
click(pic_0.x + x_1, pic_0.y + x_2);
press(pic_0.x + x_1, pic_0.y + x_2 ,100);//点击坐标
//click(pic_0.x + x_1, pic_0.y + x_2);
path_jpg_x = 2;
break;
} else {
img_big_t.recycle();
if(textContains("学习积分").exists()) break;
path_jpg_x = 0;
fInfo("继续尝试点击--‘学习积分’");
sleep(random(700, 1100));
}
}
}
function google_ocr_api(img) {
console.log('GoogleMLKit文字识别中');
let list = JSON.parse(JSON.stringify(gmlkit.ocr(img, "zh").toArray(3))); // 识别文字,并得到results
let eps = 30; // 坐标误差
for (
var i = 0; i < list.length; i++ // 选择排序对上下排序,复杂度O(N²)但一般list的长度较短只需几十次运算
) {
for (var j = i + 1; j < list.length; j++) {
if (list[i]['bounds']['bottom'] > list[j]['bounds']['bottom']) {
var tmp = list[i];
list[i] = list[j];
list[j] = tmp;
}
}
}
for (
var i = 0; i < list.length; i++ // 在上下排序完成后,进行左右排序
) {
for (var j = i + 1; j < list.length; j++) {
// 由于上下坐标并不绝对,采用误差eps
if (
Math.abs(list[i]['bounds']['bottom'] - list[j]['bounds']['bottom']) <
eps &&
list[i]['bounds']['left'] > list[j]['bounds']['left']
) {
var tmp = list[i];
list[i] = list[j];
list[j] = tmp;
}
}
}
let res = '';
for (var i = 0; i < list.length; i++) {
res += list[i]['text'];
}
list = null;
return res;
}
function paddle_ocr_api() {
console.log('PaddleOCR文字识别中');
let list = JSON.parse(JSON.stringify(paddle.ocr(arguments[0]))); // 识别文字,并得到results
let eps = 30; // 坐标误差
if (arguments.length >= 2) eps = arguments[1];
for (
var i = 0; i < list.length; i++ // 选择排序对上下排序,复杂度O(N²)但一般list的长度较短只需几十次运算
) {
for (var j = i + 1; j < list.length; j++) {
if (list[i]['bounds']['bottom'] > list[j]['bounds']['bottom']) {
var tmp = list[i];
list[i] = list[j];
list[j] = tmp;
}
}
}
for (
var i = 0; i < list.length; i++ // 在上下排序完成后,进行左右排序
) {
for (var j = i + 1; j < list.length; j++) {
// 由于上下坐标并不绝对,采用误差eps
if (
Math.abs(list[i]['bounds']['bottom'] - list[j]['bounds']['bottom']) <
eps &&
list[i]['bounds']['left'] > list[j]['bounds']['left']
) {
var tmp = list[i];
list[i] = list[j];
list[j] = tmp;
}
}
}
let res = '';
for (var i = 0; i < list.length; i++) {
res += list[i]['text'];
}
list = null;
return res;
}
if (fast_mode) {
auto.setMode("fast");
}
events.observeToast();
sleep(delay_time);
/*****************更新内容弹窗部分*****************/
var storage = storages.create('songgedodo');
// 脚本版本号
var last_version = "V10.11";
var engine_version = "V11.2";
var newest_version = "V11.5";
if (storage.get(engine_version, true)) {
storage.remove(last_version);
let gengxin_rows = ["最新版本强国APP需要虚拟机或者root【请确保手机已root或使用的虚拟机+相应插件】",
"四人/双人赛等才能使用!(并新增支持qg新版的订阅)",
"其它版本的脚本仅适用qg V2.33版,可以在豌豆荚中下载历史版本",
"(点击取消不再提示)"
];
let is_show = confirm(engine_version + "版更新内容", gengxin_rows.join("\n"));
if (!is_show) {
storage.put(engine_version, false);
}
}
var w = fInit();
// console.setTitle("学习减压四合一");
// console.show();
fInfo("学习减压四合一Pro" + newest_version + "\n……脚本初始化……");
fTips('当前强国版本为' + getVersion("cn.xuexi.android") + '(' + isPrivateModes + ')');
if(isPrivateMode_1 > 0 || isPrivateMode) fError('须去除截图限制权限,四人/双人赛等才可用ocr自动答题');
// 初始化宽高
var [device_w, device_h] = init_wh();
// log("fina:", device_w, device_h);
// OCR初始化,重写内置OCR module
if (ocr_choice == 2) {
fInfo("初始化第三方ocr插件");
try {
ocr = plugins.load("com.hraps.ocr");
ocr.recognizeText = function (img) {
let results = this.detect(img.getBitmap(), 1);
let all_txt = "";
for (let i = 0; i < results.size(); i++) {
let re = results.get(i);
all_txt += re.text;
}
return all_txt
}
} catch (e) {
fError("未安装第三方OCR插件,请安装后重新运行");
alert("未安装第三方OCR插件,点击确认跳转浏览器下载,密码为ttxs");
app.openUrl("https://wwc.lanzouo.com/ikILs001d0wh");
exit();
}
}
// sleep(2000);
// 自动允许权限进程
threads.start(function () {
//在新线程执行的代码
//sleep(500);
toastLog("开始自动获取截图权限");
var btn = className("android.widget.Button").textMatches(/允许|立即开始|START NOW/).findOne(5000);
if (btn) {
sleep(1000);
btn.click();
}
toastLog("结束获取截图权限");
});
fInfo("请求截图权限");
// 请求截图权限、似乎请求两次会失效
if (!requestScreenCapture(false)) { // false为竖屏方向
fError('请求截图失败');
exit();
}
// 防止设备息屏
fInfo("设置屏幕常亮");
device.keepScreenOn(3600 * 1000);
// 下载题库
fInfo("检测题库更新");
auto.waitFor();
//从配置文件中,根据name获取参数值
const { group_name,run_type } = hamibot.env;
var weixin_push = hamibot.env.weixin_push;
var maoyun_draw_1 = hamibot.env.maoyun_draw_1;
var no_2 = hamibot.env.no_2;
var no_3 = hamibot.env.no_3;
var suiji_1 = hamibot.env.suiji_1;
var { id_group_name } = hamibot.env;
device.wakeUp();//唤醒设备
sleep(2000); // 等待屏幕亮起
device.wakeUpIfNeeded();
// if (!device.isScreenOn()) {
// //从息屏状态 将屏幕唤醒
// device.wakeUp();//唤醒设备
// sleep(2000); // 等待屏幕亮起
// swipe(random(device.width / 3, device.width / 2), random(device.height * 8 / 10, device.height * 7 / 10), random(device.width / 3, device.width / 2), random(device.height * 2 / 10, device.height / 10), random(500, 1000));
// sleep(1000); //解锁
// desc(1).findOne().click();
// desc(2).findOne().click();
// desc(3).findOne().click();
// desc(4).findOne().click();
// }
//if (!device.isScreenOn()) {
sleep(random(1500,2000));
swipe(500,2000,500,1000,240);//可以
// }
if(suiji_1) delay(random(5, 600));
console.warn( " 产品厂商品牌:"+ device.brand + "\n设备型号:" + device.model+"\n Android 系统版本号:"+ device.release);
console.warn("设备的ID:" +device.getAndroidId()+ "\n MAC:"+ device.getMacAddress()+ "\n当前电量:"+ device.getBattery());
if(device.getBattery() < 30)console.error("当前电量:"+ device.getBattery());
else console.info("当前电量:"+ device.getBattery());
// console.warn("设备IMEI:"+ device.getIMEI());
// console.warn("\n Android 系统版本号:"+ device.release);
// console.warn("\n硬件序列号:" + device.serial);
// console.warn("设备IMEI:"+ device.getIMEI()+ "\n Android 系统版本号:"+ device.release + "\n硬件序列号:" + device.serial);
// console.warn("\n 产品厂商品牌:"+ device.brand);
// console.warn("\n设备型号:" + device.model);
// console.warn("设备的主板(?)型号:"+ device.broad);
//console.warn("设备的主板(?)型号:"+ device.broad + "\n 产品厂商品牌:"+ device.brand + "\n设备型号:" + device.model);
device.keepScreenDim()
/**
* @description: 延时函数
* @param: seconds-延迟秒数s
* @return: null
*/
function delay(seconds) {
sleep(1000 * seconds + randomNum(0, 500)); //sleep函数参数单位为毫秒所以乘1000
}
/**
* @description: 随机秒数
* @param: seconds-秒数s
* @return: [seconds+100,seconds+1000]
*/
function random_time(time) {
return time + random(100, 1000);
}
/**
* @description: 生成从minNum到maxNum的随机数
* @param: minNum-较小的数
* @param: maxNum-较大的数
* @return: null
*/
function randomNum(minNum, maxNum) {
switch (arguments.length) {
case 1:
return parseInt(Math.random() * minNum + 1, 10);
case 2:
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
default:
return 0;
}
}
//阻塞等待
function wait_come_home_page(){
//等待加载到主页
textContains('首页').waitFor();
textContains('云购').waitFor();
log("完全进入到主页")
}
//补充为2位数
function add0(m){
return m<10?'0'+m:m
}
//获取当天日期
function get_today(){
var myDate = new Date();
// return `${myDate.getFullYear()}-${myDate.getMonth()+1}-${myDate.getDate()}`
return myDate.getFullYear()+'-'+add0(myDate.getMonth()+1)+'-'+add0(myDate.getDate()+' '+add0("09:00场"))
}
//根据文本内容查找元素,并执行点击操作
function click_text_element(content,is_wait){
//是否需要等待
if(is_wait){
textContains(content).waitFor();
}
log("等待元素 ‘"+ content + "’ 加载完成,继续点击操作。。。")
//查找元素
var buy_element = text(content).findOne()
if(buy_element){
click(buy_element.bounds().centerX(), buy_element.bounds().centerY());
}
}
function click_desc_element(content,is_wait){
//是否需要等待
if(is_wait){
descContains(content).waitFor();
}
log("等待元素: ‘"+ content + "’ 加载完成,继续点击操作。。。")
//查找元素
var buy_element = desc(content).findOne()
if(buy_element){
click(buy_element.bounds().centerX(), buy_element.bounds().centerY());
}
}
/**
* 模拟点击不可以点击元素
* @param {UiObject / string} target 控件或者是控件文本
*/
function my_click_non_clickable(target) {
if (typeof target == "string") {
text(target).waitFor();
var tmp = text(target).findOne().bounds();
} else {
var tmp = target.bounds();
}
var randomX = random(tmp.left, tmp.right);
var randomY = random(tmp.top, tmp.bottom);
click(randomX, randomY);
}
/**
* 模拟点击可以点击元素
*/
function my_click_clickable(target) {
text(target).waitFor();
console.info('点击进入'+ target + '--');
click(target);
}
//遍历点击
function queryList_click(json,wenben_dj) {
for (var i = 0; i < json.length; i++) {
var sonList = json[i];
if (sonList.childCount() == 0) {
//console.log("---"+json[i]+"+++")
var b_coin = json[i].text()
// log("文本:"+b_coin)
if(b_coin== wenben_dj) {click(b_coin);console.info("点击"+ wenben_dj +"成功")
break;}
} else {
queryList_click(sonList);
}
}
//返回结果值
return b_coin
}
//遍历点击++遍历数
function queryList_click_num(json,num_dj) {
for (var i = 0; i < json.length; i++) {
var sonList = json[i];
if (sonList.childCount() == 0) {
//console.log("---"+json[i]+"+++")
var b_coin = json[i].text()
// log("文本:"+b_coin)
if(i== num_dj) {click(b_coin);console.info("点击"+ b_coin +"成功")
break;}
} else {
queryList_click_num(sonList);
}
}
//返回结果值
return b_coin
}
//进入到申购页面
function enter_buy_pre_page(){
click_text_element("云购")
delay(1);
my_click_clickable("享约申购")
}
//返回到应用首页
function back_main_page() {
//判断是否在主界面
while (true) {
if (textContains('首页').exists()&&textContains('云购').exists()&&textContains('发现').exists()&&textContains('小茅运').exists()&&textContains('我的').exists()) {
break;
} else {
back();
delay(1.5);
}
delay(2);
}
}
// push推送
function push_msg(send_msg){
console.warn('正在push推送……');
// var score = getScores(3);
send_msg +='\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n';
// try{
// if (sct_token != "") {
// URL = "https://sctapi.ftqq.com/" + sct_token + ".send";
// http.post(URL, {
// title: "申购反馈通知",
// desp: send_msg,
// });
// }
// }
// catch(e){}
// try{
let style_str = '<style>.item{height:1.5em;line-height:1.5em;}.item span{display:inline-block;padding-left:0.4em;}\
.item .bar{width:200px;height:10px;background-color:#ddd;border-radius:5px;display:inline-block;}\
.item .bar div{height:10px;background-color:#ed4e45;border-radius:5px;}</style>';
send_msg +='</div>' + style_str;
let r = http.postJson("http://www.pushplus.plus/send", {
token: hamibot.env.Token.replace(/ /g, ''),
title: "申购反馈:", // + name,
content: send_msg + "</div><style>.item{height:1.5em;line-height:1.5em;}.item span{display:inline-block;padding-left:0.4em;}.item .bar{width:200px;height:10px;background-color:#ddd;border-radius:5px;display:inline-block;}.item .bar div{height:10px;background-color:#ed4e45;border-radius:5px;}</style>",
template: "markdown",// "markdown" "html",
});
if (r.body.json()["code"] == 200) {
console.warn("推送成功");
} else {
log(r.body.json());
}
// url = 'http://www.pushplus.plus/send?token='+ hamibot.env.Token.replace(/ /g, '') +'&title=Study&content='+ send_msg +'&template=html';
// http.get(url);
// }catch(e){}
}
//返回到微信首页
function back_to_home(){
while(true){
back()
if(text("通讯录").findOne(3000)){
break
}else{
log("不满足,继续回退!")
}
}
}
function click_many_times(bounds,selector){
while(true){
//中心点坐标
var x = bounds.centerX();
var y = bounds.centerY();
var time = 100;
//点击一次(微信可能会失效,原因未知)
engines.execScript('xxx', '"auto";' + 'press(' + x + ', ' + y + ',' + time +');');
sleep(1000)
//判断元素是否出现
if(selector.findOnce()){
break
}
}
}
//发送微信消息
function send_wx_msg(send_msg){
//如果休眠,唤醒设备
//注意:为了保证耗电低,设置睡眠(30s无操作)
device.wakeUpIfNeeded()
app.launch("com.tencent.mm");
//微信分身
click_text_element("微信",is_wait=false)
text("微信").waitFor()
text("通讯录").waitFor()
sleep(2000)
swipe(450, 1500, 450, 450, 500)
//点击进入到聊天界面
var chat_element= id("id_group_name").text(group_name).findOne();
log("找到目标元素,可以点击了。。。。")
//log(chat_element)
//获取坐标点
var chat_element_bounds = chat_element.bounds();
click_many_times(chat_element_bounds,id("b4a").className("EditText"))
sleep(3000)
//1--发送消息
id("b4a").className("EditText").findOne().setText(send_msg)
sleep(3000)
//发送
text("发送").click()
sleep(1000)
//3- 返回
back_to_home()
}
//=========================================================
//查询申购结果
function get_buy_result(){
click_text_element("我的",is_wait=false)
// 获取用户名称
// username = desc("已实名").findOne().parent().children()[0]
// username = id("name_layout").findOne().parent().children()[0]
username= className("android.widget.TextView").depth(13).findOne(0).text();
click_text_element("申购单",is_wait=true)
//获取所有的item元素
var rv_element= id("reservation_rv").findOne()
//获取当前日期
var current = get_today();
console.log("当前日期:",current);
var current = current.replace(/-/g, '');
var current = current.substring(0,8).match(/[0-9][0-9]*/g);
// var current = parseInt(current.replace(/\s+/g, ''), 8);
// console.log("当前日期:",current);
//获取下面的所有子元素Item
let result = ""
if(rv_element){
var r_lt = 0;
var r_lt_z = 0;
var elements = rv_element.children()
for(let element of elements){
r_lt_z +=1;
};
for(let element of elements){
//获取预约时间
var time = element.findOne(id("date_time")).text()
var time_0 = element.findOne(id("date_time")).text()
//console.log("申购:",time)
var time = time.replace(/-/g, '');
var time = time.substring(0,10).match(/[0-9][0-9]*/g);
// var time = parseInt(time.replace(/\s+/g, ''), 8)
// console.log("申购:",time);
if(Number(time) == Number(current)){
//获取结果
var status =element.findOne(id("draw_status")).text()
//品种
var title = element.findOne(id("mt_goods_name")).text()
console.log("种类:",title,",结果:",status)
result += "\n\n " + " " + "\n\n种类:"+title+"," + "\n结果:"+status;
if(status == "申购失败" || status == "静候申购结果"){
var r_l_t = 0;
var r_l_t_s = "继续加油";
r_lt += 1;
}else {var r_l_t = r_lt_z;
var r_l_t_s = "幸运者";
}
let percent = (Number(r_l_t) / r_lt_z * 100).toFixed() + '%';
let detail = r_l_t_s + ": " + r_lt + "/" + r_lt_z;
result += '<div class="item"><div class="bar"><div style="width: ' + percent + ';"></div></div><span>' + detail + '</span></div>';
}
}
}
result = "\n\n" + "账号:" + username + "\n\n" + time_0 + "--申购结果:" + result;
//准备回退到App桌面
// back_main_page()
//进入到桌面
// home()
return result
}
//-----------------------------------------------------------------
//获取申购结果,并发送微信
function purchase_result(){
//打开日志控制台
console.show();
//打开App
launchApp('i茅台');
//进入主页
wait_come_home_page()
//点击进入申购页面
//enter_buy_pre_page()
//查询申购结果
var result_pre = get_buy_result()
var result = result_pre?result_pre:"查询结果为空"
var result = result_pre?result_pre:"查询结果为空"
if(maoyun_draw_1 == true){
var resultss = maoyun_draw();//领取或查询小茅运
var result = resultss + "\n\n" + result
}
//推送push
result_1 = "\n当前电量:"+ device.getBattery() + "\n\n" + device.brand + "--" + device.model+"--Android"+ device.release +"\n\n 设备的ID:" +device.getAndroidId()+ "\n\n MAC:"+ device.getMacAddress();
if(hamibot.env.Token != null && hamibot.env.Token.length > 6){
delay(random(0.7, 1));
push_msg(result_1 + result);
delay(random(4, 5));
}
//发送微信
if(weixin_push == true){
send_wx_msg(result_1 + result)
}
}
//真实预约
function real_buy(){
log("预约申购")
//等待【选择门店】页面加载完全
id("btReserve").waitFor()
//由于抢到即使赚到,这里直接取默认地址的第一个
my_click_non_clickable("申购");
//id("btReserve").click()
//确定申购
// text("确定").findOne().click()
delay(random(2, 3));
my_click_non_clickable("确定申购");
//text("确定申购").findOne().click()
delay(random(2, 3));
//点击【查看详情】,返回申购列表
// text("继续申购").findOne(3000).click();
//queryList_click(find(),"继续申购");
my_click_non_clickable("继续申购");
// if(textMatches("继续申购").exists() || text("继续申购").exists()) text("继续申购").findOne().click();
// else {text("查看详情").findOne().click();
// swipe(950, 1000, 750, 1000, 100);
// }
delay(1);
//返回
back_main_page();
}
//申购购买
function purchase_buy(){
console.show();
//打开App
launchApp('i茅台');
//等待进入到主页
wait_come_home_page()
//进入【云购】Tab
click_text_element("云购",is_wait=false)
// click_text_element("线上销售",is_wait=false)
my_click_clickable("享约申购");
delay(1);
my_click_clickable("享约申购");
// my_click_clickable("享约申购",is_wait=true)
//注意:可能屏幕太小,导致第一屏就没有购买入口
var good_enterences = id("bt_goods").find()
log("本次入口有:",good_enterences.length)
let index = 0;
var rukou = 0;
var wen_ts = "‘本场申购---已申购完毕";
// while(index<4){
//滑动一次
// if(!text('本场申购已结束').findOne(3000)){
// swipe(450, 1500, 450, 450, 500)}
//商品列表(预约申请的按钮)
var good_enterences = id("bt_goods").find()
// log("本次入口有:",good_enterences.length)
//商品标题
for(let good_enterence of good_enterences){
var rukou = rukou + 1;
log("入口"+rukou +":",good_enterence.text())
if(good_enterence.text()=='本场申购已结束'){
var wen_ts = "‘本场申购已结束’---明天“9:00场”再来";
console.info(wen_ts);
break;
}
else if(good_enterence.text()=='申购结果公示'){
var wen_ts = "‘申购结果公示’中---请去查询";
console.info(wen_ts);
break;
}
else if(good_enterence.text()=='09:00开始申购'){
var wen_ts = "‘09:00开始申购’中---明天“9:00场”再来";
console.info(wen_ts);
break;
}
else if(good_enterence.text()=='预约申购'){
// if(no_1&&rukou==1) continue;
if(no_2 && rukou==2) {console.info("已勾选不申请--1935");continue;}
if(no_3 && rukou==3) {console.info("已勾选不申请--贵州茅台酒(珍品)");continue;}
// if(no_4&&rukou==4) continue;
// my_click_non_clickable("预约申购");
good_enterence.click()
click("预约申购");
real_buy();
}else{
log("该条已经申购,过滤掉。。。")
}
}
// log("-----------------------------------------------------")
// index+=1;
// }
//滑回top
if(!(textContains('09:00开始申购').exists() || textContains('申购结果公示').exists() || textContains('本场申购已结束').exists())){swipe(550, 250, 450, 1800, 1000);
console.info(wen_ts);
console.info("申购完毕!");
log("准备查询/领取小茅运返回top")}
if(maoyun_draw_1 == true){
console.info("准备查询/领取小茅运")
toast("准备查询/领取小茅运")
var resultss = maoyun_draw();//领取或查询小茅运
var resultss = "\n当前电量:"+ device.getBattery() + "\n\n" + device.brand + "--" + device.model+"--Android"+ device.release +"\n\n" + "设备的ID:" + device.getAndroidId() + "\n"+ "MAC:"+ device.getMacAddress() +"\n\n" + resultss;
resultss = "\n\n" + wen_ts + "\n\n" + resultss;
} else {
var resultss = "\n当前电量:"+ device.getBattery() + "\n" + device.brand + "--" + device.model+"--Android"+ device.release +"\n\n" +"设备的ID:" +device.getAndroidId()+ "\n" + " MAC:"+ device.getMacAddress() +"\n\n" + resultss;
resultss = "\n\n" + wen_ts + "\n\n" + resultss;
}
//推送push
if(hamibot.env.Token != null && hamibot.env.Token.length > 6){
delay(random(0.7, 1));
push_msg(resultss);
delay(random(4, 5));
}
//发送微信
if(weixin_push == true){
send_wx_msg(resultss)
}
}
//领取小茅运
function maoyun_draw(){
// //打开App
// launchApp('i茅台');
// //等待进入到主页
// wait_come_home_page()
// //领取前查询【小茅运】Tab
back_main_page()
text("我的").waitFor()
//sleep(2000)
click_text_element("我的",is_wait=false);
delay(2);
text("我的订单").waitFor()
delay(2);
//查询小茅运
// var mubiaoshu = 1;//小茅运遍历1
var rooot = className("android.widget.TextView").depth(14).drawingOrder(3).indexInParent(2).enabled(true).find();
var a_coin = queryList_0(rooot,1);
toast("小茅运:" + a_coin);
log("小茅运:" + a_coin);
//查询耐力值
// var mubiaoshu = 2;//耐力值遍历2
// let rooot = className("android.widget.TextView").depth(14).drawingOrder(3).enabled(true).find()
var a_energy = queryList_0(rooot, 2);
log("耐力值:"+a_energy);
// toast("耐力值:"+a_energy)
var results = "领取前:小茅运 " + a_coin + " && " + "耐力值 " + a_energy;
console.info(results);
toast(results);
//获取所有的item元素
sleep(1000);
//return results
//进入【小茅运】Tab
log("点击小茅运");
delay(2);
click_text_element("首页",is_wait=false);
delay(2);
click_text_element("云购",is_wait=false);
delay(2);
back_main_page();
delay(1);
click_text_element("小茅运",is_wait=false);
delay(1);
// click_text_element("小茅运",is_wait=false)
toast("继续尝试进入探索领取中,等待…………")
delay(5);
var rooot_1 = className("android.widget.TextView").depth(18).find();
// if(!rooot_1){
// sleep(3000);
click_text_element("我的",is_wait=false);
delay(2);
click_text_element("云购",is_wait=false)
delay(2);
click_text_element("小茅运",is_wait=false)
delay(1); // }
//if(!rooot_1){
delay(3);
press(660, 600,100);
press(660, 600,150);
// click(660, 600);
//}
log('准备进入 日程');
// textContains('探索').waitFor();
queryList_click(find(),"领取");
var rooot_1 = className("android.widget.TextView").depth(18).find()
queryList_click_num(rooot_1,2);
delay(4);
// var maoyun_draw_s = className("android.view.View").find()
// var maoyun_draw_ss = className("android.widget.TextView").find()
//queryList_0(maoyun_draw_s,"领取");
queryList_click(find(),"领取");
// var maoyun0_draws = className("android.view.View").text("领取").find()
className("android.view.View").text("领取").find().click();
textContains('前往日程').waitFor();
click_text_element("前往日程",is_wait=false);
continued_draw();
// log("本次领取入口有:",maoyun0_draws.length)
// //商品标题
// for(let maoyun0_draw of maoyun0_draws){
// log("文本:",maoyun0_draw.text())
// if(maoyun0_draw.text()=='领取'){
// log("发现领取,领取中")
// maoyun0_draw.click()
// text("领取").findOne(1000).click()
// className("android.view.View").text("领取").find() .click()
// sleep(2)
// className("android.widget.TextView").text("领取").find() .click()
// text("领取").findOne(1000).click()
// toast("发现领取,领取成功")
// //back()
// //break
// }else{
// var maoyun1_draws = className("android.widget.TextView").text("你有新的奖励到啦").find()
// log("本次入口有:",maoyun1_draws.length)
// for(let maoyun1_draw of maoyun1_draws){
// log("文本:",maoyun1_draw.text())
// if(maoyun1_draw.text()=='你有新的奖励到啦'){
// log("发现领取,领取中")
// maoyun1_draw.click()
// text("领取").findOne(1000).click()
// className("android.view.View").text("领取").find() .click()
// sleep(2)
// className("android.widget.TextView").text("领取").find() .click()
// text("领取").findOne(1000).click()
// toast("发现领取,领取成功")
// //back()
// }else{
// toast("申购后首次尝试‘领取’无发现,继续尝试其它方式")
// log("申购后首次尝试‘领取’无发现,继续")
// }
// }
// }
// }
// delay(1);
// //查找7天连续申购领取小茅运
// back_main_page()
// toast("换种方式继续查找是否满足连续申购7天并领取,尽量确保领取")
// log("换种方式查找是否满足连续申购7天并领取")
// click_text_element("我的",is_wait=false)
// toast("继续尝试查找中,等待…………")
// delay(1);
// click_text_element("获取更多小茅运",is_wait=true)
// className("android.view.View").text("获取更多小茅运").find().click()
// //toast("继续尝试中,等待…………")
// className("android.view.View").text("领取").find() .click()
// sleep(2)
// className("android.view.View").text("领取").find() .click()
// delay(1);
// //toast("继续尝试查找中,等待…………")
// click_text_element("旅行",is_wait=false)
// delay(1.5);
// // toast("继续尝试查找中,等待…………")
// className("android.view.View").text("进去看看").find().click()
// //click_text_element("进去看看",is_wait=false)
// delay(1);
// //toast("继续尝试查找中,等待…………")
// className("android.view.View").text("我知道了").find().click()
// delay(1);
// className("android.view.View").text("领取奖励").find().click()
// className("android.widget.TextView").text("领取奖励").find().click()
// delay(1);
// className("android.view.View").text("我知道了").find().click()
// delay(1);
// className("android.widget.TextView").text("我知道了").find().click()
// //click_text_element("我知道了",is_wait=false)
// // toast("换种方式进入日程若仍然未进入,被盾,及时截图留言反馈!!等待后续版本更新")
// delay(1);
// className("android.widget.Image").text("1649814918149f13").find().click()
// sleep(2)
// className("android.widget.Image").text("1649814918149f13").find().click()
// sleep(2)
// className("android.widget.Image").text("1658819152389434").find().click()
// delay(1);
// bounds(45,456,198,621).depth(16).find().click()
// sleep(2)
// bounds(45,456,198,621).depth(16).find().click()
// sleep(2)
// bounds(41,429,181,580).depth(17).find().click()
// delay(1);
// className("android.widget.Image").text("16526814338009ec").find().click()
// sleep(2)
// className("android.widget.Image").text("16526814338009ec").find().click()
// delay(1);
// className("android.widget.Image").text("16501128103d4eef").find().click()
// sleep(2)
// className("android.widget.Image").text("16501128103d4eef").find().click()
// delay(1);
// click_text_element("申购领小茅运",is_wait=false)
// delay(1);
// var maoyun01_draws = className("android.view.View").text("申购领小茅运").find()
// // toast("继续尝试查找中,等待…………")
// //log("本次领取入口有:",maoyun01_draws.length)
// for(let maoyun01_draw of maoyun01_draws){
// log("文本:",maoyun01_draw.text())
// if(maoyun01_draw.text()==='申购领小茅运'){
// //toast("查找中")
// maoyun01_draw.click()
// }else{
// bounds(45,456,198,621).depth(16).find().click()
// delay(1);
// className("android.widget.Image").text("16526814338009ec").find().click()
// sleep(2)
// className("android.widget.Image").text("16526814338009ec").find().click()