-
Notifications
You must be signed in to change notification settings - Fork 1
/
0.js
4141 lines (4028 loc) · 151 KB
/
0.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 = {}; //分数
var myScores_1 = {}; //分数
var myScores_2 = {}; //分数
device.wakeUpIfNeeded();
var meizhou_0 = true;
var meizhou_end = 1;
var quweidati = false;
// 读取自定义配置
var w = fInit();
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 slide_verify_on = TTXS_PRO_CONFIG.get("slide_verify_on", 0);
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", 2);
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", false);
var siren = TTXS_PRO_CONFIG.get("siren", true);
var dacuo_num = TTXS_PRO_CONFIG.get("dacuo_num", "0");
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(random(2500, 3500));
btn.click();
}
toastLog("结束获取截图权限");
});
fInfo("请求截图权限");
// 请求截图权限、似乎请求两次会失效
if (!requestScreenCapture(false)) { // false为竖屏方向
fError('请求截图失败');
exit();
}
// 防止设备息屏
fInfo("设置屏幕常亮");
device.keepScreenOn(3600 * 1000);
// 下载题库
fInfo("检测题库更新");//https://fastly.jsdelivr.net/gh/OuO-dodo/tiku@master/info.json
const update_info = get_tiku_by_http("https://gitcode.net/m0_64980826/songge_tiku/-/raw/master/info.json");
//const update_info = get_tiku_by_http("https://gh.api.99988866.xyz/https://github.com/OuO-dodo/tiku/blob/master/info.json");
fInfo("稍等……");
//const update_info = get_tiku_by_http("https://ghproxy.com/https://github.com/OuO-dodo/tiku/blob/master/info.json");
if (!(update_info.statusCode >= 200 && update_info.statusCode < 300)){update_info = {
"dati_tiku_version" : 20230121,
"dati_tiku_link": "https://gitcode.net/m0_64980826/songge_tiku/-/raw/master/dati_tiku_20230121.txt",
"dati_tiku_link2": "https://raw.kgithub.com/OuO-dodo/tiku/master/dati_tiku_20230121.txt",
"tiku_version": 20230807,
"tiku_link": "https://gitcode.net/m0_64980826/songge_tiku/-/raw/master/tiku_json_20230807.txt",
"tiku_link2": "https://raw.kgithub.com/OuO-dodo/tiku/master/tiku_json_20230807.txt",
"question_reg": "魏晋时期|立春时节|投笔|永乐皇帝|古代建筑|志愿者|预警信号|公狮|七律长征|太阳的大气层|含氧量|国之大事|体育健身|三部著作|泓水之战|本土作物|甲肝|古代皇帝|古代社会|超流体|气囊中|一条鱼|生肖邮票|医学奖|痛风|台风根据|幽禽|以下水域|冷热病|古典文学|龙泉窑址|敌友|唇形科|江苏目前|绵白糖|预备党员",
"include_reg": "排水口|古代兵器|变脸|培大豆|节能减排|四岳|鸳鸯|子午觉|汉字产生|宇宙中|变声|血型|长征四号|标准文字|力量体制|原始农业",
"default_ocr_replace": {"\\+":"十"},
"old_ocr_replace": {"[闵阅]值":"阈值","[點赔精]然失色":"黯然失色","九雪云外":"九霄云外","不落[集案室][白自]":"不落窠臼"},
"accent_ocr_replace": {
"草营人":"草菅人","消[强洱]":"消弭","切[碟槎碳]":"切磋","并行不[停惊]?(?!背)":"并行不悖","[评呼]然心动":"怦然心动","[此吃北][陀吃呢]风云":"叱咤风云",
"chaiqian":"chāiqiǎn","浓意妄为":"恣意妄为","[厦魔]品":"赝品","九[^宵]?云外":"九霄云外","葱是生非":"惹是生非","言简意购":"言简意赅",
"[脸胎]炙人口":"脍炙人口","不落[^巢]?[白自]":"不落窠臼","针碗时[蜂摔辩]":"针砭时弊","[哆哔][唆峻]":"啰唆","既往不[答智]":"既往不咎","组拿":"缉拿",
"暖[陀跑]":"蹉跎","跨踏":"踌躇","调帐":"惆怅","[任仟]悔":"忏悔","快[寄密窑]":"诀窍","浙临":"濒临","底护":"庇护","抵悟":"抵牾","情懒":"慵懒",
"[泽溶]炼":"淬炼","博奔":"博弈","[疼痉]李":"痉挛","[凌演]合":"凑合","神抵":"神祗","发物":"发轫","声名[鸽韵]起":"声名鹊起","貂鲜":"貂蝉","b6":"bù",
"[悠慈]气":"憋气","[继绎伴]脚石":"绊脚石","河汉":"河汊","修营":"修葺","杯盘狼精":"杯盘狼藉","有特无恐":"有恃无恐","蒸[^溜]?水":"蒸馏水",
"嘴之以鼻":"嗤之以鼻","款收":"歉收","[链挺键]而走险":"铤而走险","[进母][康庸]置疑":"毋庸置疑","叫苦不[选送]":"叫苦不迭","追不及待":"迫不及待",
"相形见细":"相形见绌","饮鸽止渴":"饮鸩止渴","不[胜胚]而走":"不胫而走","[晖蹄]红":"蹿红","挑三栋四":"挑三拣四","沉酒":"沉湎","[忆恒]气":"怄气",
"跌[容岩]起伏":"跌宕起伏","声内":"声呐","蓝等充数":"滥竽充数","[驻姓]款":"赃款","差[造道]":"差遣","再接再历":"再接再厉","菱摩不振":"萎靡不振",
"喉声叹气":"唉声叹气","点.zhui":"点缀zhuì","寒暗":"寒暄","[组祖]击手":"狙击手","奴.?bi":"奴婢bì","矫.造作":"矫揉造作","巨壁":"巨擘",
".之若[跨鹭]":"趋之若鹜","白暴白弃":"自暴自弃","cuotu[od]":"cuōtuó","鞭答":"鞭笞","夏然而止":"戛然而止","[壁跨]浑水":"蹚浑水","鱼鲤":"鱼鳔",
"瓜熟带":"瓜熟蒂",
"粗[^矿]?(?!矿)":"粗犷","陷[^井]?(?!井)":"陷阱","古今杂[^揉]?(?!揉)":"古今杂糅",
"[^蟹董\\.]?伏":"蛰伏","[^阀\\.]?值":"阈值","[^暗\\.]?然失色":"黯然失色"
},
"other_ocr_replace": {
"[斐翡表]秀":"裴秀","何族":"侗族","从[我戒]":"从戎","朱捷":"朱棣","李诚":"李诫","\\+儿":"十八","黄色.橙色.红色":"黄色-橙色-红色","狐虎兽":"狮虎兽",
"五岭.乌蒙.金沙.+?山":"五岭、乌蒙、金沙、大渡、岷山","([a-d].?)光球层、?色球层.*?(?=[a-d].?|$)":"$1光球层、色球层、日冕层","动脉巾":"动脉血",
"[福祝][成戒]":"祀戎","准备活动.基本活动.放松活动":"准备活动-基本活动-放松活动","诗经\\W+?春秋\\W+?论语":"诗经-春秋-论语","宋囊公":"宋襄公","南稻北栗":"南稻北粟",
"娄.+?传播":"粪-口传播","([a-d].?)龙有.?五爪.*?四爪.?(?=[a-d].?|$)":"$1龙有“五爪”,蟒有“四爪”","令媛":"令嫒","液氨":"液氦","氨气":"氮气","鱼鲜":"鱼鳞",
"庚电年":"庚申年","青营素":"青蒿素","[嘎嘿漂][岭吟]":"嘌呤","热带风晶":"热带风暴","合风":"台风","婴武":"鹦鹉","潮海":"渤海","症疾":"疟疾","刘森思|刘想":"刘勰",
"蜜头":"窑头","嘎觉":"嗅觉","苦塞":"苦寒","游猴":"猕猴","藤糖":"蔗糖","捅讨":"通过"
},
"include_ocr_replace":{
"排水口":[["麒麟|鹿其"],"[蜗璃蝙]","螭"],"古代兵器":[["戈","矛"],"载","戟"],"变脸":[["京","豫"],"JI","川"],"培大豆":[["泰"],"[藏救]","菽"],
"节能减排":[["26","24","28"],"[^C]C","℃"],"四岳":[["舜","禹"],"解|鱼系","鲧"],"鸳鸯":[["爸","驾"],"驾","鸳"],"子午觉":[["23时","11时"],"一","—"],
"汉字产生":[["行书","楷书"],"小[豪拿蒙]","小篆"],"宇宙中":[["氧","碳"],"氨","氦"],"变声":[["氧气"],"氨气","氦气"],"血型":[["A型","B型"],"0","O"],
"长征四号":[["甲","丙"],"Z","乙"],"标准文字":[["隶书","金文"],"小[豪拿蒙]","小篆"],"力量体制":[["工","士"],"衣","农"],
"原始农业":[["豆","麦"],"[栗菜]","粟"]
}
}
};
//const update_info = get_tiku_by_http("https://gitcode.net/m0_64980826/songge_tiku/-/raw/master/info.json");
//const update_info = get_tiku_by_http("https://gitee.com/djh010/xuexiqiangguo-xxqg/blob/master/info.json");
fInfo("正在加载对战题库......请稍等\n题库版本:" + update_info["tiku_version"]);
fInfo("如果不动就是正在下载,多等会");
var tiku_link3 = "https://raw.kgithub.com/01buluo/zuguo/main/tiku_json_20230428.txt";
var dati_tiku_link3 = "https://raw.kgithub.com/01buluo/zuguo/main/dati_tiku_20230121.txt";
var tiku = [];
try {
tiku = get_tiku_by_http(update_info["tiku_link"]);
} catch (e) {
try {
tiku = get_tiku_by_http(update_info["tiku_link2"]);
} catch (e) {
tiku = get_tiku_by_http(update_info["tiku_link3"]);
}
}
// var tiku = get_tiku_by_gitee();
fInfo("正在加载专项题库......请稍等\n题库版本:" + update_info["dati_tiku_version"]);
var dati_tiku = [];
try {
dati_tiku = update_dati_tiku()
} catch (e) {
fError("网络原因未获取到在线题库,请尝试切换流量或者更换114DNS");
dati_tiku = get_tiku_by_ct('https://webapi.ctfile.com/get_file_url.php?uid=35157972&fid=555754562&file_chk=94c3c662ba28f583d2128a1eb9d78af4&app=0&acheck=2&rd=0.14725283060014105');
}
// 设置资源保存路径
files.createWithDirs("/sdcard/学习减压四合一/");
// 调整音量
if (yl_on) {
fInfo("设置媒体音量");
var yuan_yl = device.getMusicVolume();
var max_yl = device.getMusicMaxVolume();
let yl = Math.ceil(yinliang * max_yl / 100);
//log(yuan_yl, max_yl, yl, typeof yl);
device.setMusicVolume(yl);
fInfo("当前音量:" + device.getMusicVolume());
}
if (is_exit) {
fInfo("运行前重置学习APP");
exit_app("学习强国");
sleep(1500);
}
// 检测地理位置权限代码,出现就点掉
fInfo("开始位置权限弹窗检测");
var nolocate_thread = threads.start(function () {
//在新线程执行的代码
id("title_text").textContains("地理位置").waitFor();
fInfo("检测到位置权限弹窗");
sleep(1000);
text("暂不开启").findOne().click();
fInfo("已关闭定位");
});
fInfo("跳转学习APP");
// launch('cn.xuexi.android');
app.launchApp('学习强国');
var qg_guanbi_thread = qg_guanbi();
sleep(2000);
// console.hide();
// 命令行方式启动,似乎需要root
// var result_shell = shell("pm disable cn.xuexi.android");
// log(result_shell.code, result_shell.error);
/***************不要动****************
* **********************************
// 创建一个安卓动作,打开软件,此功能可以跳过开屏页,还在实验中
// app.startActivity({
// action: 'android.intent.action.VIEW',
// data: 'dtxuexi://appclient/page/study_feeds',
// packageName: 'cn.xuexi.android',
// });
* **********************************
*************************************/
function do_pinglun() {
// entry_jifen_project("发表观点");
entry_model(jifen_map["评论"]);
fSet("title", "评论…");
fClear();
if(text("亮点").findOne(2000)) text("亮点").findOne(2000).parent().parent().child(3).click();
my_click_non_clickable("主题教育");
if(text("主题教育").findOne()) text("主题教育").findOne().parent().parent().click();
else queryList_1(find(),"主题教育");
delay(2);
sleep(1000);
swipe(device_w / 2+random(-5, 6), device_h * 0.7+random(-7, 10), device_w / 2+random(-6, 6), device_h * 0.4+random(-4, 4), random(950, 1100));
id("general_card_title_id").findOne().parent().parent();
fInfo("尝试点击title:" + id("general_card_title_id").findOne().text());
// //log("文章click:", wen_box.click());
// while (!id("general_card_title_id").findOne().parent().parent().click()) {log("文章click: false");}
// log("文章click: true");
real_click(id("general_card_title_id").findOne().parent().parent());
log("等待加载");
idContains("image-text-content").waitFor();
let text_edit = text("欢迎发表你的观点");
log("查找评论框");
text_edit.waitFor();
sleep(random(1400, 1600));
swipe(device_w / 2 + random(-7, 9), device_h * 0.8 + random(-4, 8), device_w / 2 + random(-5, 5), device_h * 0.5+random(-10, 15), random(900, 1100));
while (text_edit.exists()) {
let pinglun_edit = text_edit.findOne(500);
fInfo("尝试点击评论框中");
log(pinglun_edit.click());
sleep(random(1400, 1600));
fRefocus();
}
fInfo("评论框click: true");
let content_list = ["全心全意为人民服务", "坚持学习,全心全意为人民服务","思想受礼,点赞","实事求是,不忘初心","不忘初心,牢记使命", "不忘初心,方得始终", "永远坚持党的领导","坚守一线,筑梦未来", "富强、民主、文明、和谐", "不忘初心,追梦,筑梦","自由,平等,公正,法治"];
classNameEndsWith("EditText").findOne().setText(content_list[random(0, content_list.length - 1)]);
sleep(random(1070, 1400));
text("发布").findOne().click();
sleep(random(1030, 1560));
text("删除").findOne().click();
sleep(random(700, 1100));
text("确认").findOne().click();
sleep(random(800, 1200));
// // 下面是分享
// for (let i=0; i<2; i++) {
// text_edit.findOne().parent().child(3).click();
// sleep(500);
// textContains("学习强国").findOne().parent().click();
// sleep(500);
// text("创建新的聊天").waitFor();
// sleep(1000);
// back();
// sleep(1000);
// }
// 回到首页
back();
// 返回积分页
jifen_init();
ran_sleep();
return true;
}
/********时长部分*********/
function do_shipin() {
// entry_jifen_project("视听学习");
entry_model(jifen_map["视频"]);
// jifen_list.child(jifen_map["视频"]).child(4).click();
if (ddtong) {
fSet("title", "视听(dd通)…");
} else {
fSet("title", "视听学习…");
}
fClear();
desc("百灵").findOne().click();
sleep(1000);
fInfo("检测温馨提示弹窗");
if (text("温馨提示").findOne(1500)) {
text("关闭").findOne().click();
fInfo("检测到温馨提示并已关闭");
}
desc("百灵").findOne().click();
let shu = text("竖").findOne();
fInfo("找到 竖")
shu.click();
sleep(1000);
// 定位到整个百灵frame_box
let frame_box = shu.parent().parent().parent().parent();
textMatches(/\d{2}:\d{2}/).waitFor();
let video_list = frame_box.findOne(className("android.widget.ListView"));
var v = className('android.widget.FrameLayout').clickable(true).depth(22).findOne().bounds();
press(v.centerX() + random(-7, 8), v.centerY()+ random(-7, 8) - 50, random(130, 188));
fInfo('点击视频');
sleep(2500);
//video_list.child(1).child(1).child(0).click();
text("分享").waitFor();
if (idContains("guide_view").findOne(1500)) {
fInfo("检测到引导遮罩");
sleep(random(900, 1100));
click(device_w / 2, device_h / 2);
sleep(random(900, 1200));
click(device_w / 2, device_h / 4);
}
sleep(800);
//log(text("刷新重试").exists());
textMatches(/刷新重试|继续播放/).exists() && (fInfo("检测到流量提醒"),
textMatches(/刷新重试|继续播放/).findOne().click());
sleep(random(1000, 1500));
if(textContains("刷新重试").exists()) {
console.error("检测到使用的手机流量,准备点击'刷新重试'");
var v = text("刷新重试").findOne().bounds();
press(v.centerX()+random(-1, 5), v.centerY() + random(-7, 8), random(120, 180));;
sleep(random(1000, 1500));
}
sleep(random(8000, 9500));
let re_times = 6;
if (ddtong) {
re_times += 6;
}
for (let i = 0; i < re_times; i++) {
click(device_w / 2 +random(-7, 8), device_h / 2 + random(-5, 6));
sleep(random(490, 560));
swipe(device_w / 2 + random(-7, 9), device_h * 0.8 + random(-4, 8), device_w / 2 + random(-5, 5), device_h * 0.1+random(-3, 5), random(900, 1100));
sleep(random(8300, 12500));
}
back();
fInfo("视频个数已刷完");
// 返回积分页
jifen_init();
ran_sleep();
return true;
}
function do_wenzhang() {
// jifen_list_1 = jifen_list_1();
// 点击进入本地
let old_wen = storage_user.get("old_wen_list", []);
// entry_jifen_project("本地频道");
entry_model(jifen_map["本地"]);
if (ddtong) {
fSet("title", "文章(dd通)…");
} else {
fSet("title", "选读文章…");
}
fClear();
sleep(2000);
if(!text("上海").findOne(3000)){
fInfo("切换地区为上海");
if(text("亮点").findOne(2000)) text("亮点").findOne(2000).parent().parent().child(5).click();
my_click_non_clickable("上海");
delay(2);
my_click_non_clickable("上海");
text("切换地区").findOne(3000);
let beijing_2 =className("android.widget.TexitView").depth(17).find();
queryList_1(beijing_2,"上海");
if (text("立即切换").exists()) {
text("取消").findOne(3000).click();
}
log("切换地区");
//let beijing_1 =className("android.widget.TexitView").depth(17).find();
// queryList_1(find(),"北京");
//className("android.widget.TexitView").depth(17).findOne(2000)
try {
text("切换地区").findOne().click();
} catch (e) {
fInfo("手动点击切换地区");
text("亮点").findOne(2000).parent().parent().child(5).click();
}
log("查找上海");
text("上海").waitFor();
sleep(500);exit
log("切换上海");
if(text("上海").findOne()) text("上海").findOne().parent().parent().click();
else queryList_1(find(),"上海");
}
log("查找banner");
//let banner = className("android.support.v7.widget.RecyclerView").findOne();
let banner = classNameContains("RecyclerView").findOne();
fInfo("查找上海新闻广播");
//fRefocus();
while (banner.findOne(text("上海新闻广播").boundsInside(0, 0, device_w, device_h)) == null) {
banner.scrollForward();
sleep(500);
}
last_obj = banner.findOne(text("上海新闻广播"));
// fInfo("点击北京新闻广播", text("北京新闻广播").findOne().parent().click());
fInfo("点击上海新闻广播:" + last_obj.parent().click());
fInfo("视听广播时长");
sleep(11500);
back();
fClear();
// 下面正式刷文章
fInfo("开始文章");
sleep(1500);
banner = classNameContains("RecyclerView").findOne();
//log(banner);
while (banner.findOne(text("上海学习平台").boundsInside(0, 0, device_w, device_h)) == null) {
banner.scrollBackward();
sleep(500);
}
sleep(1000);
fInfo("查找上海学习平台,尝试点击");
first_obj = banner.findOne(text("上海学习平台"));
// while (!text("北京学习平台").findOne().parent().click()) {log("click: false");}
// log("click: true");
// real_click(text("北京学习平台").findOne().parent());
real_click(first_obj.parent());
log("等待加载");
sleep(1000);
text("学用新思想").waitFor();
sleep(1000);
let swipe_y = text("学用新思想").findOne().parent().parent().bounds().bottom;
log("识别出顶部:", swipe_y);
fRefocus();
let listview = className("android.widget.ListView").depth(17).findOne();
// 先判断是否有可刷文章,没有则停止脚本
// while (!id("general_card_image_id").findOne(1000)) {listview.scrollForward();}
for (i = 0; i < 2; i++) {
listview.scrollForward();
sleep(500);
}
// 自定义没有刷过的文章筛选器
let wen_box_slt = className("android.view.ViewGroup").depth(20).filter(function (l) {
let title = l.findOne(idContains("general_card_title_id"));
let image = l.findOne(idContains("general_card_image_id"));
let pic_num = l.findOne(idContains("st_feeds_card_mask_pic_num"));
if (title && image && !pic_num) {
return old_wen.indexOf(title.text()) == -1 && title.text().indexOf("【专题】") == -1;
}
return false;
});
log("查找文章");
//while (!idContains("general_card_image_id").findOne(500)) {
while (!wen_box_slt.findOne(500)) {
listview.scrollForward();
//sleep(500);
}
log("找到文章");
// 下面那句会定位到新思想的文章,不能加载过新思想
let wen_box = wen_box_slt.findOne();
// 先做5次
let wen_num = 0;
let re_times = 6;
if (ddtong) {
re_times += 6;
}
while (true) {
let title = wen_box.findOne(idContains("general_card_title_id")).text();
old_wen.push(title);
if (old_wen.length > 100) {
old_wen.shift();
}
fClear();
fInfo("点击文章:" + title);
//wen_box.click();
let title_click = wen_box.parent().parent().click();
fInfo("点击:" + title_click);
classNameContains("com.uc.webview.export").waitFor();
fInfo("查找webview");
let father_view = className("android.webkit.WebView").findOne(9000);
sleep(random(1000, 1500));
// let father_view = className("android.view.View").depth(16).findOne();
// 判断是否为专题而不是文章
if (father_view && father_view.find(idContains("__next")).empty()) {
fInfo("查找文章内容");
let content = idContains("image-text-content").findOne(9000);
// log(idContains("image-text-content").findOne().id());
if (content) {
// 不先点一下划不动
idContains("xxqg-article-header").findOne().child(0).click();
}
swipe(device_w / 2+random(-3, 7), device_h * 0.7+random(-3, 8), device_w / 2+random(-7, 10), device_h * 0.3+random(-5, 6), random(950, 1100));
if (wen_num < re_times - 1) {
sleep(random(9000, 10500));
} else {
// 第6次停顿刷时间
//console.show();
toastLog("正在刷时长程序未停止");
let shichang = 6 * random(55, 66);
fClear();
fInfo("开始刷时长,总共" + shichang + "秒");
let wait_time = 1;
for (let i = 0; i < shichang; i++) { //*random(55, 60)
// 每15秒增加一次滑动防息屏
if (i % random(8, 16) == 0) {
swipe(device_w / 2 + random(-5, 10), device_h * 0.6 + random(-10, 5), device_w / 2+ random(-5, 10), device_h * 0.6+ random(-15, 10) - 100, 500);
sleep(500 + random(-5, 10));
} else {
sleep(1000 + random(7, 12));
}
//w.info.setText("已观看文章" + wait_time + "秒,总共" + shichang + "秒");
fSet("info", "已观看文章" + wait_time + "秒,总共" + shichang + "秒");
wait_time++;
}
fSet("info", "已结束文章时长");
console.hide();
back();
break;
}
} else {
wen_num -= 1;
}
back();
//id("general_card_image_id").waitFor();
className("android.widget.ListView").scrollable().depth(17).waitFor();
sleep(random(900, 1200));
while (!wen_box_slt.exists()) {
listview.scrollForward();
sleep(200);
}
wen_box = wen_box_slt.findOne();
wen_num += 1;
}
// 更新已读文章库
storage_user.put("old_wen_list", old_wen);
sleep(random(3000, 4000));
// 关闭音乐
close_video();
back();
sleep(random(3000, 4000));
// 返回积分页
jifen_init();
ran_sleep();
return true;
}
/********每日答题*********/
function do_meiri() {
// entry_jifen_project("每日答题");
entry_model(jifen_map["每日"]);
fSet("title", "每日答题…");
fClear();
// 等待加载
text("查看提示").waitFor();
// 获取右上题号,如1 /5
var tihao = className("android.view.View").depth(24).findOnce(1).text();
var num = Number(tihao[0]);
var sum = Number(tihao[tihao.length - 1]);
var substr = tihao.slice(1);
while (num <= sum) {
fClear();
fInfo("第" + num + "题");
// 等待加载
text(num + substr).waitFor();
num++;
// 如果是视频题则重新开始
if (className("android.widget.Image").exists()) {
num = 1;
restart(0);
continue;
}
do_exec();
delay(0.3);
// 点击确定下一题
depth(20).text("确定").findOne().click();
ran_sleep();
// 如果题做错了重来
if (text("下一题").exists() || text("完成").exists()) {
fInfo("答错重试");
num = 1;
restart(0);
continue;
}
}
// 循环结束完成答题
text("返回").findOne().click();
text("登录").waitFor();
ran_sleep();
return true;
}
/********每周答题*********/
function do_meizhou() {
let meizhou_d = text("每周答题").findOne(4000);
if(meizhou_d != null) meizhou_d.parent().click()
else{var textOrder = text("排行榜").findOnce().parent();
while (text("排行榜").exists()) {
console.info("点击每周答题");
textOrder.child(4).click();
sleep(random(700, 1500));
sleep(1000);
}
}
//text("每周答题").findOne().parent().click();
fSet("title", "每周答题…");
fClear();
// 等待加载
textMatches(/.*月|发现新版本/).waitFor();
if (text("发现新版本").exists()) return fError("有弹窗无法每周答题,可使用旧版修改版本号版取消弹窗或者升级最新版"), sleep(1000), text("取消").findOne().click(), sleep(1000), back(), text("我要答题").waitFor(),
sleep(1000), back(), ran_sleep(), !0;
let scoll = depth(21).scrollable().findOne();
// 下面是倒叙作答
if (meizhou_dao) {
fInfo("倒序查找未做题目");
//当出现已作答时,点击最后一个未作答
while (!text("已作答").exists()) {
scoll.scrollForward();
sleep(300);
let dixian_slt = text("您已经看到了我的底线").filter(function (w) {
log("底线:", w.bounds().top, device_h);
return w.bounds().top <= device_h - 30;
});
if (dixian_slt.exists()) {fInfo("每周答题全部已作答。"); break;}
}
var clt = text("未作答").find();
if (clt.empty()) return fInfo("每周答题全部已作答。"), ran_sleep(), back(),
sleep(random(2000, 3200)), back(), sleep(random(1600, 3300)), back(), fInfo("已全部作答 返回至‘我的’"), text("我的").waitFor(), ran_sleep(), !0;
var title = clt[clt.length - 1].parent().child(0).text();
fInfo(title + "开始作答");
clt[clt.length - 1].parent().click();
// 测试用
// text("已作答").findOnce(0).click();
}
// 下面是正序作答
else {
fInfo("正序查找未做题目");
// 找到未作答就停止滚动
let dixian_slt = text("您已经看到了我的底线").filter(function (w) {
log("底线:", w.bounds().top, device_h);
return w.bounds().top <= device_h - 30;
});
//while (true) { //测试用
while (!text("未作答").exists()) {
if (dixian_slt.exists()) return fInfo("每周答题全部已作答。"),
ran_sleep(), back(),sleep(random(2000, 3200)), back(), sleep(random(1600, 3300)), back(), fInfo("已全部作答返回至‘我的’"), text("我的").waitFor(), ran_sleep(), !0;
// back(), text("每周答题").waitFor(), sleep(1000), back(), text("我要答题").waitFor(), sleep(1000), back(), text("我的").waitFor(), ran_sleep(), !0;
// 如果到底则设置倒序为true
scoll.scrollForward();
sleep(200);
}
title = text("未作答").findOne().parent().child(0).text();
fInfo(title + "开始作答");
text("未作答").findOne().parent().click();
}
// 等待加载
text("查看提示").waitFor();
// 获取右上题号,如1 /5
var tihao = className("android.view.View").depth(24).findOnce(1).text();
var num = Number(tihao[0]);
var sum = Number(tihao[tihao.length - 1]);
var substr = tihao.slice(1);
while (num <= sum) {
fClear();
fInfo("第" + num + "题");
// 等待加载
text(num + substr).waitFor();
num++;
do_exec("(每周)");
// 点击确定下一题
depth(20).text("确定").findOne().click();
ran_sleep();
// 如果题做错了重来
if (text("下一题").exists() || text("完成").exists()) {
//toastLog(title + "我无能为力啦,请手动作答吧");
fInfo("做错尝试重答");
text("答案解析").waitFor();
upload_wrong_exec("(每周)");
storage.put('dati_tiku', dati_tiku);
back();
text("退出").findOne().click();
ran_sleep();
back();
text("每周答题").waitFor();
ran_sleep();
return false;
}
}
// 循环结束完成答题
text("返回").findOne().click();
sleep(1000);
back();
// text("每周答题").waitFor();
sleep(1000);
back();
//text("我要答题").waitFor();
sleep(1000);
back();
sleep(1500);
if (!text("我的").exists()) {sleep(3500);
if (!text("我的").exists()) back();
sleep(1000);
}
text("我的").waitFor();
ran_sleep();
meizhou_end = 0;
// getScores(3);
// sleep(800);
// back();
return true;
}
/********专项答题*********/
/*专项答题中提示的层次与每日每周的不一样
* 专项答题出现的倒计时会影响22,23层的结构*/
function do_zhuanxiang() {
let zhuanxiang_d = text("专项答题").findOne(4000);
if(zhuanxiang_d != null) zhuanxiang_d.parent().click()
else{var textOrder = text("排行榜").findOnce().parent();
while (text("排行榜").exists()) {
console.info("点击专项答题");
textOrder.child(4).click();
sleep(random(700, 1500));
sleep(1000);
}
}
//entry_jifen_project("专项答题");
fSet("title", "专项答题…");
fClear();
// 等待加载
depth(23).waitFor();
ran_sleep();
let scoll = depth(21).indexInParent(1).scrollable().findOne();
//let new_tihao = [];
// 下面是倒序答题
if (zhuanxiang_dao) {
// 当出现已满分时,点击最后一个开始答题
while (!text("已满分").exists()) {
scoll.scrollForward();
// 不加延迟会很卡
sleep(200);
}
var clt = text("开始答题").find();
if (clt.empty()) {
fInfo("专项答题全部已作答。");
back();
text("登录").waitFor();
ran_sleep();
return true;
}
// 点击最后一项
clt[clt.length - 1].click();
}
// 下面是正序
else {
// 直到找到开始答题
let dixian_slt = text("您已经看到了我的底线").filter(function (w) {
return w.bounds().top <= device_h - 30;
});
//while (true) { //测试用
while (!text("开始答题").exists()) { //开始答题
// 如果到底则设置倒序为true
if (dixian_slt.exists()) {
//storage_user.put('zhuanxiang_dao', true); 自定义不用读取
fInfo("专项答题全部已作答。");
back();
sleep(1200);
back();
// text("登录").waitFor();
ran_sleep();
return true;
}
// 滚动20次
for (i = 0; i < 15; i++) {
scoll.scrollForward();
// 不加延迟会很卡
sleep(300);
}
}
text("开始答题").findOne().click();
}
ran_sleep();
// 等待加载
text("查看提示").waitFor();
sleep(2000);
// 获取右上题号,如1 /5
var tihao = className("android.view.View").depth(24).findOnce(1).text();
// 需要加个斜杠转义
let reg = /(\d+) \/(\d+)/;
var num = Number(tihao.match(reg)[1]);
var sum = Number(tihao.match(reg)[2]);
var substr = " /" + sum;
//log(tihao);
while (num <= sum) {
fClear();
fInfo("第" + num + "题");
// 等待加载
text(num + substr).waitFor();
num++;
do_exec();
delay(0.2);
// 点击确定下一题