-
Notifications
You must be signed in to change notification settings - Fork 44
/
main.js
3604 lines (3454 loc) · 145 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"ui";
/*
这条注释为了提示我自己:
1.打包前注意有软件版本号的地方:
main.js的第431行及更新记录、
project.json
2.测试时运行后一定要先点开启无障碍按钮!!!
*/
importClass(android.graphics.Paint);
importClass(android.view.View);
//db操作
importClass(android.database.sqlite.SQLiteDatabase);
var tikuCommon = require("./tikuCommon.js");
var PrefCheckBox = require('./config.js');
//var floating = require("./floating.js");
let deviceWidth = device.width;
let margin = parseInt(deviceWidth * 0.02);
//开屏提示 2021-5-5xzy修改
var iff = files.read("./if.txt");
if (iff == ""){
alert("必读说明", "免责声明:\n本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!\n如果继续使用此应用即代表您同意此协议\n说明:此应用仅适用于Android7.0以上的版本。\n打开应用后请先点击第一个按钮打开无障碍和悬浮窗权限,如果没有反应则是已经开启。\n随后点击默认执行按钮,程序会自动检测当前分数智能执行\n如果您要使用自定义执行及单个任务执行功能,请先在数据配置页配置数据\n特别鸣谢:晴天、翻滚的茄子、AIQiangguo\n正常执行可得42分\n请确保进入学习强国时位于 主界面,模拟点击从主界面开始");
files.write("./if.txt", "1");
}
//载入配置2021.3.29xzy添加
var confi = files.read("./config.txt");
var conf = confi.split(" ");
//检测更新和更新题库2021-5-22 xzy修改
if (PrefCheckBox.getPref().get("update")){
engines.execScriptFile("./update.js");
}
var flagShut = 0;
var aCount = conf[0];//文章默认学习篇数
var vCount = conf[3];//小视频默认学习个数
var cCount = 2;//收藏+分享+评论次数
var aTime = conf[1];//每篇文章学习-30秒 30*12≈360秒=6分钟
var vTime = conf[4];//每个小视频学习60秒
var rTime = 360;//音视频时长-6分钟
var dyNum = 2;//订阅 2
var commentText = ["支持党,支持国家!", "为实现中华民族伟大复兴而不懈奋斗!", "不忘初心,牢记使命"];//评论内容,可自行修改,大于5个字便计分
var num = random(0, commentText.length - 1) ;//随机数
var aCat = ["推荐","要闻","综合"];
var aCatlog = aCat[num] ;//文章学习类别,随机取"推荐""要闻"、"新思想"
var aZX = conf[2];//文章执行1或2脚本
var date_string = getTodayDateString();//获取当天日期字符串
var vCat = ["第一频道", "学习视频", "联播频道"];
var vCatlog = vCat[num] ; //视频学习类别,随机取 "第一频道"、"学习视频"、"联播频道"
if (num == 0){
var s = "央视网";
}else if (num == 1){
var s = "央视新闻";
}else {
var s = "中央广播电视总台";
}
var lCount = conf[5];//挑战答题轮数
var qCount = random(5, 7);//挑战答题每轮答题数(5~7随机)
var zCount = conf[6];//争上游答题轮数
var zsyzd = 1;//争上游和双人对战是否自动做,1,2 默认自动1
var oldaquestion;//争上游和对战答题循环,定义旧题目对比新题目用20201022
var myScores = {};//分数
//特殊题,特点:题目一样,答案不同
var ZiXingTi = "选择词语的正确词形。"; //字形题
var DuYinTi = "选择正确的读音。";//读音题 20201211
var ErShiSiShi ="下列不属于二十四史的是。";//二十四史
var asub = 2;
var customize_flag = false;//自定义运行标志
var zsyNext = parseInt(conf[9]);
var zsyWaitTime = parseInt(conf[10]);
/*
<---------------UI部分开始--------------->
xzy更新
*/
//alert("协议及说明", "免责声明:\n本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!\n如果继续使用此应用即代表您同意此协议\n说明:此应用仅适用于Android7.0以上的版本。");
var color = conf[8];
//var txt = files.read("./运行日志.txt");
var dbName = "tiku.db";//题库文件名
var path = files.path(dbName);
var db = SQLiteDatabase.openOrCreateDatabase(path, null);
var sql = "SELECT * FROM tikuNet;";
var cursor = db.rawQuery(sql, null);
if (cursor.moveToFirst()) {
var answer = cursor.getString(0);
cursor.close();
}
ui.layout(
<drawer id="drawer">
<vertical>
<appbar bg="{{conf[8]}}">
<toolbar id="toolbar" title="自动学习强国"/>
<tabs id="tabs"/>
</appbar>
<viewpager id="viewpager">
<frame>
<ScrollView>
<vertical>
<button text="先点我开启无障碍和悬浮窗,如果没有反应,说明已经开启" style="Widget.AppCompat.Button.Colored" id="click_me" w="*" />
<button id="stop" w="*" text="紧急停止所有任务" style="Widget.AppCompat.Button.Colored" />
<button style="Widget.AppCompat.Button.Colored" id="all" h="50" text="默认执行" />
<button id="sau" w="*" text="切换账户执行(为每个账户执行默认执行)" style="Widget.AppCompat.Button.Colored" />
<button text="-------以下为单个任务执行-------" style="Widget.AppCompat.Button.Borderless.Colored" w="*"/>
<pref-checkbox id="cq" text="挑战答题"/>
<pref-checkbox id="dq" text="每日答题"/>
<pref-checkbox id="sr" text="双人对战"/>
<pref-checkbox id="zsy" text="四人赛"/>
<pref-checkbox id="dwz" text="读文章"/>
<pref-checkbox id="kspnews" text="看视频(新闻联播)"/>
<pref-checkbox id="kspbailing" text="看视频(百灵)"/>
<pref-checkbox id="weekly" text="每周答题"/>
<pref-checkbox id="special" text="专项答题"/>
<pref-checkbox id="CSA" text="收藏评论分享(已包含在读文章中)"/>
<button id="startToLearn" w="*" text="开始学习选中的内容" style="Widget.AppCompat.Button.Colored" />
<button id="sauc" w="*" text="切换账户执行(为每个账户执行选中的内容)" style="Widget.AppCompat.Button.Colored" />
<button text="-------公告-------" style="Widget.AppCompat.Button.Borderless.Colored" w="*"/>
<button text="此应用仅适用于Android7.0以上!" style="Widget.AppCompat.Button.Borderless.Colored" w="auto"/>
<button w="250" w="*" id="about" text="使用说明" style="Widget.AppCompat.Button.Colored" />
</vertical>
</ScrollView>
</frame>
<frame>
<ScrollView>
<vertical>
<button style="Widget.AppCompat.Button.Colored" id="save" h="50" text="保存当前配置" />
<button text="-------软件配置-------" style="Widget.AppCompat.Button.Borderless.Colored" w="*"/>
<pref-checkbox id="update" text="是否自动检查更新和更新题库"/>
<pref-checkbox id="perf2" text="是否开启悬浮窗"/>
<input id="ud" w="*" h="auto" hint="输入更新源" />
<input id="bg" w="*" h="auto" hint="输入软件配色(如#xxxxxx,重启软件后生效)" />
<button text="-------自定义读文章的配置-------" style="Widget.AppCompat.Button.Borderless.Colored" w="*"/>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="文章频道:" />
<input id="aCatlog" w="55" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="日期:" />
<input id="date_string" w="110" text="" />
</horizontal>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="文章数量:" />
<input id="aCount" w="30" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="时长:" />
<input id="aTime" w="30" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="执行:" />
<input id="aZX" w="30" text="" />
</horizontal>
<button text="-------自定义看视频的配置-------" style="Widget.AppCompat.Button.Borderless.Colored" w="*"/>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="视频频道:" />
<input id="vCatlog" w="80" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="关键词:" />
<input id="s" w="150" text="" />
</horizontal>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="视频数量:" />
<input id="vCount" w="30" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="时长:" />
<input id="vTime" w="30" text="" />
</horizontal>
<button text="-------自定义答题挑战的配置-------" style="Widget.AppCompat.Button.Borderless.Colored" w="*"/>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="挑战次数:" />
<input id="lCount" w="45" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="答题:" />
<input id="qCount" w="45" text="" />
</horizontal>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="四人赛次数(不包慢速答题次数):" />
<input id="zCount" w="50" text="" />
</horizontal>
<horizontal>
<text textSize="15sp" marginLeft="15" textColor="black" text="慢速答题次数:" />
<input id="zsyNext" w="50" text="" />
<text textSize="15sp" marginLeft="15" textColor="black" text="延迟速度:" />
<input id="zsyWaitTime" w="50" text="" />
</horizontal>
</vertical>
</ScrollView>
</frame>
<frame>
<vertical>
<horizontal gravity="center">
<input margin={margin + "px"} id="keyword" hint=" 输入题目或答案关键字" h="auto" />
<radiogroup orientation="horizontal">
<radio id="rbQuestion" text="题目" checked="true" />
<radio id="rbAnswer" text="答案" />
</radiogroup>
</horizontal>
<button gravity="center" id="search" text=" 搜索 " />
<horizontal gravity="center">
<button id="lastTen" text=" 最近十条 " />
<button id="prev" text=" 上一条 " />
<button id="next" text=" 下一条 " />
<button id="reset" text=" 重置 " />
</horizontal>
<horizontal gravity="center">
<button id="update" text=" 修改 " />
<button id="delete" text=" 删除 " />
<button id="insert" text=" 新增 " />
<button id="updateTikuNet" text=" 更新题库 " />
</horizontal>
<progressbar id="pbar" indeterminate="true" style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal" />
<text id="resultLabel" text="" gravity="center" />
<horizontal>
<vertical>
<text id="questionLabel" text="题目" />
<horizontal>
<text id="questionIndex" text="0" />
<text id="slash" text="/" />
<text id="questionCount" text="0" />
</horizontal>
</vertical>
<input margin={margin + "px"} id="question" w="*" h="auto" />
</horizontal>
<horizontal>
<text id="answerLabel" text="答案" />
<input id="answer" w="*" h="auto" />
</horizontal>
<horizontal gravity="center">
<button id="daochu" text="导出文章列表" />
<button id="daoru" text="导入文章列表" />
<button id="listdel" text="清空文章列表" />
</horizontal>
<text text="此页面源于LazyStudy" />
</vertical>
</frame>
<frame>
<ScrollView>
<vertical>
<text id="v270" />
<text id="v260" />
<text id="v252" />
<text id="v251" />
<text id="v250" />
<text id="v244" />
<text id="v240" />
<text id="v220" />
<text id="v204" />
<text id="v203" />
<text id="v202" />
<text id="v201" />
<text id="v200" />
<text id="v101" />
<text id="v100" />
</vertical>
</ScrollView>
</frame>
<frame>
<vertical>
<webview id="webview" h="300" margin="0 16"/>
<text text="官方网站:http://xzy.center/" />
<text text="扫码赞助我" />
<img src="http://www.xzy.center/pic/fullsizerender(2).jpg" />
</vertical>
</frame>
<frame>
<list id="todoList">
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp"
cardElevation="1dp" foreground="?selectableItemBackground">
<horizontal gravity="center_vertical">
<View bg="#97ac69" h="*" w="10" />
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
<text id="title" text="{{this.title}}" textColor="#222222" textSize="16sp" maxLines="1" />
<text text="{{this.summary}}" textColor="#999999" textSize="14sp" maxLines="1" />
</vertical>
<!--<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" />-->
</horizontal>
</card>
</list>
<fab id="add" w="auto" h="auto" src="@drawable/ic_add_black_48dp"
margin="16" layout_gravity="bottom|right" tint="#ffffff" />
</frame>
</viewpager>
</vertical>
<vertical layout_gravity="left" bg="#ffffff" w="280">
<img w="280" h="200" scaleType="fitXY" src="http://images.shejidaren.com/wp-content/uploads/2014/10/023746fki.jpg"/>
<list id="menu">
<horizontal bg="?selectableItemBackground" w="*">
<img w="50" h="50" padding="16" src="{{this.icon}}" tint="{{color}}"/>
<text textColor="black" textSize="15sp" text="{{this.title}}" layout_gravity="center"/>
</horizontal>
</list>
</vertical>
</drawer>
);
ui.v260.setText("v2.6.0:2021.7.25\n1,功能性更新\n2,完善切换账户执行的功能\n3,修复一些bug\n4,更新UI\n");
ui.v260.setText("v2.6.0:2021.7.25\n1,更新软件源\n2,添加切换账户执行的功能\n3,修复一些bug\n");
ui.v252.setText("v2.5.2:2021.7.1\n1,可自行选择是否自动更新及显示悬浮窗\n2,添加更新源设置\n");
ui.v251.setText("v2.5.1:2021.4.1\n如想要提建议请去github,不要在赞赏里说\n1,自动更新题库\n2,保存配置\n3,修复读文章问题\n");
ui.v250.setText("v2.5.0:2021.3.6\n特别鸣谢:github上的所有朋友\n1,每次打开检查更新\n2,添加第一次打开应用的判断\n");
ui.v244.setText("v2.4.4:2021.2.17\n特别鸣谢:晴天、翻滚的茄子\n1,每次打开自动清空日志\n2,添加订阅功能\n3,添加函数名执行功能\n3,添加第一次打开应用的判断\n");
ui.v240.setText("v2.4.0:2021.2.16\n1,修复适配问题\n2,更新UI\n3,更新协议及说明\n");
ui.v220.setText("v2.2.0:2021.1.27\n1,添加争上游答题\n2,修复个别执行没有返回的问题\n3,添加协议及说明\n");
ui.v204.setText("v2.0.4:2020.8.29\n1,添加应用安装检测\n2,修复视听学习不能加积分的bug\n");
ui.v203.setText("v2.0.3:2020.8.28\n1,修复一些bug\n2,添加公告\n");
ui.v202.setText("v2.0.2:2020.8.27\n1,修复选读文章bug\n2,添加更新记录\n");
ui.v201.setText("v2.0.1:2020.8.27\n1,修复一些bug\n2,添加弹窗提示\n");
ui.v200.setText("v2.0.0:2020.8.27\n1,修复视听学习及一些bug\n2,添加本地频道及分享功能\n3,更新UI界面\n4,添加一键刷积分\n");
ui.v101.setText("v1.0.1:2020.8.26\n1,修复一些bug\n");
ui.v100.setText("v1.0.0:2020.8.26\n原始版本,构建UI布局。添加选读文章及视听学习功能");
ui.ud.setText(conf[7]);
ui.bg.setText(conf[8]);
ui.startToLearn.click(function () {
thread = threads.start(function () {
start_app();
zCount = parseInt(ui.zCount.getText());
lCount = parseInt(ui.lCount.getText());
qCount = parseInt(ui.qCount.getText());
zCount = parseInt(ui.zCount.getText());
vTime = parseInt(ui.vTime.getText());
vTime = parseInt(ui.vTime.getText());
vCount = parseInt(ui.vCount.getText());
zsyNext = parseInt(ui.zsyNext.getText());
zsyWaitTime = parseInt(ui.zsyWaitTime.getText());
if(PrefCheckBox.getPref().get("CSA"))
CollectAndShareAndComment();
if(PrefCheckBox.getPref().get("weekly"))
weeklyQuestion();
if(PrefCheckBox.getPref().get("special"))
specialQuestion();
if(PrefCheckBox.getPref().get("zsy"))
zsyQuestion();
if(PrefCheckBox.getPref().get("cq"))
challengeQuestion();
if(PrefCheckBox.getPref().get("dq"))
dailyQuestion();
if(PrefCheckBox.getPref().get("sr"))
SRQuestion();
if(PrefCheckBox.getPref().get("dwz"))
articleStudy();
if(PrefCheckBox.getPref().get("kspnews"))
videoStudy_news();
if(PrefCheckBox.getPref().get("kspbailing"))
videoStudy_bailing();
threads.shutDownAll();
console.hide();
engines.stopAll();
exit();
});
});
ui.sauc.click(function () {
thread = threads.start(function () {
zCount = parseInt(ui.zCount.getText());
lCount = parseInt(ui.lCount.getText());
qCount = parseInt(ui.qCount.getText());
zCount = parseInt(ui.zCount.getText());
vTime = parseInt(ui.vTime.getText());
vTime = parseInt(ui.vTime.getText());
vCount = parseInt(ui.vCount.getText());
zsyNext = parseInt(ui.zsyNext.getText());
zsyWaitTime = parseInt(ui.zsyWaitTime.getText());
customize_flag = true;
launchApp("学习强国");
sau();
threads.shutDownAll();
console.hide();
engines.stopAll();
exit();
});
});
var storage = storages.create("todoList");
//从storage获取todo列表
var todoList = storage.get("items", [
{
title: "请添加账户,请务必不要删除此条",
summary: "点击加号添加,长按用户名删除"
}
]);
ui.todoList.setDataSource(todoList);
ui.todoList.on("item_long_click", function (e, item, i, itemView, listView) {
confirm("确定要删除" + item.title + "吗?")
.then(ok => {
if (ok) {
todoList.splice(i, 1);
}
});
e.consumed = true;
});
//当离开本界面时保存todoList
ui.emitter.on("pause", () => {
storage.put("items", todoList);
});
ui.add.on("click", () => {
dialogs.rawInput("请输入用户名(电话号码)")
.then(title => {
if (!title) {
return;
}
dialogs.rawInput("请输入密码")
.then(summary => {
todoList.push({
title: title,
summary: summary
});
});
})
});
//创建选项菜单(右上角)
ui.emitter.on("create_options_menu", menu=>{
menu.add("协议");
menu.add("关于");
menu.add("说明");
});
//监听选项菜单点击
ui.emitter.on("options_item_selected", (e, item)=>{
switch(item.getTitle()){
case "协议":
alert("协议", "免责声明:本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!\n如果继续使用此应用即代表您同意此协议");
break;
case "关于":
alert("关于", "自动学习强国 v3.0.0 Alpha1,徐子越制作");
break;
case "说明":
alert("使用说明",
"〇程序需要 悬浮窗 和 无障碍权限(设置→辅助功能→无障碍→本 APP)\n 〇程序工作原理为模拟点击,基于Auto.js框架+JavaScript脚本执行 \n 〇程序不支持每周答题,专项答题,订阅。正常执行完毕42分(可执行前手动答题,答题完毕学习强国请返回主界面; 也可执行中手动辅助答题,以手动点击为准) \n 〇积分判断执行:读取今日积分确定需执行任务,任务精准,但部分手机可能不支持(积分获取正常推荐使用) \n 〇循序依次执行:预置每日积分所需执行任务数,不判断积分,依次执行所有任务(积分获取返回null或报错使用) \n ◎请确保进入学习强国时位于 主界面,模拟点击从主界面开始 \n ◎因存在文章误点击视频,多次重复点击同一文章视频问题,有概率造成循环执行,请手动补学 \n ◎安卓版本低于安卓7,无法执行收藏评论转发,文章界面模拟滑动 \n ◎测试机型:Redmi 6,Android 9,MiUI 11开发版,Honor 8 Lite \n ★代码基于以下项目实现(UI及其它有所更改):Auto.js https://github.com/hyb1996/Auto.js \n LazyStudy https://github.com/lolisaikou/LazyStudy \n AutoLearnChina https://github.com/gzhjic/LearnChinaHelper \n XXQG-Helper https://github.com/ivanwhaf/xxqg-helper \n ●免责声明:本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!"
);
break;
}
e.consumed = true;
});
activity.setSupportActionBar(ui.toolbar);
//设置滑动页面的标题
ui.viewpager.setTitles(["自动", "配置", "题库", "更新记录", "xzy的网站", "账户管理"]);
//让滑动页面和标签栏联动
ui.tabs.setupWithViewPager(ui.viewpager);
//让工具栏左上角可以打开侧拉菜单
ui.toolbar.setupWithDrawer(ui.drawer);
//进度条不可见
ui.run(() => { ui.pbar.setVisibility(View.INVISIBLE);});
ui.menu.setDataSource([
{
title: "作者官网:http://xzy.center/",
icon: "@drawable/ic_android_black_48dp"
},
{
title: "退出",
icon: "@drawable/ic_exit_to_app_black_48dp"
}
]);
ui.menu.on("item_click", item => {
switch(item.title){
case "退出":
ui.finish();
break;
}
})
ui.webview.loadUrl("http://xzy.center/");
ui.click_me.on("click", ()=>{
toast("选择'自动学习强国'开启无障碍");
engines.execScript("选择'自动学习强国'开启无障碍","auto.waitFor();console.show();console.hide();");
});
var thread = null;
//查询
ui.search.click(() => {
//预先初始化
qaArray = [];
threads.shutDownAll();
ui.run(() => {
ui.question.setText("");
ui.answer.setText("");
ui.questionIndex.setText("0");
ui.questionCount.setText("0");
});
//查询开始
threads.start(function () {
if (ui.keyword.getText() != "") {
var keyw = ui.keyword.getText();
if (ui.rbQuestion.checked) {//按题目搜
var sqlStr = util.format("SELECT question,answer FROM tiku WHERE %s LIKE '%%%s%'", "question", keyw);
} else {//按答案搜
var sqlStr = util.format("SELECT question,answer FROM tiku WHERE %s LIKE '%%%s%'", "answer", keyw);
}
qaArray = tikuCommon.searchDb(keyw, "tiku", sqlStr);
var qCount = qaArray.length;
if (qCount > 0) {
ui.run(() => {
ui.question.setText(qaArray[0].question);
ui.answer.setText(qaArray[0].answer);
ui.questionIndex.setText("1");
ui.questionCount.setText(String(qCount));
});
} else {
toastLog("未找到");
ui.run(() => {
ui.question.setText("未找到");
});
}
} else {
toastLog("请输入关键字");
}
});
});
//最近十条
ui.lastTen.click(() => {
threads.start(function () {
var keyw = ui.keyword.getText();
qaArray = tikuCommon.searchDb(keyw, "", "SELECT question,answer FROM tiku ORDER BY rowid DESC limit 10");
var qCount = qaArray.length;
if (qCount > 0) {
//toastLog(qCount);
ui.run(() => {
ui.question.setText(qaArray[0].question);
ui.answer.setText(qaArray[0].answer);
ui.questionIndex.setText("1");
ui.questionCount.setText(qCount.toString());
});
} else {
toastLog("未找到");
ui.run(() => {
ui.question.setText("未找到");
});
}
});
});
//上一条
ui.prev.click(() => {
threads.start(function () {
if (qaArray.length > 0) {
var qIndex = parseInt(ui.questionIndex.getText()) - 1;
if (qIndex > 0) {
ui.run(() => {
ui.question.setText(qaArray[qIndex - 1].question);
ui.answer.setText(qaArray[qIndex - 1].answer);
ui.questionIndex.setText(String(qIndex));
});
} else {
toastLog("已经是第一条了!");
}
} else {
toastLog("题目为空");
}
});
});
//下一条
ui.next.click(() => {
threads.start(function () {
if (qaArray.length > 0) {
//toastLog(qaArray);
var qIndex = parseInt(ui.questionIndex.getText()) - 1;
if (qIndex < qaArray.length - 1) {
//toastLog(qIndex);
//toastLog(qaArray[qIndex + 1].question);
ui.run(() => {
ui.question.setText(qaArray[qIndex + 1].question);
ui.answer.setText(qaArray[qIndex + 1].answer);
ui.questionIndex.setText(String(qIndex + 2));
});
} else {
toastLog("已经是最后一条了!");
}
} else {
toastLog("题目为空");
}
});
});
//修改
ui.update.click(() => {
threads.start(function () {
if (ui.question.getText() && qaArray.length > 0 && parseInt(ui.questionIndex.getText()) > 0) {
var qIndex = parseInt(ui.questionIndex.getText()) - 1;
var questionOld = qaArray[qIndex].question;
var questionStr = ui.question.getText();
var answerStr = ui.answer.getText();
var sqlstr = "UPDATE tiku SET question = '" + questionStr + "' , answer = '" + answerStr + "' WHERE question= '" + questionOld + "'";
tikuCommon.executeSQL(sqlstr);
} else {
toastLog("请先查询");
}
});
});
//删除
ui.delete.click(() => {
threads.start(function () {
if (qaArray.length > 0 && parseInt(ui.questionIndex.getText()) > 0) {
var qIndex = parseInt(ui.questionIndex.getText()) - 1;
var questionOld = qaArray[qIndex].question;
var sqlstr = "DELETE FROM tiku WHERE question = '" + questionOld + "'";
tikuCommon.executeSQL(sqlstr);
iff = iff - 1;
files.write("./if.txt", iff);
} else {
toastLog("请先查询");
}
});
});
//新增
ui.insert.click(() => {
threads.start(function () {
if (ui.question.getText() != "" && ui.answer.getText() != "") {
var questionStr = ui.question.getText();
var answerStr = ui.answer.getText();
var sqlstr = "INSERT INTO tiku VALUES ('" + questionStr + "','" + answerStr + "','')";
tikuCommon.executeSQL(sqlstr);
checkAndUpdate(questionStr, answerStr);
iff++;
files.write("./if.txt", iff);
} else {
toastLog("请先输入 问题 答案");
}
});
});
function reset() {
}
//重置
ui.reset.click(() => {
threads.shutDownAll();
threads.start(function () {
qaArray = [];
ui.run(() => {
ui.keyword.setText("");
ui.question.setText("");
ui.answer.setText("");
ui.questionIndex.setText("0");
ui.questionCount.setText("0");
ui.rbQuestion.setChecked(true);
});
toastLog("重置完毕!");
});
});
//更新网络题库
ui.updateTikuNet.click(() => {
dialogs.build({
title: "更新网络题库",
content: "确定更新?",
positive: "确定",
negative: "取消",
})
.on("positive", update)
.show();
function update() {
threads.start(function () {
/* ui.run(() => {
ui.resultLabel.setText("正在更新网络题库...");
ui.pbar.setVisibility(View.VISIBLE);
}); */
engines.execScriptFile("./update.js");
});
}
});
var path = files.path("list.db")
ui.listdel.click(() => {
var db = SQLiteDatabase.openOrCreateDatabase(path, null);
var Deletelistable = "DELETE FROM learnedArticles";
db.execSQL(Deletelistable);
db.close();
toastLog("已清空文章阅读记录!");
})
ui.daochu.click(() => {
dialogs.build({
title: "提示",
content: "这个操作会备份已学文章的数据库到\n/sdcard/Download文件夹下",
positive: "确定",
}).show();
files.copy(path, "/sdcard/Download/list.db");
toastLog("已将数据库复制到/sdcard/Download文件夹下");
});
ui.daoru.click(() => {
dialogs.build({
title: "提示",
content: "请确认文件已经放在\n/sdcard/Download文件夹下\n导入后会删除导出的文件!!\n如果需要请先备份!!",
positive: "确定",
negative: "取消",
}).on("positive", copy)
.show();
function copy() {
files.copy("/sdcard/Download/list.db", path);
toastLog("导入成功!");
files.remove("/sdcard/Download/list.db")
}
});
ui.save.click(function () {
aCatlog = ui.aCatlog.getText();
date_string = parseInt(ui.date_string.getText());
vCatlog = ui.vCatlog.getText();
s = ui.s.getText();
aCount = parseInt(ui.aCount.getText());
aTime = parseInt(ui.aTime.getText());
aZX = parseInt(ui.aZX.getText());
vCount = parseInt(ui.vCount.getText());
vTime = parseInt(ui.vTime.getText());
lCount = parseInt(ui.lCount.getText());
qCount = parseInt(ui.qCount.getText());
zCount = parseInt(ui.zCount.getText());
zsyNext = parseInt(ui.zsyNext.getText());
zsyWaitTime = parseInt(ui.zsyWaitTime.getText());
var ud = ui.ud.getText();
var bg = ui.bg.getText();
var config = aCount+" "+aTime+" "+aZX+" "+vCount+" "+vTime+" "+lCount+" "+zCount+" "+ud+" "+bg+" "+zsyNext+" "+zsyWaitTime;
files.write("./config.txt", config);
toast("保存成功");
});
ui.all.click(function () {
if (thread != null && thread.isAlive()) {
alert("注意", "脚本正在运行,请结束之前进程");
return;
}
toast("开始积分判断运行");
thread = threads.start(function () {
aCatlog = ui.aCatlog.getText();
vCatlog = ui.vCatlog.getText();
aZX = parseInt(ui.aZX.getText());
lCount = parseInt(ui.lCount.getText());
qCount = parseInt(ui.qCount.getText());
zCount = parseInt(ui.zCount.getText());
main();
});
});
ui.sau.click(function () {//切换账户
auto.waitFor();//等待获取无障碍辅助权限
if (thread != null && thread.isAlive()) {
alert("注意", "脚本正在运行,请结束之前进程");
return;
}
thread = threads.start(function () {
flagShut = 1;
//start_app();
console.show();
launchApp("学习强国");
sau();
threads.shutDownAll();
console.hide();
engines.stopAll();
exit();
});
});
ui.stop.click(function () {
if (thread != null && thread.isAlive()) {
threads.shutDownAll();
toast("停止运行!")
console.hide();
}
else {
toast("没有线程在运行!")
}
});
ui.about.click(function () {
alert("使用说明",
"〇程序需要 悬浮窗 和 无障碍权限(设置→辅助功能→无障碍→本 APP)\n 〇程序工作原理为模拟点击,基于Auto.js框架+JavaScript脚本执行 \n 〇程序不支持每周答题,专项答题,订阅。正常执行完毕42分(可执行前手动答题,答题完毕学习强国请返回主界面; 也可执行中手动辅助答题,以手动点击为准) \n 〇积分判断执行:读取今日积分确定需执行任务,任务精准,但部分手机可能不支持(积分获取正常推荐使用) \n 〇循序依次执行:预置每日积分所需执行任务数,不判断积分,依次执行所有任务(积分获取返回null或报错使用) \n ◎请确保进入学习强国时位于 主界面,模拟点击从主界面开始 \n ◎因存在文章误点击视频,多次重复点击同一文章视频问题,有概率造成循环执行,请手动补学 \n ◎安卓版本低于安卓7,无法执行收藏评论转发,文章界面模拟滑动 \n ◎测试机型:Redmi 6,Android 9,MiUI 11开发版,Honor 8 Lite \n ★代码基于以下项目实现(UI及其它有所更改):Auto.js https://github.com/hyb1996/Auto.js \n LazyStudy https://github.com/lolisaikou/LazyStudy \n AutoLearnChina https://github.com/gzhjic/LearnChinaHelper \n XXQG-Helper https://github.com/ivanwhaf/xxqg-helper \n ●免责声明:本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!"
)
});
ui.aCatlog.setText(aCatlog.toString());
ui.date_string.setText(date_string.toString());
ui.aCount.setText(aCount.toString());
ui.aTime.setText(aTime.toString());
ui.aZX.setText(aZX.toString());
ui.vCatlog.setText(vCatlog.toString());
ui.s.setText(s.toString());
ui.vCount.setText(vCount.toString());
ui.vTime.setText(vTime.toString());
ui.lCount.setText(lCount.toString());
ui.qCount.setText(qCount.toString());
ui.zCount.setText(zCount.toString());
ui.zsyNext.setText(zsyNext.toString());
ui.zsyWaitTime.setText(zsyWaitTime.toString());
function getTodayDateString() {
var date = new Date();
var y = date.getFullYear();
var m = date.getMonth();
var d = date.getDate();
var s = dateToString(y, m, d);//年,月,日
return s
}
function dateToString(y, m, d) {
var year = y.toString();
if ((m + 1) < 10) {
var month = "0" + (m + 1).toString();
} else {
var month = (m + 1).toString();
}
if (d < 10) {
var day = "0" + d.toString();
} else {
var day = d.toString();
}
var s = year + "-" + month + "-" + day;//年-月-日
return s;
}
/*
<---------------UI部分结束--------------->
*/
/**
* @description: 获取json数组元素个数函数
* @param: jsonData-json数据
* @return: null
*/
function getJsonLength(jsonData){
var jsonLength = 0;
for(var item in jsonData){
jsonLength++;
}
return jsonLength;
}
/**
* @description: 自动切换账户执行函数
* @param: todoList-账户列表
* @return: null
*/
function sau() {
JSON.stringify(todoList);
var todoListLength = getJsonLength(todoList);
toast(todoListLength);
if(todoListLength <=1){
alert("请先到账户配置页面添加账户!");
launchApp("自动学习强国");
return 0;
}
log("等待打开学习强国");
while(true){
if(id("home_bottom_tab_icon_large").exists()){
break;
}
if(id("btn_next").exists()){
break;
}
}
//while(!id("home_bottom_tab_icon_large").exists() || !id("btn_next").exists());
var i = 1;
//toast(todoListLength);
while(i<todoListLength){
log("开始第"+i+"个账户的执行,用户名:"+todoList[i].title);
if(id("home_bottom_tab_icon_large").exists()){
log("还没有退出登录,自动退出");
id("comm_head_xuexi_mine").findOne().click();
while(!id("my_setting").exists());
id("my_setting").findOne().click();
delay(2);
click("退出登录");
delay(2);
click("确认");
}
log("等待登陆按钮出现");
while(!id("user_avatar_login_tv").exists());
log("登录");
setText(0, todoList[i].title);
setText(1, todoList[i].summary);
id("btn_next").findOne().click();
log("等待加载出主页");
while(!id("home_bottom_tab_icon_large").exists());
if(customize_flag == true){
if(PrefCheckBox.getPref().get("CSA"))
CollectAndShareAndComment();
if(PrefCheckBox.getPref().get("weekly"))
weeklyQuestion();
if(PrefCheckBox.getPref().get("special"))
specialQuestion();
if(PrefCheckBox.getPref().get("zsy"))
zsyQuestion();
if(PrefCheckBox.getPref().get("cq"))
challengeQuestion();
if(PrefCheckBox.getPref().get("dq"))
dailyQuestion();
if(PrefCheckBox.getPref().get("sr"))
SRQuestion();
if(PrefCheckBox.getPref().get("dwz"))
articleStudy();
if(PrefCheckBox.getPref().get("kspnews"))
videoStudy_news();
if(PrefCheckBox.getPref().get("kspbailing"))
videoStudy_bailing();
}else{
log("开始判断积分执行");
aCatlog = ui.aCatlog.getText();
vCatlog = ui.vCatlog.getText();
aZX = parseInt(ui.aZX.getText());
lCount = parseInt(ui.lCount.getText());
qCount = parseInt(ui.qCount.getText());
zCount = parseInt(ui.zCount.getText());
main();
}
delay(2);
i = i+1;
}
}
/**
* @description: 新闻联播小视频学习计时(弹窗)函数
* @param: n-视频标号 seconds-学习秒数
* @return: null
*/
function video_timing_news(n, seconds) {
seconds = parseInt(seconds) + parseInt(random(0, 10));
for (var i = 0; i < seconds; i+=5) {
sleep(5000);
while (!text("播放").exists())//如果离开了联播小视频界面则一直等待
{
console.error("当前已离开第" + (n + 1) + "个新闻小视频界面,请重新返回视频");
delay(2);
}
console.info("第" + (n + 1) + "个小视频已经观看" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
toast("这是防息屏弹窗,请无视 awa");
}
}
/**
* @description: 广播学习计时(弹窗)函数
* @param: r_time-已经收听的时间 seconds-学习秒数
* @return: null
*/
function radio_timing(r_time, seconds) {
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 stopRadio() {
console.log("停止收听广播!");
click("电台");
delay(1);
click("听广播");
delay(2);
while (!(textContains("正在收听").exists() || textContains("最近收听").exists() || textContains("推荐收听").exists())) {
log("等待加载");
delay(2)
}
if (click("正在收听") == 0) {
click("最近收听");
}
delay(3);
id("v_play").findOnce(0).click();
delay(2)
if (id("btn_back").findOne().click() == 0) {