forked from sec-an/Better-Auto-XXQG
-
Notifications
You must be signed in to change notification settings - Fork 1
/
2.js
3105 lines (2966 loc) · 105 KB
/
2.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();
importClass(android.database.sqlite.SQLiteDatabase);
importClass("java.security.SecureRandom");
importClass("java.security.MessageDigest");
importClass("javax.crypto.spec.DESKeySpec");
importClass("javax.crypto.SecretKeyFactory");
importClass("javax.crypto.Cipher");
importClass("java.security.NoSuchAlgorithmException");
importClass("javax.crypto.KeyGenerator");
importClass("javax.crypto.SecretKey");
importClass("javax.crypto.spec.SecretKeySpec");
importClass("javax.crypto.KeyGenerator");
importClass("javax.crypto.spec.IvParameterSpec");
importClass(java.net.HttpURLConnection);
importClass(java.net.URL);
importClass(java.io.File);
importClass(java.io.FileOutputStream);
var config = {
iv: "abcdfui8701olkw4",
bm: "UTF-8",
}
for (var k in config) {
var v = config[k]
config[k] = new java.lang.String(v)
}
var STUDY_CONFIG = storages.create("STUDY_CONFIG");
var BAIDUAPI = storages.create("BAIDUAPI");
function noverify() {
var noverify_thread = threads.start(function () {
//在新线程执行的代码
while (true) {
textContains("访问异常").waitFor();
console.log("检测到滑动验证");
var delay = STUDY_CONFIG.get("huakuaidelay", "300") * 1;
var bound = idContains("nc_1_n1t").findOne().bounds();
var hua_bound = text("向右滑动验证").findOne().bounds();
var x_start = bound.centerX();
var dx = x_start - hua_bound.left;
var x_end = hua_bound.right - dx;
var x_mid = (x_end - x_start) * random(5, 8) / 10 + x_start;
var back_x = (x_end - x_start) * random(2, 3) / 10;
var y_start = random(bound.top, bound.bottom);
var y_end = random(bound.top, bound.bottom);
log("y_start:", y_start, "x_start:", x_start, "x_mid:", x_mid, "x_end:", x_end);
x_start = random(x_start - 7, x_start);
x_end = random(x_end, x_end + 10);
// sleep(600);
// press(x_start, y_start, 200);
// sleep(200);
gesture(random(delay, delay + 50), [x_start, y_start], [x_mid, y_end], [x_mid - back_x, y_start], [x_end, y_end]);
//swipe(x_start, y_start, x_end, y_end, random(900,1000));
sleep(500);
if (textContains("刷新").exists()) {
click("刷新");
continue;
}
if (textContains("网络开小差").exists()) {
click("确定");
continue;
}
console.log("已完成滑动验证,若滑动失败请在配置中调整滑动时间");
sleep(1000);
}
});
return noverify_thread;
}
function javaDecrypt(ciphertext, privateKey) {
var keyb = privateKey.getBytes(config.bm); // byte[]
var md = MessageDigest.getInstance("SHA-256");
var thedigest = md.digest(keyb); // byte[]
var skey = new SecretKeySpec(thedigest, "AES");
var dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
dcipher.init(Cipher.DECRYPT_MODE, skey, new IvParameterSpec(config.iv.getBytes()));
var clearbyte = dcipher.doFinal(base64Decode(ciphertext));
return new java.lang.String(clearbyte);
}
function base64Decode(r) {
var r = android.util.Base64.decode(r, 0)
return r
}
function decrypt(ciphertext) {
var info = splitCiphertextAndPassword(ciphertext)
var privateKey = info.privateKey
var ciphertext = info.ciphertext
privateKey = new java.lang.String(privateKey)
ciphertext = new java.lang.String(ciphertext)
return javaDecrypt(ciphertext, privateKey).toString()
}
function splitCiphertextAndPassword(ciphertext) {
var firstThreeFigures = ciphertext.slice(0, 3)
var keyLength = parseInt(firstThreeFigures.slice(0, 1)) + parseInt(firstThreeFigures.slice(1, 2)) + parseInt(firstThreeFigures.slice(2, 3))
var privateKey = ciphertext.slice(100, 100 + keyLength)
var ciphertext = ciphertext.slice(100 + keyLength)
var result = {
privateKey: privateKey,
ciphertext: ciphertext
}
return result
}
var noverify_thread = noverify();
var url = 'https://ghproxy.com/https://raw.githubusercontent.com/sec-an/Better-Auto-XXQG/main/Study/QuestionBank.db';
var path = '/sdcard/QuestionBank.db';
device.wakeUpIfNeeded(); //点亮屏幕
var first = true; //记录答题的第一次
var r; // 替换用;
var articles = STUDY_CONFIG.get("article", true);
var video = STUDY_CONFIG.get("video", 0);
var meiri = STUDY_CONFIG.get("meiri", true);
var tiaozhan = STUDY_CONFIG.get("tiaozhan", true);
var zhuanxiang_txt = STUDY_CONFIG.get("checkbox_01", true);
var meizhou_txt = STUDY_CONFIG.get("checkbox_02", true);
var siren = STUDY_CONFIG.get("checkbox_03", true);
var shuangren = STUDY_CONFIG.get("shuangren", true);
var 专项答题下滑 = STUDY_CONFIG.get("select", 0);
var 每周答题下滑 = STUDY_CONFIG.get("selectm", 0);
var choose = STUDY_CONFIG.get("select_01", 0);
var 订阅 = STUDY_CONFIG.get("ssub", 0);
var stronger = STUDY_CONFIG.get("stronger", 0); //每日答题增强模式
var token;
var ttt;
var question_list = [];
var init_true = false;
var downloadDialog = null;
var init_url = 'https://ghproxy.com/https://raw.githubusercontent.com/sec-an/Better-Auto-XXQG/main/Study/question';
var file_tmp = false;
var tikus = '';
/**
* 获取用户token
*/
function get_baidu_token() { // 百度ocr
if (!BAIDUAPI.get("AK", "") || !BAIDUAPI.get("SK", "")) {
console.error('百度ocr配置未填写!!!');
if (noverify_thread.isAlive()) {
noverify_thread.interrupt();
}
exit();
}
var res = http.post(
'https://aip.baidubce.com/oauth/2.0/token', {
grant_type: 'client_credentials',
client_id: BAIDUAPI.get("AK", "").replace(/ /g, ''),
client_secret: BAIDUAPI.get("SK", "").replace(/ /g, '')
}
);
var xad = res.body.json()['access_token'];
if (xad == null) {
console.error('百度文字识别(OCR)配置出错了!!!,脚本结束');
if (noverify_thread.isAlive()) {
noverify_thread.interrupt();
}
exit();
} else {
console.info('百度文字识别(OCR)配置正确');
}
return xad;
}
function get_paddle_ocr() {
console.info("你选择了助手内置文字识别PaddleOCR");
if (app.versionName < "1.1.0") {
console.error("请更新助手软件!!!,脚本结束");
if (noverify_thread.isAlive()) {
noverify_thread.interrupt();
}
exit();
}
}
var showlog = false;
if (shuangren == true || siren == true || 订阅 != 0 || stronger != 0 || tiaozhan) {
console.show(true);
if (siren == true || shuangren == true) {
console.error('正在获取截图权限,并检查ocr配置是否正确');
if (choose == 0) {
get_paddle_ocr();
} else if (choose == 1) token = get_baidu_token();
}
if (stronger != 0) {
console.info('正在检测增强模式配置');
if (siren == true && choose == 1) {
ttt = token;
} else {
ttt = get_baidu_token();
}
}
if (!files.exists(path)) {
//toastLog('没有题库,正在下载题库,请等待!!!');
threads.start(function () {
var tiku = http.get(url).body.bytes();
//console.log(tiku)
files.writeBytes(path, tiku);
});
}
delay(2);
show_log();
while (!showlog) {
sleep(1000);
};
if (tiaozhan || siren || shuangren)
init();
if (tiaozhan && !(siren == true || shuangren == true || 订阅 != 0 || stronger != 0)) {} //只开了挑战答题的话
else {
threads.start(function () {
if (!requestScreenCapture(false)) {
toastLog("请求截图失败,脚本结束");
if (noverify_thread.isAlive()) {
noverify_thread.interrupt();
}
exit();
}
});
delay(1.5);
if (textContains("立即开始").exists() || textContains("允许").exists()) {
if (textContains("立即开始").exists()) {
textContains("立即开始").className("Button").findOne().click();
} else {
textContains("允许").className("Button").findOne().click();
}
console.info('自动点击获取权限按键!!!');
}
while (true) {
try {
captureScreen();
break;
} catch (e) {
console.log('等待截图权限中');
};
sleep(1500);
}
console.info('立即开始,允许截图权限已获取!!!');
}
}
function show_log() {
threads.start(function () {
try {
var text = http.get('https://ghproxy.com/https://raw.githubusercontent.com/sec-an/Better-Auto-XXQG/main/Study/showlogs').body.string();
if (text.length == 0) {
show_log = true;
return;
}
console.info('查看使用须知,5s后自动关闭');
var d = dialogs.build({
title: "使用须知",
content: text,
positive: "关闭",
}).on("positive", () => {
d.dismiss();
// setClip(text);
d = null;
text = null;
showlog = true;
}).show();
sleep(5000);
if (!showlog) {
d.dismiss();
// setClip(text)
d = null;
text = null;
showlog = true;
}
} catch (e) {
try {
d.dismiss();
d = null;
} catch (e) {}
text = null;
showlog = true;
}
});
}
var lCount = 1; //挑战答题轮数
var qCount = 5; //挑战答题每轮答题数
var asub = 2; //订阅数
var aCount = 6; //文章默认学习篇数
var vCount = 6; //小视频默认学习个数
var cCount = 2; //收藏+分享+评论次数
var dayCount = 1; // 每日答题
var tzCount = 1; // 挑战答题
var zsyCount = 1; //争上游答题
var doubleCount = 1; // 双人对战
var meizhou = 1; //每周答题
var zhuanxiang = 1; //专项答题
var aTime = STUDY_CONFIG.get("time1", "61"); //有效阅读一分钟1分*6
var vTime = STUDY_CONFIG.get("time2", "6"); //每个小视频学习-5秒
var rTime = 370; //广播收听6分 * 60 = 360秒
var 点点通 = {
'有效视听': 0,
'有效浏览': 0,
'挑战答题': 0
};
var myScores = {}; //分数
var article_list = [];
var delay_time = 1000;
/**
* @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: 点击文本控件
* @param: 文本
* @return: null
*/
function my_click_clickable(target) {
text(target).waitFor();
click(target);
}
/**
* @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;
}
}
/**
* @description: 文章学习计时(弹窗)函数
* @param: n-文章标号 seconds-学习秒数
* @return: null
*/
function article_timing(n, seconds) {
var seconds = seconds * 1;
seconds = seconds + randomNum(1, 5);
h = device.height; //屏幕高
w = device.width; //屏幕宽
x = (w / 3) * 2;
h1 = (h / 6) * 5;
h2 = (h / 6);
for (var i = 0; i < seconds; i++) {
while (!textContains("欢迎发表你的观点").exists()) //如果离开了文章界面则一直等待
{
console.error("当前已离开第" + (n + 1) + "文章界面,请重新返回文章页面...");
delay(2);
}
if (i % 5 == 0) //每5秒打印一次学习情况
{
console.info("第" + (n + 1) + "篇文章已经学习" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
}
sleep(1000);
if (i % 10 == 0) //每10秒滑动一次,如果android版本<7.0请将此滑动代码删除
{
toast("这是防息屏toast,请忽视-。-");
if (i <= seconds / 2) {
swipe(x, h1, x, h2, 500); //向下滑动
} else {
swipe(x, h2, x, h1, 500); //向上滑动
}
}
}
}
/**
* @description: 视频学习计时(弹窗)函数
* @param: n-视频标号 seconds-学习秒数
* @return: null
*/
function video_timing_bailing(n, seconds) {
var seconds = seconds * 1;
seconds = seconds + randomNum(1, 5);
delay(1);
for (var i = 0; i < seconds; i++) {
sleep(1000);
while (!(textContains("分享").exists() || textContains("播放").exists()) || desc("工作").exists()) //如果离开了百灵小视频界面则一直等待
{
console.error("当前已离开第" + (n + 1) + "个视频界面,请重新返回视频");
delay(2);
}
console.info("第" + (n + 1) + "个视频已经观看" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
}
}
/**
* @description: 广播学习计时(弹窗)函数
* @param: r_time-已经收听的时间 seconds-学习秒数
* @return: null
*/
function radio_timing(r_time, seconds) {
var seconds = seconds * 1;
for (var i = 0; i < seconds; i++) {
sleep(1000);
if (i % 5 == 0) //每5秒打印一次信息
{
console.info("广播已经收听" + (i + 1 + r_time) + "秒,剩余" + (seconds - i - 1) + "秒!");
}
if (i % 15 == 0) //每15秒弹一次窗防止息屏
{
toast("这是防息屏弹窗,可忽略-. -");
}
}
}
/**
* @description: 已读文章判断
* @param: null
* @return: null
*/
function insertLearnedArticle(article) {
article_list.push(article);
}
function getLearnedArticle(article) {
for (var i = 0; i < article_list.length; i++) {
if (article_list[i] == article) {
return true;
}
}
return false;
}
var commentText = ["歌颂共产党,永远跟党走。", "为中华崛起而读书!", "倡导富强、民主、文明、和谐", "自由,平等,公正,法治", "不忘初心,牢记使命", "努力奋斗,回报祖国!", "赞叹中共伟大成就 祝福中国美好未来!"]; //评论内容,可自行修改,大于5个字便计分
/**
* @description: 分享评论
* @param: null
* @return: null
*/
function collectCommentShare() {
while (!text("欢迎发表你的观点").exists()) {
toastLog("需要在文章界面");
delay(1);
}
var textOrder = text("欢迎发表你的观点").findOnce().drawingOrder();
var zhuanOrder = textOrder + 3;
var shareIcon = className("ImageView").filter(function (iv) {
return iv.drawingOrder() == zhuanOrder;
}).findOnce();
toastLog("正在进行分享评论...");
shareIcon.click(); //点击分享
while (!textContains("分享到学习强").exists()); //等待弹出分享选项界面
delay(2);
click(decodeURI("%E5%88%86%E4%BA%AB%E5%88%B0%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BD"));
delay(1);
toastLog("分享成功!");
delay(1);
back(); //返回文章界面
delay(2);
//评论
var num = random(0, commentText.length - 1) //随机数
click("欢迎发表你的观点");
delay(1);
setText(commentText[num]); //输入评论内容
delay(1);
click("发布"); //点击右上角发布按钮
//toastLog("评论成功!");
delay(2);
click("删除"); //删除该评论
delay(2);
click("确认"); //确认删除
//toastLog("评论删除成功!");
delay(2);
toastLog("分享,评论结束");
}
/**
* @description: 文章学习函数 (阅读文章+文章学习时长)---6+6=12分
* @param: null
* @return: null
*/
function articleStudy(x) {
var aCatlog = '推荐'
while (!desc("工作").exists()); //等待加载出主页
var listView = className("ListView"); //获取文章ListView控件用于翻页
if (x == 0) {
desc("工作").click(); //点击主页正下方的"学习"按钮
delay(2);
click(aCatlog);
}
delay(2);
var zt_flag = false; //判断进入专题界面标志
var x = aCount;
if (点点通['有效浏览']) {
x = Math.max(点点通['有效浏览'] * 6 - (6 - aCount), 点点通['有效浏览'] * 6);
}
console.log('需要学习' + x + '篇');
for (var i = 0, t = 0; i < x;) {
if (aCount <= 0) aTime = 6;
try {
if ((text('播报').findOnce(t).parent().parent().parent().child(0).parent().parent().click()) == true) {
delay(3);
// // delay(10); //等待加载出文章页面,后面判断是否进入了视频文章播放要用到
//获取当前正在阅读的文章标题
let n = 0;
while (!textContains("欢迎发表你的观点").exists()) { //如果没有找到评论框则认为没有进入文章界面,一直等待
delay(1);
console.warn("正在等待加载文章界面...");
if (n > 2) { //等待超过3秒则认为进入了专题界面,退出进下一篇文章
console.warn("没找到评论框!该界面非文章界面!");
zt_flag = true;
break;
}
n++;
}
if (text("展开").exists()) { //如果存在“展开”则认为进入了文章栏中的视频界面需退出
console.warn("进入了视频界面,退出并进入下一篇文章!");
t++;
back();
listView.scrollForward();
delay(1.5);
if (rTime != 0) {
while (!desc("工作").exists());
console.info("因为广播被打断,重新收听广播...");
delay(0.5);
listenToRadio(); //听电台广播
while (!desc("工作").exists());
desc("工作").click();
}
delay(2);
continue;
}
if (zt_flag == true) { //进入专题页标志
console.warn("进入了专题界面,即将退出并进下一篇文章!");
t++;
back();
delay(2);
zt_flag = false;
continue;
}
var currentNewsTitle = ""
if (id("xxqg-article-header").exists()) {
currentNewsTitle = id("xxqg-article-header").findOne().child(0).text(); // 最终解决办法
} else if (textContains("来源").exists()) {
currentNewsTitle = textContains("来源").findOne().parent().children()[0].text();
} else if (textContains("作者").exists()) {
currentNewsTitle = textContains("作者").findOne().parent().children()[0].text();
} else if (descContains("来源").exists()) {
currentNewsTitle = descContains("来源").findOne().parent().children()[0].desc();
} else if (descContains("作者").exists()) {
currentNewsTitle = descContains("作者").findOne().parent().children()[0].desc();
} else {
console.log("无法定位文章标题,即将退出并阅读下一篇")
t++;
back();
delay(2);
continue;
}
if (currentNewsTitle == "") {
console.log("标题为空,即将退出并阅读下一篇")
t++;
back();
delay(2);
continue;
}
var flag = getLearnedArticle(currentNewsTitle);
if (flag) {
//已经存在,表明阅读过了
console.info("该文章已经阅读过,即将退出并阅读下一篇");
t++;
back();
delay(2);
continue;
} else {
//没阅读过,添加到数据库
insertLearnedArticle(currentNewsTitle);
}
console.log("正在学习第" + (i + 1) + "篇文章,标题:", currentNewsTitle);
//开始循环进行文章学习
article_timing(i, aTime);
aCount--;
delay(2);
if (sCount != 0) {
console.info("第" + (3 - sCount) + "次分享开始");
sCount--;
collectCommentShare(); //评论和分享
}
back(); //返回主界面
console.info('返回主界面');
delay(0.3);
while (!desc("工作").exists()) { //等待加载出主页
console.info("等待加载主页");
delay(2);
}
delay(2);
//console.info('i++,t++')
listView.scrollForward();
delay(1)
i++;
t++; //t为实际点击的文章控件在当前布局中的标号,和i不同,勿改动!
} else {
t++;
}
} catch (e) {
listView.scrollForward();
//console.info('异常')
t = 0;
delay(1.5);
}
}
aTime = STUDY_CONFIG.get("time1", "61");
}
/**
* @description:百灵小视频学习函数
* @param: null
* @return: null
*/
function videoStudy_news(tmp) {
h = device.height; //屏幕高
w = device.width; //屏幕宽
x = (w / 3) * 2;
h1 = (h / 6) * 5;
h2 = (h / 6);
//delay(1)
if (tmp == 1) {
desc("工作").click();
delay(2)
click("百灵");
delay(1)
}
click("推荐");
delay(2);
//获取listView视频列表控件用于翻页
var v = className('android.widget.FrameLayout').clickable(true).depth(24).findOne().bounds();
press(v.centerX(), v.centerY(), 150);
delay(1);
for (var i = 0; i < vCount;) {
if (textContains("分享").exists()) {
console.log("即将学习第" + (i + 1) + "个视频!");
video_timing_bailing(i, vTime); //学习每个新闻联播小片段
//back();//返回联播频道界面
swipe(x, h1, x, h2, 500); // 下滑动
delay(1);
i++;
} else {
delay(1);
console.error("等待百灵视频界面");
}
}
delay(2);
back();
}
function new_bailing_video(tmp) {
h = device.height; //屏幕高
w = device.width; //屏幕宽
x = (w / 3) * 2;
h1 = (h / 6) * 5;
h2 = (h / 6);
//delay(1)
if (tmp == 1) {
desc("工作").click();
delay(2)
click("百灵");
delay(1)
}
for (var i = 0; i < vCount;) {
if (textContains("百灵").exists()) {
try {
if (i % 2 == 0) {
click("推荐");
delay(2);
}
className('android.widget.FrameLayout').clickable(true).depth(22).findOnce((i % 2)).click();
console.log("即将学习第" + (i + 1) + "个视频!");
video_timing_bailing(i, vTime); //学习每个新闻联播小片段
back(); //返回联播频道界面
delay(1);
i++;
} catch (e) {
delay(1);
console.error("等待百灵视频界面");
}
} else {
delay(1);
console.error("等待百灵视频界面");
}
}
}
function video_news_time(n, seconds) {
var seconds = seconds * 1;
seconds = seconds + randomNum(1, 5);
for (var i = 0; i < seconds; i++) {
sleep(1000);
while (!desc("工作").exists()) //如果离开了看电视视频界面则一直等待
{
console.error("当前已离开第" + (n + 1) + "个视频界面,请重新返回视频");
delay(2);
}
console.info("第" + (n + 1) + "个视频已经观看" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
}
}
/**
* @description:电视台视频学习
* @param: null
* @return: null
*/
function video_news(tmp) {
h = device.height; //屏幕高
w = device.width; //屏幕宽
x = (w / 3) * 2;
h1 = (h / 6) * 5;
h2 = (h / 6);
//delay(1)
var t = 6;
if (tmp == 1) {
desc("工作").click();
delay(2);
click("电视台");
delay(1)
click("看电视");
delay(2);
t = 0;
}
var s = textContains("中央广播电视总台").depth(22).findOnce().parent();
s.click();
console.info('改变提示框位置');
delay(1);
console.setPosition(device.width / 4, -device.height / 4);
for (var i = 0; i < vCount; i++) {
if (textContains("电视台").exists()) {
console.log("即将学习第" + (i + 1) + "个视频!");
var cctv = s.parent().parent().parent().parent().child(1).child(0).child(t).bounds();
press(cctv.centerX(), cctv.centerY(), 150);
delay(2);
video_news_time(i, vTime); //学习每个直播小片段
delay(1);
t++;
t = t % 8;
} else {
delay(1);
console.error("等待电视台->看电视界面");
}
}
console.setPosition(0, device.height / 2);
delay(2);
//back();
}
/**
* @description: 听“电台”新闻广播函数 (视听学习+视听学习时长)---6+6=12分
* @param: null
* @return: null
*/
function listenToRadio() {
click("电台");
delay(1);
click("听广播");
delay(2);
while (!(textContains("正在收听").exists() || textContains("最近收听").exists() || textContains("推荐收听").exists())) {
log("等待加载");
delay(1);
}
if (click("最近收听") == 0) {
if (click("推荐收听") == 0) {
click("正在收听");
}
}
delay(2);
if (id("btn_back").findOne().click() == 0) {
delay(2);
back(); //返回电台界面
}
delay(2);
}
/**
* @description: 启动app
* @param: null
* @return: null
*/
function start_app() {
console.setPosition(0, device.height / 2); //部分华为手机console有bug请注释本行
console.show(true); //部分华为手机console有bug请注释本行
console.log("正在启动app...");
if (!(launchApp(decodeURI("%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BD")) || launch('cn.xuexi.android'))) {
console.error(decodeURI("%E6%89%BE%E4%B8%8D%E5%88%B0%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BDApp!%EF%BC%8C%E8%AF%B7%E8%87%AA%E5%B7%B1%E5%B0%9D%E8%AF%95%E6%89%93%E5%BC%80"));
// return;
}
while (!desc("工作").exists()) {
console.log("正在等待加载出主页,如果一直加载此信息,请检测是否在主界面,或者无障碍服务可能出现BUG,请停止运行助手软件并重新给无障碍服务");
if (textContains("取消").exists() && textContains("立即升级").exists()) {
//toast('1');
text("取消").click();
}
delay(3);
}
delay(1);
}
/**
* @description: 本地频道
* @param: null
* @return: null
*/
function localChannel() {
delay(1)
while (!desc("工作").exists()); //等待加载出主页
desc("工作").click();
console.log("点击本地频道");
if (text("新思想").exists()) {
text("新思想").findOne().parent().parent().child(3).click();
delay(3);
className("android.support.v7.widget.RecyclerView").findOne().child(2).click();
delay(2);
console.log("返回主界面");
back();
launchApp(decodeURI("%E5%AD%A6%E4%B9%A0%E5%BC%BA%E5%9B%BD"));
delay(1);
text("新思想").findOne().parent().parent().child(0).click();
} else {
console.log("请手动点击本地频道!");
}
}
/**
* @description: 获取积分
* @param: null
* @return: null
*/
function getScores(i) {
while (!desc("工作").exists()); //等待加载出主页
console.log("正在获取积分...");
delay(2);
while (!text("积分明细").exists()) {
if (id("comm_head_xuexi_score").exists()) {
id("comm_head_xuexi_score").findOnce().click();
} else if (text("积分").exists()) {
text("积分").findOnce().parent().child(1).click();
}
delay(3);
}
while (!text('登录').exists()) {
delay(0.5);
}
let err = false;
while (!err) {
try {
className("android.widget.ListView").findOnce().children().forEach(item => {
var name;
try {
name = item.child(0).child(0).text();
} catch (e) {
name = item.child(0).text();
}
let str = item.child(2).text().split("/");
let score = str[0].match(/[0-9][0-9]*/g);
myScores[name] = score;
});
err = true;
} catch (e) {
console.log(e);
}
}
if (i == 3) {
var score = textContains("今日已累积").findOne().text();
score += '%0A四人赛:' + myScores["四人赛"] + '分';
score += '%0A双人赛:' + myScores["双人对战"] + '分';
score += '%0A成长总积分:' + textContains("成长总积分").findOne().parent().child(3).text() + '分%0A';
log(score);
back();
return score;
}
console.log(myScores);
aCount = Math.ceil((12 - myScores["我要选读文章"]) / 2); //文章个数
if (i == 1) {
console.info("检查阅读文章是否满分!")
aCount = 12 - myScores["我要选读文章"];
if (aCount != 0) {
console.log("还需要阅读:" + aCount.toString() + "篇!");
} else {
console.info("已满分!");
}
delay(1);
back();
delay(1);
return;
}
if (i == 2) {
console.info("检查视频是否满分!")
vCount = 6 - myScores["视听学习"];
if (vCount != 0) {
console.log("还需要观看:" + vCount.toString() + "篇!");
} else {
console.info("已满分!");
}
delay(1);
back();
delay(1);
return;
}
if (aCount != 0) {
aCount = aCount;
}
vCount = 6 - myScores["视听学习"];
rTime = (6 - myScores["视听学习时长"]) * 60;
asub = 2 - myScores["订阅"];
sCount = 1
cCount = 1 - myScores["发表观点"]
if (myScores["每日答题"] < 5) dayCount = 1;
else dayCount = 0;
if (myScores["挑战答题"] < 6) tzCount = 1;
else tzCount = 0;
if (myScores["四人赛"] == 0) zsyCount = 1;
else zsyCount = 0;
if (myScores["双人对战"] == 0) doubleCount = 1;
else doubleCount = 0;
if (myScores["每周答题"] == 0) meizhou = 1;
else meizhou = 0;
if (myScores["专项答题"] == 0) zhuanxiang = 1;
else zhuanxiang = 0;
console.log('评论:' + cCount.toString() + '个')
console.log('分享:' + sCount.toString() + '个')
console.log('订阅:' + asub.toString() + '个')
console.log('剩余文章:' + aCount.toString() + '篇')
// console.log('剩余每篇文章学习时长:' + aTime.toString() + '秒')
console.log('剩余视频:' + vCount.toString() + '个')
console.log('剩视听学习时长:' + rTime.toString() + '秒')
console.log('每日答题:\t' + dayCount.toString());
console.log('挑战答题:\t' + tzCount.toString());
console.log('四人赛:\t' + zsyCount.toString());
console.log('双人对战:\t' + doubleCount.toString());
if (meizhou_txt == "开启")
console.log('每周答题:\t' + meizhou.toString());
if (zhuanxiang_txt == "开启")
console.log('专项答题:\t' + zhuanxiang.toString());
delay(1);
back();
delay(1);
}
/**
@description: 停止广播
@param: null
@return: null
*/
function stopRadio() {
console.log("停止收听广播!");
click("电台");
delay(1);
click("听广播");
delay(2);
while (!(textContains("正在收听").exists() || textContains("最近收听").exists() || textContains("推荐收听").exists())) {
log("等待加载");
delay(2)
}
if (click("正在收听") == 0) {
click("最近收听");
}