├── auto.js
├── autojs.js
├── readme.md
├── tikuCommon.js
├── 双人对战.mq
├── 多人对战.mq
├── 就要强国1.96-0312.apk
├── 就要强国_v0.9.9.apk
├── 挑战答题.mp4
├── 挑战答题.mq
├── 本地频道.mq
├── 查看积分.mq
├── 看视频.mq
├── 订阅.mq
├── 读文章.mq
└── 赞助.jpg
/auto.js:
--------------------------------------------------------------------------------
1 | "ui";
2 |
3 | ui.layout(
4 |
5 |
6 |
7 | 请选择订阅的栏目名:
8 |
9 |
10 |
11 | 请输入文章阅读次数推荐大于12
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | );
27 |
28 | ui.runjyqg.click(function () {
29 | var op1 = ui.op1.isChecked();
30 | var op2 = ui.op2.isChecked();
31 | var op3 = ui.op3.isChecked();
32 | var op4 = ui.op4.isChecked();
33 | var op5 = ui.op5.isChecked();
34 | var op6 = ui.op6.isChecked();
35 | var op7 = ui.op7.isChecked();
36 | var readnum = ui.readnum.getText()
37 | log("选读文章:" + op1, "\n看视频" + op2, "\n双人对战" + op3, "\n四人赛" + op4, "\n挑战答题" + op5, "\n订阅" + op6, "\n本地频道" + op7)
38 | threads.start(function () {
39 | var subscribeoption = ui.sp1.getSelectedItemPosition();
40 | main(op1, op2, op3, op4, op5, op6, op7, subscribeoption,readnum);
41 | })
42 | })
43 | ui.stopjyqg.click(function () {
44 | engines.stopAllAndToast()
45 | })
46 | ui.sponsor.click(function () {
47 | app.openUrl("https://zjzdmc.top/jsfx/48.html")
48 | toast("点击文章页的赞赏即可,感谢支持!")
49 | })
50 |
51 |
52 | var screen_var = "";
53 | screen_var += "屏幕宽度:" + device.width;
54 | screen_var += ",屏幕高度:" + device.height;
55 | var commenttext = ["新时代的中国越来越好,生活质量不断提高", "全民族团结一致,艰苦奋斗,共创辉煌加油", "团结奋斗,努力实现伟大的中国梦加油加油", "贯彻新发展理念,构建新发展格局加油加油", "心里有牵挂,脚下有道路,眼中有方向加油", "同呼吸共命运心连心,共同建设强大的祖国", "支持党,支持国家!", "为实现中华民族伟大复兴而不懈奋斗!", "紧跟党走,毫不动摇!", "不忘初心,牢记使命", "努力奋斗,报效祖国!"]; // 评论
56 | var xvar = 8; // 选读文章次数
57 | var svar = 10; // 看视频次数
58 | var xtime = 120; // 单篇文章阅读时间
59 | var stimes = 600; // 看视频总时间
60 | var dian = 0; // 加载
61 | function goSleep(seconds) {
62 | sleep(1000 * seconds); // 睡眠seconds秒
63 | }
64 | function advertisement() {
65 | console.log("广告---耐心等待");
66 | app.openUrl("https://zjzdmc.top");
67 | for (let readTime = 0; readTime < 6000;) {
68 | if (readTime <= 30000) {
69 | swipe(readX, readH1, readX, readH2 - 200, 1000);
70 | goSleep(2);
71 | log("滑动次数+1");
72 | readTime += 500;
73 | click(random(60, 1000), random(60, 1660))
74 | }
75 | else {
76 | swipe(readX, readH2 + 200, readX, readH1, 1000);
77 | goSleep(2);
78 | log("滑动次数+1");
79 | readTime += 500;
80 | click(random(60, 1000), random(60, 1660))
81 | }
82 | }
83 | home();
84 | }
85 | function starStudy() {
86 | toast("请自行结束学习强国进程");
87 | home();
88 | goSleep(10);
89 | if (app.launchApp('学习强国')) {
90 | log("启动中...");
91 | while (true) {
92 | if (id("home_bottom_tab_icon_large").exists()) {
93 | log("启动成功");
94 | break;
95 | }
96 | else {
97 | if (dian == 1) {
98 | log("启动中..");
99 | }
100 | else if (dian == 2) {
101 | log("启动中.");
102 | }
103 | else if (dian == 3) {
104 | log("启动中...");
105 | dian = 0
106 | }
107 | sleep(2000);
108 | dian++;
109 | }
110 | }
111 | sleep(5000);
112 | }
113 | else {
114 | log("应用不存在,请下载!");
115 | }
116 | }
117 |
118 | var screenWidth = device.width;
119 | var screenHeight = device.height;
120 | var readRandom = random(0, 2)
121 | var readGenres = ["推荐", "要闻", "综合"];
122 | var readNum = 12;
123 | var readX = (screenWidth / 3) * 2;
124 | var readH1 = (screenHeight / 6) * 5;
125 | var readH2 = (screenHeight / 6);
126 | var readCommentRandom = random(0, commenttext.length - 1);
127 |
128 | var readPlaces = ["“学习强国”学习平台", "新华社", "人民日报", "人民日报客户端"];
129 | function read(readnum) {
130 | if(readnum < 12){
131 | toast("阅读次数为"+readnum+"次,少于规定次数,以设置为12次")
132 | readNum = 12;
133 | }
134 | else {
135 | readNum = readnum;
136 | }
137 | goSleep(3);
138 | let readGenre = readGenres[readRandom];
139 | log(readGenre);
140 | click(readGenre);
141 | goSleep(1);
142 | for (var readnot = 0; readnot < readNum;) {
143 | click("“学习强国”学习平台"); //先进入一个文章页,然后判断是否是文章页
144 | goSleep(1)
145 | let readJudge = true;
146 | while (readJudge) {
147 | if (className("android.widget.TextView").text("欢迎发表你的观点").exists()) {
148 | readJudge = false;
149 | log("在文章页");
150 | break; // 判断是否存在评论
151 | }
152 | else {
153 | if (id("home_bottom_tab_icon_large").exists()) {
154 | className("ListView").scrollForward(); // 翻页
155 | log("在主页");
156 | let readPlace = readPlaces[random(0, readPlaces.length - 1)]
157 | click(readPlace);
158 | }
159 | else {
160 | back();
161 | className("ListView").scrollForward(); // 翻页
162 | log("不在文章页");
163 | goSleep(2);
164 | let readPlace = readPlaces[random(0, readPlaces.length - 1)]
165 | click(readPlace);
166 | goSleep(5);
167 | }
168 | }
169 | }
170 | goSleep(3);
171 | if (className("android.widget.RelativeLayout").clickable(true).depth(11).exists()) {
172 | className("android.widget.RelativeLayout").clickable(true).depth(11).findOne().click(); // 播放
173 | }
174 | else {
175 | log("播放不存在,打开的是视频页面")
176 | }
177 | goSleep(1);
178 | for (let readTime = 0; readTime <= 60000;) {
179 | if (readTime <= 30000) {
180 | swipe(readX, readH1, readX, readH2 - 200, 1000);
181 | goSleep(5);
182 | log("滑动次数+1");
183 | readTime += 6000;
184 | }
185 | else {
186 | swipe(readX, readH2 + 200, readX, readH1, 1000);
187 | goSleep(5);
188 | log("滑动次数+1");
189 | readTime += 6000;
190 | }
191 | }// 滑动文章
192 | goSleep(3);
193 | if (readnot == 3) {
194 | className("android.widget.TextView").text("欢迎发表你的观点").findOne().click();
195 | className("android.widget.EditText").findOne().click();
196 | setText(commenttext[readCommentRandom]);
197 | goSleep(1);
198 | className("android.widget.TextView").text("发布").findOne().click()
199 | goSleep(2);
200 | click("删除");
201 | goSleep(1);
202 | click("确认");
203 | log("评论成功");
204 | }
205 | else if (readnot == 1&&readnot ==5) {
206 | className("ImageView").drawingOrder(4).findOnce().click(); // 点击分享按钮
207 | goSleep(1);
208 | click("分享到学习强国");
209 | goSleep(1);
210 | click("创建新的聊天");
211 | goSleep(1);
212 | click("好友");
213 | goSleep(2);
214 | back();
215 | goSleep(1);
216 | back();
217 | goSleep(1);
218 | back();
219 | // 分享
220 | }
221 | goSleep(2);
222 | readnot += 1;
223 | log("已经阅读完" + readnot + "次");
224 | back();
225 | goSleep(3);
226 | className("ListView").scrollForward(); // 翻页
227 | goSleep(3)
228 | }
229 | }
230 | function video() {
231 | click("百灵");
232 | goSleep(10);
233 | className("android.widget.FrameLayout").depth(24).focusable(false).indexInParent(0).click();
234 | goSleep(2)
235 | while(true){
236 | if(className("android.widget.ImageView").depth(17).focusable(false).indexInParent(0).exists()){
237 | log("点击成功");
238 | break;
239 | }
240 | else {
241 | back();
242 | goSleep(2);
243 | className("android.widget.FrameLayout").depth(24).focusable(false).indexInParent(0).click();
244 | goSleep(2);
245 | }
246 | }
247 | goSleep(2)
248 | if(click("继续播放")){
249 | log("已用流量开始播放视频")
250 | }
251 | goSleep(600);//等待10min
252 | back();
253 | }
254 | function thinkIsInHomepage(){
255 | goSleep(5);
256 | if(id("home_bottom_tab_icon_large").exists()){
257 | console.log("在主页");
258 | }
259 | else {
260 | back();
261 | back();
262 | back();
263 | back();
264 | goSleep(2)
265 | starStudy();
266 | }
267 | }
268 | function dayAnswer() {
269 | click("我的");
270 | goSleep(1);
271 | click("学习积分");
272 | goSleep(1);
273 | swipe(300, 800, 300, 400, 500);
274 | goSleep(1);
275 | click("去答题");
276 | }
277 | function toTubscribe(subscribeoption) {
278 | click("订阅");
279 | goSleep(1);
280 | click("添加");
281 | goSleep(2);
282 | if (subscribeoption == 0) {
283 | subscribeoption = "推荐";
284 | }
285 | else if (subscribeoption == 1) {
286 | subscribeoption = "上新";
287 | }
288 | else if (subscribeoption == 2) {
289 | subscribeoption = "主要央媒";
290 | }
291 | else if (subscribeoption == 3) {
292 | subscribeoption = "行业媒体";
293 | }
294 | else if (subscribeoption == 4) {
295 | subscribeoption = "机关企事业单位";
296 | }
297 | else if (subscribeoption == 5) {
298 | subscribeoption = "高校";
299 | }
300 | else if (subscribeoption == 6) {
301 | subscribeoption = "地方媒体";
302 | }
303 | else if (subscribeoption == 7) {
304 | subscribeoption = "社会机构";
305 | }
306 | else {
307 | subscribeoption = "推荐";
308 | }
309 | log("用户建议通过" + subscribeoption + "来订阅")
310 | className("android.view.View").desc(subscribeoption).findOne().click()
311 | goSleep(2);
312 | for (let tubscrtibe = 0; tubscrtibe < 2;) {
313 | let notSubscribeNum = 0;
314 | if (className("android.view.View").depth(16).exists()) {
315 | className("android.view.View").depth(16).click();
316 | }
317 | else {
318 | back();
319 | }
320 | goSleep(3);
321 | if (className("android.widget.ImageView").desc("订阅").exists()) {
322 | goSleep(2);
323 | click("订阅");
324 | log("订阅成功");
325 | goSleep(2);
326 | back();
327 | goSleep(2);
328 | tubscrtibe += 1;
329 | }
330 | else {
331 | notSubscribeNum += 1;
332 | }
333 | goSleep(2)
334 | if (className("android.widget.Button").exists()) {
335 | console.log("在订阅页");
336 | }
337 | else {
338 | console.log("返回");
339 | var a = back();
340 | }
341 | goSleep(2)
342 | if(click("添加")){
343 | log("点击添加")
344 | };
345 | goSleep(2);
346 | swipe(600, 900, 600, 617, 500);
347 | goSleep(2);
348 | let subscribeDesc = ["推荐","上新","主要央媒","行业媒体","机关企事业单位","高校","地方媒体","社会机构"];
349 | let subscribeDescRandom = random(0,subscribeDesc.length-1);
350 | if(className("android.view.View").depth(15).indexInParent(10).exists()){
351 | if(className("android.view.View").depth(15).indexInParent(10).exists()){
352 | className("android.view.View").desc(subscribeDesc[subscribeDescRandom]).findOne().click();
353 | goSleep(3);
354 | }
355 |
356 | }
357 | if(notSubscribeNum == 20){
358 | toast("没有找到合适的订阅号,请稍后任务完成自行订阅");
359 | break;
360 | }
361 | }
362 | back();
363 | }
364 |
365 | function toLocation() {
366 | click("北京");
367 | goSleep(1)
368 | click("北京学习平台");
369 | goSleep(3);
370 | back();
371 | }
372 |
373 |
374 | function doubleFight() {
375 | click("我的");
376 | goSleep(2);
377 | click("我要答题")
378 | goSleep(2);
379 | className("android.view.View").depth(22).indexInParent(9).click(); // 双人对战
380 | goSleep(2);
381 | className("android.view.View").text("").findOne().click();
382 | goSleep(2)
383 | if(className("android.widget.Button").exists()){
384 | click("知道了");
385 | goSleep(2);
386 | className("android.view.View").text("").findOne().click();
387 | }
388 | goSleep(15)
389 | for (let runNum = 0; runNum < 1;) {
390 | let listArray = className("ListView").findOnce().children();//题目选项列表
391 | let i = random(0, listArray.length - 1);
392 | log("随机点击");
393 | listArray[i].child(0).click();//随意点击一个答案
394 | goSleep(5);
395 | if (className("android.view.View").text(" 继续加油!").exists()) {
396 | runNum += 1;
397 | log("继续加油");
398 | goSleep(1);
399 | }
400 | else if (className("android.view.View").text(" 获得胜利!").exists()) {
401 | runNum += 1;
402 | log("获得胜利");
403 | goSleep(1);
404 | }
405 | }
406 | goSleep(2);
407 | back();
408 | goSleep(2);
409 | className("android.view.View").text("").findOne().click()
410 | goSleep(2);
411 | while(true){
412 | if(className("android.widget.Button").text("退出").exists){
413 | className("android.widget.Button").text("退出").findOne().click();
414 | break;
415 | }
416 | else {
417 | className("android.view.View").text("").findOne().click()
418 | }
419 | }
420 | goSleep(2)
421 | back();
422 | goSleep(2);
423 | back();
424 | }
425 | function runHigh() {
426 | click("我的");
427 | goSleep(2);
428 | click("我要答题")
429 | goSleep(2);
430 | className("android.view.View").depth(22).indexInParent(8).click(); // 四人赛
431 | goSleep(2);
432 | if(className("android.widget.Button").exists()){
433 | click("知道了");
434 | goSleep(2);
435 | click("开始比赛");
436 | }
437 | goSleep(2);
438 | click("开始比赛")
439 | goSleep(15);
440 | for (let runNum = 0; runNum < 2;) {
441 | let think = true;
442 | while (think) {
443 | let listArray = className("ListView").findOnce().children();//题目选项列表
444 | let i = random(0, listArray.length - 1);
445 | log("随机点击");
446 | listArray[i].child(0).click();//随意点击一个答案
447 | goSleep(5);
448 | if (className("android.view.View").text(" 继续加油!").exists()) {
449 | runNum += 1;
450 | log("继续加油");
451 | goSleep(2);
452 | think = false;
453 | }
454 | else if (className("android.view.View").text(" 获得胜利!").exists()) {
455 | runNum += 1;
456 | log("获得胜利");
457 | goSleep(2);
458 | think = false;
459 | }
460 | }
461 | if (runNum == 1) {
462 | think = true;
463 | click("继续挑战");
464 | log("第二轮");
465 | goSleep(10);
466 | click("开始比赛");
467 | goSleep(15);
468 | }
469 | }
470 | goSleep(2)
471 | back();
472 | goSleep(2);
473 | back();
474 | goSleep(2);
475 | back();
476 | goSleep(2);
477 | back();
478 | }
479 | function goChallenge() {
480 | click("我的");
481 | goSleep(2);
482 | click("我要答题")
483 | goSleep(2);
484 | className("android.view.View").depth(22).indexInParent(10).click(); // 挑战答题
485 | goSleep(5);
486 | for (let challengeNum = 0; challengeNum < 10; challengeNum++) {
487 | // 挑战答题搜索答案
488 | var questions = className("ListView").findOnce().parent().child(0).text();
489 | var re = new RegExp("[\u4E00-\u9FA5]{2,5}");
490 | var question = questions.match(re);
491 | var url = 'http://www.syiban.com/search/index/init.html?modelid=1&q=' + question;
492 | var res = http.get(url);
493 | var html = res.body.string();
494 | var re2 = new RegExp(';">答案:.*');
495 | var answer = html.match(re2);
496 | var re3 = new RegExp("[A-Z]");
497 | var answer2 = answer[0].match(re3);
498 | let option = 0
499 | if (answer2 == "B") {
500 | option = 1;
501 | }
502 | else if (answer2 == "C") {
503 | option = 2;
504 | }
505 | else if (answer2 == "D") {
506 | option = 3;
507 | }
508 | if (challengeNum > 6) {
509 | option = 1;
510 | }
511 | let listArray = className("ListView").findOnce().children();//题目选项列表
512 | listArray[option].child(0).click();//点击答案
513 | challengeNum + 1;
514 | goSleep(10);
515 | if (className("android.view.View").text("结束本局").exists()) {
516 | click("结束本局");
517 | goSleep(5);
518 | let challengeNiceText = String(className("android.view.View").depth(25).findOne().getText()); //获取本次答对xx
519 | let challengeNiceNumReRule = RegExp("10|[0-9]");
520 | let challengeNiceNum = challengeNiceText.match(challengeNiceNumReRule)[0] //匹配答对题数进行判断
521 | if (challengeNum > 5) {
522 | log("结束,答对" + challengeNum - 1 + "道题")
523 | back();
524 | goSleep(2);
525 | back();
526 | goSleep(2);
527 | back();
528 | goSleep(2);
529 | break;
530 | }
531 | else {
532 | log("重新开始,答对" + challengeNum - 1 + "道题")
533 | challengeNum = 0;
534 | log("重新开始");
535 | click("再来一局");
536 | goSleep(10);
537 | }
538 | }
539 | }
540 | }
541 | function main(op1, op2, op3, op4, op5, op6, op7, subscribeoption,readnum) {
542 | console.show();//开启提示
543 | if (!$floaty.checkPermission()) {
544 | // 没有悬浮窗权限,提示用户并跳转请求
545 | toast("本脚本需要悬浮窗权限来显示悬浮窗,请在随后的界面中允许并重新运行本脚本。");
546 | $floaty.requestPermission();
547 | exit();
548 | } else {
549 | console.log('已有悬浮窗权限');
550 | }
551 | var bbh = http.get("https://zjzdmc.top/autojsbbh.txt");
552 | var bbhhtml = bbh.body.string();
553 | if (bbhhtml == "1.01") {
554 | console.log("现在是最新版" + bbhhtml);
555 | }
556 | else {
557 | console.log("版本错误,已停止运行");
558 | engines.stopAll();
559 | }
560 | advertisement()
561 | starStudy();
562 | if (op1) {
563 | read(readnum);
564 | log("已经完成文章选读");
565 | thinkIsInHomepage();
566 | goSleep(10);
567 | }
568 | if (op3) {
569 | doubleFight();
570 | log("已经完成双人对战");
571 | thinkIsInHomepage();
572 | goSleep(10);
573 | }
574 | if (op4) {
575 | runHigh();
576 | log("已经完成四人赛");
577 | thinkIsInHomepage();
578 | goSleep(10);
579 | }
580 | if (op5) {
581 | goChallenge();
582 | log("已经完成挑战答题");
583 | thinkIsInHomepage();
584 | goSleep(10);
585 | }
586 | if (op6) {
587 | toTubscribe(subscribeoption);
588 | log("已经完成订阅");
589 | thinkIsInHomepage();
590 | goSleep(10);
591 | }
592 | if (op7) {
593 | toLocation();
594 | log("已经完成本地频道");
595 | thinkIsInHomepage();
596 | goSleep(10);
597 | }
598 | if (op2) {
599 | video();
600 | log("已经完成视频播放");
601 | goSleep(10);
602 | }
603 | log("执行完成");
604 | }
605 | //log(className("android.view.View").depth(23).indexInParent(1).findOne().getText())
606 |
--------------------------------------------------------------------------------
/autojs.js:
--------------------------------------------------------------------------------
1 | "ui";
2 |
3 | importClass(android.view.View);
4 | //db操作
5 | importClass(android.database.sqlite.SQLiteDatabase);
6 |
7 | var tikuCommon = require("./tikuCommon.js");
8 | let deviceWidth = device.width;
9 |
10 | let margin = parseInt(deviceWidth * 0.02);
11 |
12 | //开屏提示 2021-5-5xzy修改
13 | var iff = files.read("./if.txt");
14 | if (iff == ""){
15 | alert("必读说明", "免责声明:\n本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!\n如果继续使用此应用即代表您同意此协议\n说明:此应用仅适用于Android7.0以上的版本。\n打开应用后请先点击第一个按钮打开无障碍和悬浮窗权限,如果没有反应则是已经开启。\n随后点击默认执行按钮,程序会自动检测当前分数智能执行\n如果您要使用自定义执行及单个任务执行功能,请先在数据配置页配置数据\n特别鸣谢:晴天、翻滚的茄子、AIQiangguo\n正常执行可得42分\n请确保进入学习强国时位于 主界面,模拟点击从主界面开始");
16 | files.write("./if.txt", "1");
17 | }
18 |
19 | //载入配置2021.3.29xzy添加
20 | var confi = files.read("./config.txt");
21 | var conf = confi.split(" ");
22 |
23 |
24 |
25 |
26 |
27 | //检测更新和更新题库2021-5-5 xzy修改
28 | engines.execScriptFile("./update.js");
29 |
30 | lCount+" "+qCount+" "+zCount;
31 |
32 | var aCount = conf[0];//文章默认学习篇数
33 | var vCount = conf[3];//小视频默认学习个数
34 | var cCount = 2;//收藏+分享+评论次数
35 |
36 | var aTime = conf[1];//每篇文章学习-30秒 30*12≈360秒=6分钟
37 | var vTime = conf[4];//每个小视频学习60秒
38 | var rTime = 360;//音视频时长-6分钟
39 |
40 | var dyNum = 2;//订阅 2
41 | var commentText = ["支持党,支持国家!", "为实现中华民族伟大复兴而不懈奋斗!", "不忘初心,牢记使命"];//评论内容,可自行修改,大于5个字便计分
42 | var num = random(0, commentText.length - 1) ;//随机数
43 |
44 | var aCat = ["推荐","要闻","综合"];
45 | var aCatlog = aCat[num] ;//文章学习类别,随机取"推荐""要闻"、"新思想"
46 | var aZX = conf[2];//文章执行1或2脚本
47 | var date_string = getTodayDateString();//获取当天日期字符串
48 | var vCat = ["第一频道", "学习视频", "联播频道"];
49 | var vCatlog = vCat[num] ; //视频学习类别,随机取 "第一频道"、"学习视频"、"联播频道"
50 | if (num == 0){
51 | var s = "央视网";
52 | }else if (num == 1){
53 | var s = "央视新闻";
54 | }else {
55 | var s = "中央广播电视总台";
56 | }
57 |
58 | var lCount = conf[5];//挑战答题轮数
59 | var qCount = random(5, 7);//挑战答题每轮答题数(5~7随机)
60 | var zCount = conf[6];//争上游答题轮数
61 | var zsyzd =1;//争上游和双人对战是否自动做,1,2 默认自动1
62 | var oldaquestion;//争上游和对战答题循环,定义旧题目对比新题目用20201022
63 | var myScores = {};//分数
64 | //特殊题,特点:题目一样,答案不同
65 | var ZiXingTi = "选择词语的正确词形。"; //字形题
66 | var DuYinTi = "选择正确的读音。";//读音题 20201211
67 | var ErShiSiShi ="下列不属于二十四史的是。";//二十四史
68 |
69 | var customize_flag = false;//自定义运行标志
70 |
71 | /*
72 | <---------------UI部分开始--------------->
73 | xzy更新
74 | */
75 | //alert("协议及说明", "免责声明:\n本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!\n如果继续使用此应用即代表您同意此协议\n说明:此应用仅适用于Android7.0以上的版本。");
76 |
77 | var color = "#009688";
78 |
79 | //var txt = files.read("./运行日志.txt");
80 | var dbName = "tiku.db";//题库文件名
81 | var path = files.path(dbName);
82 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
83 | var sql = "SELECT * FROM tikuNet;";
84 | var cursor = db.rawQuery(sql, null);
85 | if (cursor.moveToFirst()) {
86 | var answer = cursor.getString(0);
87 | cursor.close();
88 | }
89 |
90 | ui.layout(
91 |
92 |
93 |
94 |
95 |
96 |
97 |
227 |
228 |
229 |
230 |
236 |
237 |
238 | );
239 |
240 | ui.v251.setText("v2.5.1:2021.4.1\n如想要提建议请去github,不要在赞赏里说\n1,自动更新题库\n2,保存配置\n3,修复读文章问题\n");
241 | ui.v250.setText("v2.5.0:2021.3.6\n特别鸣谢:github上的所有朋友\n1,每次打开检查更新\n2,添加第一次打开应用的判断\n");
242 | ui.v244.setText("v2.4.4:2021.2.17\n特别鸣谢:晴天、翻滚的茄子\n1,每次打开自动清空日志\n2,添加订阅功能\n3,添加函数名执行功能\n3,添加第一次打开应用的判断\n");
243 | ui.v240.setText("v2.4.0:2021.2.16\n1,修复适配问题\n2,更新UI\n3,更新协议及说明\n");
244 | ui.v220.setText("v2.2.0:2021.1.27\n1,添加争上游答题\n2,修复个别执行没有返回的问题\n3,添加协议及说明\n");
245 | ui.v204.setText("v2.0.4:2020.8.29\n1,添加应用安装检测\n2,修复视听学习不能加积分的bug\n");
246 | ui.v203.setText("v2.0.3:2020.8.28\n1,修复一些bug\n2,添加公告\n");
247 | ui.v202.setText("v2.0.2:2020.8.27\n1,修复选读文章bug\n2,添加更新记录\n");
248 | ui.v201.setText("v2.0.1:2020.8.27\n1,修复一些bug\n2,添加弹窗提示\n");
249 | ui.v200.setText("v2.0.0:2020.8.27\n1,修复视听学习及一些bug\n2,添加本地频道及分享功能\n3,更新UI界面\n4,添加一键刷积分\n");
250 | ui.v101.setText("v1.0.1:2020.8.26\n1,修复一些bug\n");
251 | ui.v100.setText("v1.0.0:2020.8.26\n原始版本,构建UI布局。添加选读文章及视听学习功能");
252 |
253 | //创建选项菜单(右上角)
254 | ui.emitter.on("create_options_menu", menu=>{
255 | menu.add("协议");
256 | menu.add("关于");
257 | menu.add("说明");
258 | });
259 | //监听选项菜单点击
260 | ui.emitter.on("options_item_selected", (e, item)=>{
261 | switch(item.getTitle()){
262 | case "协议":
263 | alert("协议", "免责声明:本程序只供个人学习Auto.js使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!\n如果继续使用此应用即代表您同意此协议");
264 | break;
265 | case "关于":
266 | alert("关于", "自动学习强国 v2.5.1");
267 | break;
268 | case "说明":
269 | alert("使用说明",
270 | "〇程序需要 悬浮窗 和 无障碍权限(设置→辅助功能→无障碍→本 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使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!"
271 | );
272 | break;
273 | }
274 | e.consumed = true;
275 | });
276 | activity.setSupportActionBar(ui.toolbar);
277 |
278 | //设置滑动页面的标题
279 | ui.viewpager.setTitles(["自动", "数据配置", "题库", "更新记录"]);
280 | //让滑动页面和标签栏联动
281 | ui.tabs.setupWithViewPager(ui.viewpager);
282 |
283 | //让工具栏左上角可以打开侧拉菜单
284 | ui.toolbar.setupWithDrawer(ui.drawer);
285 |
286 | //进度条不可见
287 | ui.run(() => { ui.pbar.setVisibility(View.INVISIBLE);});
288 |
289 | ui.menu.setDataSource([
290 | {
291 | title: "学习强国辅助2.5.1",
292 | icon: "@drawable/ic_android_black_48dp"
293 | },
294 | {
295 | title: "退出",
296 | icon: "@drawable/ic_exit_to_app_black_48dp"
297 | }
298 | ]);
299 |
300 | ui.menu.on("item_click", item => {
301 | switch(item.title){
302 | case "退出":
303 | ui.finish();
304 | break;
305 | }
306 | })
307 |
308 |
309 | ui.click_me.on("click", ()=>{
310 | toast("选择'强国辅助'开启无障碍");
311 | engines.execScript("选择'强国辅助'开启无障碍","auto.waitFor();console.show();console.hide();");
312 | });
313 |
314 | var thread = null;
315 |
316 |
317 | //查询
318 | ui.search.click(() => {
319 | //预先初始化
320 | qaArray = [];
321 | threads.shutDownAll();
322 | ui.run(() => {
323 | ui.question.setText("");
324 | ui.answer.setText("");
325 | ui.questionIndex.setText("0");
326 | ui.questionCount.setText("0");
327 | });
328 | //查询开始
329 | threads.start(function () {
330 | if (ui.keyword.getText() != "") {
331 | var keyw = ui.keyword.getText();
332 | if (ui.rbQuestion.checked) {//按题目搜
333 | var sqlStr = util.format("SELECT question,answer FROM tiku WHERE %s LIKE '%%%s%'", "question", keyw);
334 | } else {//按答案搜
335 | var sqlStr = util.format("SELECT question,answer FROM tiku WHERE %s LIKE '%%%s%'", "answer", keyw);
336 | }
337 | qaArray = tikuCommon.searchDb(keyw, "tiku", sqlStr);
338 | var qCount = qaArray.length;
339 | if (qCount > 0) {
340 | ui.run(() => {
341 | ui.question.setText(qaArray[0].question);
342 | ui.answer.setText(qaArray[0].answer);
343 | ui.questionIndex.setText("1");
344 | ui.questionCount.setText(String(qCount));
345 | });
346 | } else {
347 | toastLog("未找到");
348 | ui.run(() => {
349 | ui.question.setText("未找到");
350 | });
351 | }
352 | } else {
353 | toastLog("请输入关键字");
354 | }
355 | });
356 | });
357 |
358 | //最近十条
359 | ui.lastTen.click(() => {
360 | threads.start(function () {
361 | var keyw = ui.keyword.getText();
362 | qaArray = tikuCommon.searchDb(keyw, "", "SELECT question,answer FROM tiku ORDER BY rowid DESC limit 10");
363 | var qCount = qaArray.length;
364 | if (qCount > 0) {
365 | //toastLog(qCount);
366 | ui.run(() => {
367 | ui.question.setText(qaArray[0].question);
368 | ui.answer.setText(qaArray[0].answer);
369 | ui.questionIndex.setText("1");
370 | ui.questionCount.setText(qCount.toString());
371 | });
372 | } else {
373 | toastLog("未找到");
374 | ui.run(() => {
375 | ui.question.setText("未找到");
376 | });
377 | }
378 | });
379 | });
380 |
381 | //上一条
382 | ui.prev.click(() => {
383 | threads.start(function () {
384 | if (qaArray.length > 0) {
385 | var qIndex = parseInt(ui.questionIndex.getText()) - 1;
386 | if (qIndex > 0) {
387 | ui.run(() => {
388 | ui.question.setText(qaArray[qIndex - 1].question);
389 | ui.answer.setText(qaArray[qIndex - 1].answer);
390 | ui.questionIndex.setText(String(qIndex));
391 | });
392 | } else {
393 | toastLog("已经是第一条了!");
394 | }
395 | } else {
396 | toastLog("题目为空");
397 | }
398 | });
399 | });
400 |
401 | //下一条
402 | ui.next.click(() => {
403 | threads.start(function () {
404 | if (qaArray.length > 0) {
405 | //toastLog(qaArray);
406 | var qIndex = parseInt(ui.questionIndex.getText()) - 1;
407 | if (qIndex < qaArray.length - 1) {
408 | //toastLog(qIndex);
409 | //toastLog(qaArray[qIndex + 1].question);
410 | ui.run(() => {
411 | ui.question.setText(qaArray[qIndex + 1].question);
412 | ui.answer.setText(qaArray[qIndex + 1].answer);
413 | ui.questionIndex.setText(String(qIndex + 2));
414 | });
415 | } else {
416 | toastLog("已经是最后一条了!");
417 | }
418 | } else {
419 | toastLog("题目为空");
420 | }
421 | });
422 | });
423 |
424 | //修改
425 | ui.update.click(() => {
426 | threads.start(function () {
427 | if (ui.question.getText() && qaArray.length > 0 && parseInt(ui.questionIndex.getText()) > 0) {
428 | var qIndex = parseInt(ui.questionIndex.getText()) - 1;
429 | var questionOld = qaArray[qIndex].question;
430 | var questionStr = ui.question.getText();
431 | var answerStr = ui.answer.getText();
432 | var sqlstr = "UPDATE tiku SET question = '" + questionStr + "' , answer = '" + answerStr + "' WHERE question= '" + questionOld + "'";
433 | tikuCommon.executeSQL(sqlstr);
434 | } else {
435 | toastLog("请先查询");
436 | }
437 | });
438 | });
439 |
440 | //删除
441 | ui.delete.click(() => {
442 | threads.start(function () {
443 | if (qaArray.length > 0 && parseInt(ui.questionIndex.getText()) > 0) {
444 | var qIndex = parseInt(ui.questionIndex.getText()) - 1;
445 | var questionOld = qaArray[qIndex].question;
446 | var sqlstr = "DELETE FROM tiku WHERE question = '" + questionOld + "'";
447 | tikuCommon.executeSQL(sqlstr);
448 | iff = iff - 1;
449 | files.write("./if.txt", iff);
450 | } else {
451 | toastLog("请先查询");
452 | }
453 | });
454 | });
455 |
456 | //新增
457 | ui.insert.click(() => {
458 | threads.start(function () {
459 | if (ui.question.getText() != "" && ui.answer.getText() != "") {
460 | var questionStr = ui.question.getText();
461 | var answerStr = ui.answer.getText();
462 | var sqlstr = "INSERT INTO tiku VALUES ('" + questionStr + "','" + answerStr + "','')";
463 | tikuCommon.executeSQL(sqlstr);
464 | iff++;
465 | files.write("./if.txt", iff);
466 | } else {
467 | toastLog("请先输入 问题 答案");
468 | }
469 | });
470 | });
471 |
472 | function reset() {
473 |
474 | }
475 | //重置
476 | ui.reset.click(() => {
477 | threads.shutDownAll();
478 | threads.start(function () {
479 | qaArray = [];
480 | ui.run(() => {
481 | ui.keyword.setText("");
482 | ui.question.setText("");
483 | ui.answer.setText("");
484 | ui.questionIndex.setText("0");
485 | ui.questionCount.setText("0");
486 | ui.rbQuestion.setChecked(true);
487 | });
488 | toastLog("重置完毕!");
489 | });
490 | });
491 |
492 | //更新网络题库
493 | ui.updateTikuNet.click(() => {
494 | dialogs.build({
495 | title: "更新网络题库",
496 | content: "确定更新?",
497 | positive: "确定",
498 | negative: "取消",
499 | })
500 | .on("positive", update)
501 | .show();
502 |
503 | function update() {
504 | threads.start(function () {
505 | /* ui.run(() => {
506 | ui.resultLabel.setText("正在更新网络题库...");
507 | ui.pbar.setVisibility(View.VISIBLE);
508 | }); */
509 | engines.execScriptFile("./update.js");
510 | });
511 | }
512 | });
513 |
514 | var path = files.path("list.db")
515 |
516 | ui.listdel.click(() => {
517 |
518 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
519 |
520 | var Deletelistable = "DELETE FROM learnedArticles";
521 |
522 | db.execSQL(Deletelistable);
523 |
524 | db.close();
525 |
526 | toastLog("已清空文章阅读记录!");
527 |
528 | })
529 |
530 | ui.daochu.click(() => {
531 |
532 | dialogs.build({
533 |
534 | title: "提示",
535 |
536 | content: "这个操作会备份已学文章的数据库到\n/sdcard/Download文件夹下",
537 |
538 | positive: "确定",
539 |
540 | }).show();
541 |
542 | files.copy(path, "/sdcard/Download/list.db");
543 |
544 | toastLog("已将数据库复制到/sdcard/Download文件夹下");
545 |
546 | });
547 |
548 | ui.daoru.click(() => {
549 |
550 | dialogs.build({
551 |
552 | title: "提示",
553 |
554 | content: "请确认文件已经放在\n/sdcard/Download文件夹下\n导入后会删除导出的文件!!\n如果需要请先备份!!",
555 |
556 | positive: "确定",
557 |
558 | negative: "取消",
559 |
560 | }).on("positive", copy)
561 |
562 | .show();
563 |
564 | function copy() {
565 |
566 | files.copy("/sdcard/Download/list.db", path);
567 |
568 | toastLog("导入成功!");
569 |
570 | files.remove("/sdcard/Download/list.db")
571 |
572 | }
573 |
574 | });
575 |
576 | ui.save.click(function () {
577 | aCatlog = ui.aCatlog.getText();
578 | date_string = parseInt(ui.date_string.getText());
579 | vCatlog = ui.vCatlog.getText();
580 | s = ui.s.getText();
581 | aCount = parseInt(ui.aCount.getText());
582 | aTime = parseInt(ui.aTime.getText());
583 | aZX = parseInt(ui.aZX.getText());
584 | vCount = parseInt(ui.vCount.getText());
585 | vTime = parseInt(ui.vTime.getText());
586 | lCount = parseInt(ui.lCount.getText());
587 | qCount = parseInt(ui.qCount.getText());
588 | zCount = parseInt(ui.zCount.getText());
589 |
590 | var config = aCount+" "+aTime+" "+aZX+" "+vCount+" "+vTime+" "+lCount+" "+zCount;
591 | files.write("./config.txt", config);
592 | toast("保存成功");
593 | });
594 |
595 |
596 | ui.all.click(function () {
597 | if (thread != null && thread.isAlive()) {
598 | alert("注意", "脚本正在运行,请结束之前进程");
599 | return;
600 | }
601 | toast("开始积分判断运行");
602 | thread = threads.start(function () {
603 | aCatlog = ui.aCatlog.getText();
604 | vCatlog = ui.vCatlog.getText();
605 | aZX = parseInt(ui.aZX.getText());
606 | lCount = parseInt(ui.lCount.getText());
607 | qCount = parseInt(ui.qCount.getText());
608 | zCount = parseInt(ui.zCount.getText());
609 | main();
610 | });
611 | });
612 |
613 | ui.customize.click(function () {
614 | if (thread != null && thread.isAlive()) {
615 | alert("注意", "脚本正在运行,请结束之前进程");
616 | return;
617 | }
618 | toast("开始自定义运行");
619 | thread = threads.start(function () {
620 | aCatlog = ui.aCatlog.getText();
621 | date_string = parseInt(ui.date_string.getText());
622 | vCatlog = ui.vCatlog.getText();
623 | s = ui.s.getText();
624 | aCount = parseInt(ui.aCount.getText());
625 | aTime = parseInt(ui.aTime.getText());
626 | aZX = parseInt(ui.aZX.getText());
627 | vCount = parseInt(ui.vCount.getText());
628 | vTime = parseInt(ui.vTime.getText());
629 | lCount = parseInt(ui.lCount.getText());
630 | qCount = parseInt(ui.qCount.getText());
631 | zCount = parseInt(ui.zCount.getText());
632 | customize_flag = true;
633 | console.log('文章频道:' + aCatlog.toString() + '日期:' + date_string)
634 | console.log('文章数量:' + aCount.toString() + '篇')
635 | console.log('视频频道:' + vCatlog.toString() + '关键词' + s)
636 | console.log('视频数量:' + vCount.toString() + '个')
637 | main();
638 | });
639 | });
640 |
641 | ui.cq.click(function () {//挑战答题
642 | auto.waitFor();//等待获取无障碍辅助权限
643 | if (thread != null && thread.isAlive()) {
644 | alert("注意", "脚本正在运行,请结束之前进程");
645 | return;
646 | }
647 | thread = threads.start(function () {
648 | lCount = parseInt(ui.lCount.getText());
649 | qCount = parseInt(ui.qCount.getText());
650 | start_app();
651 | challengeQuestion();
652 | threads.shutDownAll();
653 | console.hide();
654 | engines.stopAll();
655 | exit();
656 | });
657 | });
658 |
659 | ui.dwz.click(function () {//挑战答题
660 | auto.waitFor();//等待获取无障碍辅助权限
661 | if (thread != null && thread.isAlive()) {
662 | alert("注意", "脚本正在运行,请结束之前进程");
663 | return;
664 | }
665 | thread = threads.start(function () {
666 | start_app();
667 | articleStudy();
668 | threads.shutDownAll();
669 | console.hide();
670 | engines.stopAll();
671 | exit();
672 | });
673 | });
674 |
675 | ui.dq.click(function () {//每日答题
676 | auto.waitFor();//等待获取无障碍辅助权限
677 | if (thread != null && thread.isAlive()) {
678 | alert("注意", "脚本正在运行,请结束之前进程");
679 | return;
680 | }
681 | thread = threads.start(function () {
682 | start_app();
683 | dailyQuestion();
684 | threads.shutDownAll();
685 | console.hide();
686 | engines.stopAll();
687 | exit();
688 | });
689 | });
690 |
691 | ui.sr.click(function () {//双人对战
692 | auto.waitFor();//等待获取无障碍辅助权限
693 | if (thread != null && thread.isAlive()) {
694 | alert("注意", "脚本正在运行,请结束之前进程");
695 | return;
696 | }
697 | thread = threads.start(function () {
698 | start_app();
699 | zCount = parseInt(ui.zCount.getText());
700 | SRQuestion();
701 | threads.shutDownAll();
702 | console.hide();
703 | engines.stopAll();
704 | exit();
705 | });
706 | });
707 |
708 | ui.zsy.click(function () {//争上游答题
709 | auto.waitFor();//等待获取无障碍辅助权限
710 | if (thread != null && thread.isAlive()) {
711 | alert("注意", "脚本正在运行,请结束之前进程");
712 | return;
713 | }
714 | thread = threads.start(function () {
715 | start_app();
716 | zCount = parseInt(ui.zCount.getText());
717 | zsyQuestion();
718 | threads.shutDownAll();
719 | console.hide();
720 | engines.stopAll();
721 | exit();
722 | });
723 | });
724 |
725 | ui.stop.click(function () {
726 | if (thread != null && thread.isAlive()) {
727 | threads.shutDownAll();
728 | toast("停止运行!")
729 | console.hide();
730 | }
731 | else {
732 | toast("没有线程在运行!")
733 | }
734 | });
735 |
736 | ui.about.click(function () {
737 | alert("使用说明",
738 | "〇程序需要 悬浮窗 和 无障碍权限(设置→辅助功能→无障碍→本 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使用,不得盈利传播,不得用于违法用途,否则造成的一切后果自负!"
739 | )
740 | });
741 |
742 |
743 | ui.aCatlog.setText(aCatlog.toString());
744 | ui.date_string.setText(date_string.toString());
745 | ui.aCount.setText(aCount.toString());
746 | ui.aTime.setText(aTime.toString());
747 | ui.aZX.setText(aZX.toString());
748 | ui.vCatlog.setText(vCatlog.toString());
749 | ui.s.setText(s.toString());
750 | ui.vCount.setText(vCount.toString());
751 | ui.vTime.setText(vTime.toString());
752 | ui.lCount.setText(lCount.toString());
753 | ui.qCount.setText(qCount.toString());
754 | ui.zCount.setText(zCount.toString());
755 |
756 |
757 | function getTodayDateString() {
758 | var date = new Date();
759 | var y = date.getFullYear();
760 | var m = date.getMonth();
761 | var d = date.getDate();
762 | var s = dateToString(y, m, d);//年,月,日
763 | return s
764 | }
765 |
766 | function dateToString(y, m, d) {
767 | var year = y.toString();
768 | if ((m + 1) < 10) {
769 | var month = "0" + (m + 1).toString();
770 | } else {
771 | var month = (m + 1).toString();
772 | }
773 | if (d < 10) {
774 | var day = "0" + d.toString();
775 | } else {
776 | var day = d.toString();
777 | }
778 | var s = year + "-" + month + "-" + day;//年-月-日
779 | return s;
780 | }
781 |
782 | // 上下
783 |
784 | function video_timing_bailing(n, seconds) {
785 | for (var i = 0; i < seconds; i++) {
786 | while (!textContains("分享").exists())//如果离开了百灵小视频界面则一直等待
787 | {
788 | console.error("当前已离开第" + (n + 1) + "个百灵小视频界面,请重新返回视频");
789 | delay(2);
790 | }
791 | sleep(1000);
792 | console.info("第" + (n + 1) + "个小视频已经观看" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
793 | }
794 | }
795 |
796 | function video_timing_news(n, seconds) {
797 | seconds = parseInt(seconds) + parseInt(random(0, 10));
798 | for (var i = 0; i < seconds; i++) {
799 | sleep(1000);
800 | while (!text("播放").exists())//如果离开了联播小视频界面则一直等待
801 | {
802 | console.error("当前已离开第" + (n + 1) + "个新闻小视频界面,请重新返回视频");
803 | delay(2);
804 | }
805 | console.info("第" + (n + 1) + "个小视频已经观看" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
806 | }
807 | }
808 |
809 | function radio_timing(r_time, seconds) {
810 | for (var i = 0; i < seconds; i++) {
811 | sleep(1000);
812 | if (i % 5 == 0)//每5秒打印一次信息
813 | {
814 | console.info("广播已经收听" + (i + 1 + r_time) + "秒,剩余" + (seconds - i - 1) + "秒!");
815 | }
816 | if (i % 15 == 0)//每15秒弹一次窗防止息屏
817 | {
818 | toast("这是防息屏弹窗,可忽略-. -");
819 | }
820 | }
821 | }
822 |
823 | function stopRadio() {
824 | console.log("停止收听广播!");
825 | click("电台");
826 | delay(1);
827 | click("听广播");
828 | delay(2);
829 | while (!(textContains("正在收听").exists() || textContains("最近收听").exists() || textContains("推荐收听").exists())) {
830 | log("等待加载");
831 | delay(2)
832 | }
833 | if (click("正在收听") == 0) {
834 | click("最近收听");
835 | }
836 | delay(3);
837 | id("v_play").findOnce(0).click();
838 | delay(2)
839 | if (id("btn_back").findOne().click() == 0) {
840 | delay(2);
841 | back();
842 | }
843 | }
844 |
845 | function getLearnedArticle(title, date) {
846 | rtitle = title.replace("'", "''");
847 | var dbName = "list.db";
848 | //文件路径
849 | var path = files.path(dbName);
850 | //确保文件存在
851 | if (!files.exists(path)) {
852 | // files.createWithDirs(path);
853 | console.error("未找到题库!请将题库放置与js同一目录下");
854 | }
855 | //创建或打开数据库
856 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
857 | var createTable = "\
858 | CREATE TABLE IF NOt EXISTS learnedArticles(\
859 | title CHAR(500),\
860 | date CHAR(100)\
861 | );";
862 | // var cleanTable = "DELETE FROM tikuNet";
863 | db.execSQL(createTable);
864 | // db.execSQL(cleanTable);
865 | var sql = "SELECT * FROM learnedArticles WHERE title = '" + rtitle + "' AND date = '" + date + "'";
866 | var cursor = db.rawQuery(sql, null);
867 | var res = cursor.moveToFirst();
868 | cursor.close();
869 | db.close();
870 | log(res);
871 | return res;
872 | }
873 |
874 | function insertLearnedArticle(title, date) {
875 | rtitle = title.replace("'", "''");
876 | var dbName = "list.db";
877 | var path = files.path(dbName);
878 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
879 | var createTable = "\
880 | CREATE TABLE IF NOt EXISTS learnedArticles(\
881 | title CHAR(253),\
882 | date CHAR(100)\
883 | );";
884 | // var cleanTable = "DELETE FROM tikuNet";
885 | db.execSQL(createTable);
886 | var sql = "INSERT INTO learnedArticles VALUES ('" + rtitle + "','" + date + "')";
887 | db.execSQL(sql);
888 | db.close();
889 | }
890 |
891 | function article_timing(n, seconds) {
892 | seconds = parseInt(seconds);
893 | var randNum = random(0, 10);
894 | randNum = parseInt(randNum); //惨痛的教训:这里必须要转成int类型,否则就成了几百秒 xzy 2021-5-5更新
895 | seconds = seconds + randNum;
896 | h = device.height;//屏幕高
897 | w = device.width;//屏幕宽
898 | x = (w / 3) * 2;
899 | h1 = (h / 6) * 5;
900 | h2 = (h / 6);
901 | for (var i = 0; i < seconds; i++) {
902 | while (!textContains("欢迎发表你的观点").exists())//如果离开了文章界面则一直等待
903 | {
904 | console.error("当前已离开第" + (n + 1) + "文章界面,请重新返回文章页面...");
905 | delay(2);
906 | }
907 | if (i % 5 == 0)//每5秒打印一次学习情况
908 | {
909 | console.info("第" + (n + 1) + "篇文章已经学习" + (i + 1) + "秒,剩余" + (seconds - i - 1) + "秒!");
910 | }
911 | sleep(1000);
912 | if (i % 10 == 0)//每10秒滑动一次,如果android版本<7.0请将此滑动代码删除
913 | {
914 | toast("这是防息屏toast,请忽视-。-");
915 | if (i <= seconds / 2) {
916 | swipe(x, h1, x, h2, 500);//向下滑动
917 | }
918 | else {
919 | swipe(x, h2, x, h1, 500);//向上滑动
920 | }
921 | }
922 | }
923 | }
924 |
925 |
926 | function articleStudy(x) {
927 | while (!desc("工作").exists());//等待加载出主页
928 | var listView = className("ListView");//获取文章ListView控件用于翻页
929 | if (x == 0) {
930 | desc("工作").click();//点击主页正下方的"学习"按钮
931 | delay(2);
932 | click(aCatlog);
933 | }
934 | delay(2);
935 | var zt_flag = false;//判断进入专题界面标志
936 | var fail = 0;//点击失败次数
937 | var date_string = getTodayDateString();//获取当天日期字符串
938 | for (var i = 0, t = 0; i < aCount;) {
939 | try {
940 | if ((id("general_card_title_id").findOnce(t).parent().parent().click() || id("general_card_title_id").findOnce(t).parent().parent().parent().click()) == true) {
941 | delay(5);
942 | // // delay(10); //等待加载出文章页面,后面判断是否进入了视频文章播放要用到
943 | //获取当前正在阅读的文章标题
944 | let n = 0;
945 | while (!textContains("欢迎发表你的观点").exists()) {//如果没有找到评论框则认为没有进入文章界面,一直等待
946 | delay(2);
947 | console.warn("正在等待加载文章界面...");
948 | if (n > 3) {//等待超过3秒则认为进入了专题界面,退出进下一篇文章
949 | console.warn("没找到评论框!该界面非文章界面!");
950 | zt_flag = true;
951 | break;
952 | }
953 | n++;
954 | }
955 | if (text("展开").exists()) {//如果存在“展开”则认为进入了文章栏中的视频界面需退出
956 | console.warn("进入了视频界面,退出并进入下一篇文章!");
957 | t++;
958 | back();
959 | if (rTime != 0) {
960 | while (!desc("工作").exists());
961 | console.info("因为广播被打断,重新收听广播...");
962 | delay(0.5);
963 | listenToRadio();//听电台广播
964 | while (!desc("工作").exists());
965 | desc("工作").click();
966 | }
967 | delay(2);
968 | continue;
969 | }
970 | if (zt_flag == true) {//进入专题页标志
971 | console.warn("进入了专题界面,即将退出并进下一篇文章!");
972 | t++;
973 | back();
974 | delay(2);
975 | zt_flag = false;
976 | continue;
977 | }
978 | var currentNewsTitle = ""
979 | if (id("xxqg-article-header").exists()) {
980 | currentNewsTitle = id("xxqg-article-header").findOne().child(0).text(); // 最终解决办法
981 | } else if (textContains("来源").exists()) {
982 | currentNewsTitle = textContains("来源").findOne().parent().children()[0].text();
983 | } else if (textContains("作者").exists()) {
984 | currentNewsTitle = textContains("作者").findOne().parent().children()[0].text();
985 | } else if (descContains("来源").exists()) {
986 | currentNewsTitle = descContains("来源").findOne().parent().children()[0].desc();
987 | } else if (descContains("作者").exists()) {
988 | currentNewsTitle = descContains("作者").findOne().parent().children()[0].desc();
989 | } else {
990 | console.log("无法定位文章标题,即将退出并阅读下一篇")
991 | t++;
992 | back();
993 | delay(2);
994 | continue;
995 | }
996 | if (currentNewsTitle == "") {
997 | console.log("标题为空,即将退出并阅读下一篇")
998 | t++;
999 | back();
1000 | delay(2);
1001 | continue;
1002 | }
1003 | var flag = getLearnedArticle(currentNewsTitle, date_string);
1004 | if (flag) {
1005 | //已经存在,表明阅读过了
1006 | console.info("该文章已经阅读过,即将退出并阅读下一篇");
1007 | t++;
1008 | back();
1009 | delay(2);
1010 | continue;
1011 | } else {
1012 | //没阅读过,添加到数据库
1013 | insertLearnedArticle(currentNewsTitle, date_string);
1014 | }
1015 | console.log("正在学习第" + (i + 1) + "篇文章,标题:", currentNewsTitle);
1016 | fail = 0;//失败次数清0
1017 | //开始循环进行文章学习
1018 | log(i+"next"+aTime);
1019 | article_timing(i, aTime);
1020 | delay(2);
1021 | back();//返回主界面
1022 | while (!desc("工作").exists());//等待加载出主页
1023 | delay(2);
1024 | i++;
1025 | t++;//t为实际点击的文章控件在当前布局中的标号,和i不同,勿改动!
1026 | } else {
1027 | t++;
1028 | }
1029 | } catch (e) {
1030 | listView.scrollForward();
1031 | t = 0;
1032 | delay(1.5);
1033 | }
1034 | }
1035 |
1036 | }
1037 |
1038 |
1039 | function videoStudy_news() {
1040 | delay(1)
1041 | desc("工作").click();
1042 | delay(2)
1043 | click("电视台");
1044 | delay(1)
1045 | click("联播频道");
1046 | delay(2);
1047 | var listView = className("ListView");//获取listView视频列表控件用于翻页
1048 | for (var i = 0, t = 0; i < vCount;) {
1049 | if ((click("中央广播电视总台", t) || click("央视网", t)) == true) {
1050 | console.log("即将学习第" + (i + 1) + "个视频!");
1051 | video_timing_news(i, vTime);//学习每个新闻联播小片段
1052 | back();//返回联播频道界面
1053 | while (!desc("工作").exists());//等待加载出主页
1054 | delay(1);
1055 | i++;
1056 | t++;
1057 | if (t >= 2) {//如果是平板等设备,请尝试修改i为合适值!
1058 | listView.scrollForward();//翻页
1059 | delay(2);
1060 | t = 0;
1061 | }
1062 | }
1063 | else {
1064 | listView.scrollForward();//翻页
1065 | delay(2);
1066 | t = 0;
1067 | }
1068 | }
1069 | }
1070 |
1071 |
1072 | function listenToRadio() {
1073 | click("电台");
1074 | delay(1);
1075 | click("听广播");
1076 | delay(2);
1077 | while (!(textContains("正在收听").exists() || textContains("最近收听").exists() || textContains("推荐收听").exists())) {
1078 | log("等待加载");
1079 | delay(1);
1080 | }
1081 | if (click("最近收听") == 0) {
1082 | if (click("推荐收听") == 0) {
1083 | click("正在收听");
1084 | }
1085 | }
1086 | delay(2);
1087 | if (id("btn_back").findOne().click() == 0) {
1088 | delay(2);
1089 | back();//返回电台界面
1090 | }
1091 | delay(2);
1092 | }
1093 |
1094 | function main() {
1095 | if (!judge_tiku_existence()) {//题库不存在则退出
1096 | return;
1097 | }
1098 | auto.waitFor();//等待获取无障碍辅助权限
1099 | start_app();//启动app
1100 | var start = new Date().getTime();//程序开始时间
1101 | if (customize_flag == true) {
1102 | //自定义学习,各项目执行顺序可换
1103 | localChannel1();//本地频道
1104 | zsyQuestion();//争上游答题
1105 | SRQuestion();//双人对战
1106 | challengeQuestion();//挑战答题
1107 | dailyQuestion();//每日答题
1108 | if (aZX == 1){
1109 | articleStudy1();//学习文章脚本1,包含点赞、分享和评论
1110 | }else{
1111 | articleStudy2();//学习文章脚本2,包含点赞、分享和评论
1112 | }
1113 | videoStudy_news();//看视频
1114 | }else {
1115 | getScores();//获取积分
1116 | while ( myScores["双人对战"] < 1 || myScores["争上游答题"] < 4 || myScores['本地频道'] != 1 || myScores['挑战答题'] != 6 || myScores['每日答题'] != 5 || myScores['视听学习'] != 6 || myScores['我要选读文章'] != 12 /*|| myScores['分享'] != 1 || myScores['发表观点'] != 1*/){
1117 | if (myScores['本地频道'] != 1) {
1118 | localChannel1();//本地频道
1119 | }
1120 | //if (myScores["争上游答题"] < 4) {
1121 | zsyQuestion();//争上游答题
1122 | //}
1123 | if (myScores["双人对战"] < 1) {
1124 | SRQuestion();//双人对战
1125 | }
1126 | if (myScores['挑战答题'] != 6) {
1127 | challengeQuestion();//挑战答题
1128 | }
1129 | if (myScores['每日答题'] != 5) {
1130 | dailyQuestion(); //每日答题
1131 | }
1132 | if (myScores['我要选读文章'] != 12) {
1133 | if (aZX == 1){
1134 | articleStudy1();//学习文章脚本1,包含点赞、分享和评论
1135 | }else{
1136 | articleStudy2();//学习文章脚本2,包含点赞、分享和评论
1137 | }
1138 | }
1139 | if (myScores['视听学习'] != 6){
1140 | videoStudy_news();//看视频
1141 | }
1142 | getScores();//再次获取积分,核对文章和视听时长,补学
1143 | continue;//break结束当前循环,continue继续执行当前循环
1144 | }
1145 | if (myScores['分享'] != 1 || myScores['发表观点'] != 1){
1146 | aCount = 2;//置文章数2,学习文章2,启动分享收藏评论2
1147 | articleStudy1(); //收藏+分享 若c运行到此报错请注释本行!
1148 | }
1149 | if (myScores['视听学习时长'] != 6){
1150 | listenToRadio();//听电台广播补视听时长
1151 | }
1152 | }
1153 | var end = new Date().getTime();
1154 | console.log("运行结束,共耗时" + (parseInt(end - start)) / 1000 + "秒");
1155 | threads.shutDownAll();
1156 | console.hide();
1157 | engines.stopAll();
1158 | exit();
1159 | }
1160 |
1161 | function start_app() {
1162 | console.setPosition(0, device.height / 2);//部分华为手机console有bug请注释本行
1163 | console.show();//部分华为手机console有bug请注释本行
1164 | console.log("启动学习强国");
1165 | if (!launchApp("学习强国")){//启动学习强国app
1166 | console.error("找不到学习强国App!");
1167 | return;
1168 | }
1169 | delay(3); //如果已清理强国app后台,默认打开主页;如果未清理后台,3秒应该可以拉起强国app
1170 | if (className("android.view.View").text("继续挑战").exists()){//双人对战 争上游结束页
1171 | back(); delay(1); }
1172 | if (className("android.view.View").text("开始对战").exists()){//双人对战开始页
1173 | back(); delay(1); }
1174 | if (className("android.widget.Button").text("退出").exists()){//双人对战退出房间
1175 | className("android.widget.Button").text("退出").findOne().click();
1176 | back(); delay(1); }
1177 | if (className("android.view.View").text("开始比赛").exists()){//争上游答题开始页
1178 | back(); delay(1); }
1179 | if (className("android.view.View").text("答题练习").exists()){//我要答题页
1180 | back(); delay(1); }
1181 | if (id("menu_contact").exists()){//强国通讯录
1182 | id("home_bottom_tab_button_work").findOne().click();
1183 | delay(1); }
1184 | if (id("more_text").exists()){//学习积分页
1185 | back(); delay(1); }
1186 | if (id("my_display_name").exists()){//我的主页
1187 | back(); delay(1); }
1188 | /*while (!id("home_bottom_tab_button_work").exists()){
1189 | back();delay(2);
1190 | continue;
1191 | } */ //适合内部返回主页,不适合已清理强国后台情况下初始拉起强国app
1192 | while (!id("home_bottom_tab_button_work").exists()) {//20201001 学习按钮文字属性由"学习"改为 "工作",以下所有点击学习按钮加载主页均同步修改
1193 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1194 | console.log("等待加载出主页");
1195 | delay(1);
1196 | continue;/*break;exists(); back();*/
1197 | }
1198 | delay(1);
1199 | }
1200 |
1201 | function delay(seconds) {
1202 | sleep(1000 * seconds);//sleep函数参数单位为毫秒所以乘1000
1203 | }
1204 |
1205 | function getScores() {
1206 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1207 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1208 | delay(2);
1209 | console.log("正在获取积分...");
1210 | while (!text("积分明细").exists()) {//自主页点击右上角积分数字进入学习积分
1211 | if (id("comm_head_xuexi_score").exists()) {
1212 | id("comm_head_xuexi_score").findOnce().click();
1213 | } else if (text("积分").exists()) {
1214 | text("积分").findOnce().parent().child(1).click();
1215 | } else if (id("comm_head_xuexi_mine").exists()){//自强国通页面进入我的主页点击学习积分
1216 | id("comm_head_xuexi_mine").findOnce().click();
1217 | if (id("my_display_name").exists()){//我的主页
1218 | id("my_recycler_view").findOnce().child(0).click();
1219 | }
1220 | }
1221 | delay(3);
1222 | }
1223 | let err = false;
1224 | while (!err) {
1225 | try {
1226 | className("android.widget.ListView").findOnce().children().forEach(item => {
1227 | let name = item.child(0).child(0).text();
1228 | let str = item.child(2).text().split("/");
1229 | let score = str[0].match(/[0-9][0-9]*/g);
1230 | myScores[name] = score;
1231 | });
1232 | err = true;
1233 | } catch (e) {
1234 | console.log(e);
1235 | }
1236 | }
1237 | console.log(myScores);
1238 | aCount = 12 - myScores["我要选读文章"];
1239 | vCount = 6 - myScores["视听学习"];
1240 | rTime = (6 - myScores["视听学习时长"]) * 60;
1241 | console.log('剩余文章:' + aCount.toString() + '篇')
1242 | console.log('剩余视频:' + vCount.toString() + '个')
1243 | console.log('视听学习时长:' + rTime.toString() + '秒')
1244 | delay(1); back(); delay(1);
1245 | }
1246 |
1247 | //文章学习函数之1 点击基于日期s=date_String或 "学习强国"平台
1248 | function articleStudy1() {
1249 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1250 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1251 | delay(2);
1252 | var aCatlog = aCat[num] ;//文章学习类别,随机取"推荐""要闻"、"新思想"
1253 | var date_string = getTodayDateString();//获取当天日期字符串
1254 | var s = date_string;
1255 | var listView = className("ListView");//获取文章ListView控件用于翻页
1256 | click(aCatlog);
1257 | delay(2);
1258 | var zt_flag = false;//判断进入专题界面标志
1259 | var fail = 0;//点击失败次数
1260 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1261 | for (var i = 0, t = 0; i < aCount;) {
1262 | if (click(s, t) == true)//如果点击成功则进入文章页面,不成功意味着本页已经到底,要翻页
1263 | {
1264 | let n = 0;
1265 | while (!textContains("欢迎发表你的观点").exists())//如果没有找到评论框则认为没有进入文章界面,一直等待
1266 | {
1267 | delay(1);
1268 | console.warn("正在等待加载文章界面...");
1269 | if (n > 3)//等待超过3秒则认为进入了专题界面,退出进下一篇文章
1270 | {
1271 | console.warn("没找到评论框!该界面非文章界面!");
1272 | zt_flag = true;
1273 | break;
1274 | }
1275 | n++;
1276 | }
1277 | if (textContains("央视网").exists() || textContains("广播").exists() || textContains("中央广播电视总台").exists() ||textContains("播放").exists() ||textContains("展开").exists() )//如果存在“央视网、中央广播电视总台、播放、展开”则认为进入了视频需退出。关键词测试
1278 | {
1279 | console.warn("进入视频界面,退出并进下一篇文章!");
1280 | t++;
1281 | back();
1282 | /* while (!id("home_bottom_tab_button_work").exists());
1283 | delay(0.5);
1284 | click("电台");
1285 | delay(1);
1286 | click("最近收听");
1287 | console.log("因广播被打断,重新收听广播...");
1288 | delay(1);
1289 | back();*/
1290 | while (!id("home_bottom_tab_button_work").exists());
1291 | id("home_bottom_tab_button_work").findOne().click();
1292 | delay(1);
1293 | num = random(0, commentText.length - 1) ; //重取随机数
1294 | aCatlog = aCat[num] ;
1295 | s = "“学习强国”学习平台";
1296 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1297 | click(aCatlog);
1298 | delay(1);
1299 | continue;
1300 | }
1301 |
1302 | if (id("v_play").exists() || id("bg_play").exists())//进入电台页面2020.09.28
1303 | {
1304 | console.warn("进入电台界面,退出并进下一篇文章!");
1305 | t++;
1306 | if (id("btn_back").exists()){
1307 | id("btn_back").findOnce().click();//返回 2020.09.28需关闭电台收听
1308 | }else{
1309 | back; }//返回 2020.09.28需关闭电台收听
1310 | while (!id("home_bottom_tab_button_work").exists());
1311 | id("home_bottom_tab_button_work").findOne().click();
1312 | delay(1);
1313 | num = random(0, commentText.length - 1) ; //重取随机数
1314 | aCatlog = aCat[num] ;
1315 | s = "“学习强国”学习平台";
1316 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1317 | click(aCatlog);
1318 | delay(1);
1319 | continue;
1320 | }
1321 |
1322 | if (zt_flag == true)//进入专题页标志
1323 | {
1324 | console.warn("进入了专题界面,退出并进下一篇文章!")
1325 | t++;
1326 | back();
1327 | delay(1);
1328 | zt_flag = false;
1329 | continue;
1330 | }
1331 | console.log("正在学习第" + (i + 1) + "篇文章...");
1332 | fail = 0;//失败次数清0
1333 | article_timing(i, aTime);
1334 | if (i < cCount)//收藏分享2篇文章
1335 | {
1336 | CollectAndShare(i);//收藏+分享 若运行到此报错请注释本行!
1337 | Comment(i);//评论
1338 | }
1339 | back();//返回主界面
1340 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1341 | delay(1);
1342 | i++;
1343 | t++;//t为实际点击的文章控件在当前布局中的标号,和i不同,勿改动!
1344 | } else {
1345 | if (id("v_play").exists() || id("bg_play").exists())//进入电台页面2020.09.28
1346 | {
1347 | console.warn("进入电台界面,退出并进下一篇文章!");
1348 | t++;
1349 | if (id("btn_back").exists()){
1350 | id("btn_back").findOnce().click();//返回 2020.09.28需关闭电台收听
1351 | }else{
1352 | back; }
1353 | while (!id("home_bottom_tab_button_work").exists());
1354 | id("home_bottom_tab_button_work").findOne().click();
1355 | delay(1);
1356 | num = random(0, commentText.length - 1) ; //重取随机数
1357 | aCatlog = aCat[num] ;
1358 | s = "“学习强国”学习平台";
1359 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1360 | click(aCatlog);
1361 | delay(1);
1362 | continue;
1363 | }
1364 |
1365 | if (i == 0)//如果第一次点击就没点击成功则认为首页无当天文章
1366 | {
1367 | date_string = getYestardayDateString();
1368 | s = date_string;
1369 | /*s = "“学习强国”学习平台";*/
1370 | num = random(0, commentText.length - 1) ; //重取随机数
1371 | aCatlog = aCat[num] ;
1372 | click(aCatlog);
1373 | console.warn("首页没有找到当天文章,即将学习昨日新闻!"+aCatlog + s);
1374 | continue;
1375 | }
1376 |
1377 | if (fail > 3)//连续翻几页没有点击成功则认为今天的新闻还没出来,学习昨天的
1378 | {
1379 | date_string = getYestardayDateString();
1380 | /*s = date_string;*/
1381 | s = "“学习强国”学习平台";
1382 | num = random(0, commentText.length - 1) ; //重取随机数
1383 | aCatlog = aCat[num] ;
1384 | click(aCatlog);
1385 | console.warn("没有找到当天文章,即将学习昨日新闻!"+aCatlog + s);
1386 | fail = 0;//失败次数清0
1387 | continue;
1388 | }
1389 |
1390 | if (!textContains(s).exists())//当前页面当天新闻
1391 | {
1392 | fail++;//失败次数加一
1393 | }
1394 | listView.scrollForward();//向下滑动(翻页)
1395 | t = 0;
1396 | delay(1.5);
1397 | }
1398 | }
1399 | }
1400 | //文章学习函数之2 基于播报判断.因基于父子控件判断,点击基于日期s=date_String 感谢chongyadong
1401 | function articleStudy2() {
1402 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1403 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1404 | delay(2);
1405 | var aCatlog = aCat[num] ;//文章学习类别,随机取"推荐""要闻"、"新思想"
1406 | var date_string = getTodayDateString();//获取当天日期字符串
1407 | var s = date_string;
1408 | var listView = className("ListView");//获取文章ListView控件用于翻页
1409 | click(aCatlog);
1410 | delay(2);
1411 | var zt_flag = false;//判断进入专题界面标志
1412 | var currentNewsTitle = "";
1413 | var fail = 0; //点击失败次数
1414 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1415 | for (var i = 0, t = 0; i < aCount;) {
1416 | var art_obj = text(s).findOnce(t);
1417 | //console.info(art_obj);
1418 | if ((art_obj != null) && (art_obj.parent().childCount() == 4)) {
1419 | t++; //t为实际查找的文章控件在当前布局中的标号,和i不同,勿改动!
1420 | if ((art_obj.parent().child(3).text() == "播报") && (art_obj.parent().child(0).text() != currentNewsTitle)) //如果播报存在就进入文章正文
1421 | {
1422 | currentNewsTitle = art_obj.parent().child(0).text();
1423 | log(currentNewsTitle);
1424 | art_obj.parent().click();
1425 | delay(1);
1426 | let n = 0;
1427 | while (!textContains("欢迎发表你的观点").exists())//如果没有找到评论框则认为没有进入文章界面,一直等待
1428 | {
1429 | delay(1);
1430 | console.warn("正在等待加载文章界面...");
1431 | if (n > 3)//等待超过3秒则认为进入了专题界面,退出进下一篇文章
1432 | {
1433 | console.warn("没找到评论框!该界面非文章界面!");
1434 | zt_flag = true;
1435 | break;
1436 | }
1437 | n++;
1438 | }
1439 | if (textContains("央视网").exists() || textContains("广播").exists() || textContains("中央广播电视总台").exists() ||textContains("播放").exists() ||textContains("展开").exists() )//如果存在“央视网、中央广播电视总台、播放、展开”则认为进入了视频需退出。关键词测试
1440 | {
1441 | console.warn("进入视频界面,退出并进下一篇文章!");
1442 | t++;
1443 | back();
1444 | /*while (!id("home_bottom_tab_button_work").exists());
1445 | delay(0.5);
1446 | click("电台");
1447 | delay(1);
1448 | click("最近收听");
1449 | console.log("因广播被打断,重新收听广播...");
1450 | delay(1);
1451 | back();*/
1452 | while (!id("home_bottom_tab_button_work").exists());
1453 | id("home_bottom_tab_button_work").findOne().click();
1454 | delay(1);
1455 | num = random(0, commentText.length - 1) ; //重取随机数
1456 | aCatlog = aCat[num] ;
1457 | s = date_string;
1458 | /*s = "“学习强国”学习平台";*/
1459 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1460 | click(aCatlog);
1461 | delay(1);
1462 | continue;
1463 | }
1464 |
1465 | if (id("v_play").exists() || id("bg_play").exists())//进入电台页面2020.09.28
1466 | {
1467 | console.warn("进入电台界面,退出并进下一篇文章!");
1468 | t++;
1469 | if (id("btn_back").exists()){
1470 | id("btn_back").findOnce().click();//返回 2020.09.28需关闭电台收听
1471 | }else{
1472 | back; }//返回 2020.09.28需关闭电台收听
1473 | while (!id("home_bottom_tab_button_work").exists());
1474 | id("home_bottom_tab_button_work").findOne().click();
1475 | delay(1);
1476 | num = random(0, commentText.length - 1) ; //重取随机数
1477 | aCatlog = aCat[num] ;
1478 | s = date_string;
1479 | /*s = "“学习强国”学习平台";*/
1480 | console.log('文章类别:' + aCatlog + '关键词:'+ s)
1481 | click(aCatlog);
1482 | delay(1);
1483 | continue;
1484 | }
1485 |
1486 | if (zt_flag == true)//进入专题页标志
1487 | {
1488 | console.warn("进入了专题界面,退出并进下一篇文章!")
1489 | t++;
1490 | back();
1491 | delay(1);
1492 | zt_flag = false;
1493 | continue;
1494 | }
1495 | console.log("正在学习第" + (i + 1) + "篇文章...");
1496 | fail = 0; //失败次数清0
1497 | article_timing(i, aTime);
1498 | if (i < cCount)//收藏分享2篇文章
1499 | {
1500 | CollectAndShare(i);//收藏+分享 若c运行到此报错请注释本行!
1501 | Comment(i);//评论
1502 | }
1503 | back(); //返回主界面
1504 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1505 | delay(1);
1506 | i++;
1507 | }else{ //判断非目标文章
1508 | if (t > 2) {
1509 | listView.scrollForward(); //向下滑动(翻页
1510 | console.log("----------翻页------------");
1511 | t = 0;
1512 | delay(1.5);
1513 | }
1514 | }
1515 | }else{
1516 | if (fail > 3) //连续翻几页没有点击成功则认为今天的新闻还没出来,学习昨天的
1517 | {
1518 | date_string = getYestardayDateString();
1519 | s = date_string;
1520 | /*s = "“学习强国”学习平台";*/
1521 | num = random(0, commentText.length - 1) ; //重取随机数
1522 | aCatlog = aCat[num] ;
1523 | click(aCatlog);
1524 | console.warn("没有找到当天文章,即将学习昨日新闻!"+aCatlog + s);
1525 | fail = 0;//失败次数清0
1526 | continue;
1527 | }
1528 | if (!textContains(date_string).exists()) //当前页面当天新闻
1529 | {
1530 | fail++; //失败次数加一
1531 | }
1532 | listView.scrollForward(); //向下滑动(翻页
1533 | console.log("----------翻页------------");
1534 | t = 0;
1535 | delay(1.5);
1536 | }
1537 | }
1538 | }
1539 |
1540 | function videoStudy_news() {
1541 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1542 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1543 | delay(2);
1544 | click("电视台");
1545 | var vCatlog = vCat[num] ; //视频学习类别,随机取 "第一频道"、"学习视频"、"联播频道"
1546 | if (num == 0){
1547 | var s = "中央广播电视总台";
1548 | }else if (num == 1){
1549 | var s = "央视新闻";
1550 | }else {
1551 | var s = "中央广播电视总台";
1552 | }
1553 | delay(1);
1554 | click(vCatlog);
1555 | delay(2);
1556 | var listView = className("ListView");//获取listView视频列表控件用于翻页
1557 | var fail = 0;//点击失败次数
1558 | delay(1);
1559 | console.log('视频类别:' + vCatlog + '关键词:'+ s )
1560 | for (var i = 0, t = 1; i < vCount;) {
1561 | if (click(s, t) == true) {
1562 | console.log("即将学习第" + (i + 1) + "个视频!");
1563 | fail = 0;//失败次数清0
1564 | video_timing_news(i, vTime);//学习每个新闻联播小片段
1565 | back();//返回联播频道界面
1566 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1567 | delay(1);
1568 | i++;
1569 | t++;
1570 | if (i == 3) {//如果是平板等设备,请尝试修改i为合适值!
1571 | listView.scrollForward();//翻页
1572 | delay(2);
1573 | t = 2;
1574 | }
1575 | }
1576 | else {
1577 | if (fail > 3)//连续翻几页没有点击成功则改换频道
1578 | {
1579 | num = random(0, commentText.length - 1) ; //重取随机数
1580 | vCatlog = vCat[num] ;
1581 | click(vCatlog);
1582 | delay(2);
1583 | if (num == 0){
1584 | var s = "央视网";
1585 | }else if (num == 1){
1586 | var s = "新华社";
1587 | }else {
1588 | var s = "中央广播电视总台";
1589 | }
1590 | delay(1);
1591 | console.warn("改换:"+ vCatlog + '关键词:'+ s);
1592 | fail = 0;//失败次数清0
1593 | continue;
1594 | }
1595 | if (!textContains(s).exists())//未找到关键词
1596 | {
1597 | fail++;//失败次数加一
1598 | }
1599 | listView.scrollForward();//翻页
1600 | delay(2);
1601 | t = 3;
1602 | }
1603 | }
1604 | }
1605 |
1606 | function videoStudy_bailing(vCount, vTime) {
1607 | h = device.height;//屏幕高
1608 | w = device.width;//屏幕宽
1609 | x = (w / 3) * 2;//横坐标2分之3处
1610 | h1 = (h / 6) * 5;//纵坐标6分之5处
1611 | h2 = (h / 6);//纵坐标6分之1处
1612 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1613 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1614 | delay(2);
1615 | click("百灵");
1616 | delay(2);
1617 | click("竖");
1618 | delay(2);
1619 | var a = className("FrameLayout").depth(23).findOnce(0);//根据控件搜索视频框,但部分手机不适配,改用下面坐标点击
1620 | a.click();
1621 | //click((w/2)+random()*10,h/4);//坐标点击第一个视频
1622 | delay(1);
1623 | for (var i = 0; i < vCount; i++) {
1624 | console.log("正在观看第" + (i + 1) + "个小视频");
1625 | video_timing_bailing(i, vTime);//观看每个小视频
1626 | if (i != vCount - 1) {
1627 | swipe(x, h1, x, h2, 500);//往下翻(纵坐标从5/6处滑到1/6处)
1628 | }
1629 | }
1630 | back();
1631 | delay(2);
1632 | }
1633 |
1634 | function listenToRadio() {
1635 | var r_start = new Date().getTime();//广播开始时间
1636 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1637 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1638 | delay(2);
1639 | click("电台");
1640 | delay(1);
1641 | click("听广播");//202012听新闻广播 改为 听广播
1642 | delay(2);
1643 | if (textContains("最近收听").exists()) {
1644 | click("最近收听");
1645 | console.log("正在收听广播...");
1646 | delay(1);
1647 | back();//返回
1648 | delay(1);
1649 | }
1650 | if (textContains("推荐收听").exists()) {
1651 | click("推荐收听");
1652 | console.log("正在收听广播...");
1653 | delay(1);
1654 | back();//返回
1655 | delay(1);
1656 | }
1657 | id("home_bottom_tab_button_work").findOne().click();
1658 | delay(1);
1659 | var r_end = new Date().getTime();//广播结束时间
1660 | var radio_time = (parseInt((r_end - r_start) / 1000));//广播已经收听的时间
1661 | var left_time =rTime - radio_time;
1662 | radio_timing(parseInt((r_end - r_start) / 1000), left_time);//广播剩余需收听时间
1663 | }
1664 |
1665 | function stopRadio() {
1666 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1667 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1668 | delay(2);
1669 | console.log("停止收听广播!");
1670 | click("电台");
1671 | delay(1);
1672 | click("听广播");//202012听新闻广播 改 听广播
1673 | delay(2);
1674 | while (!(textContains("正在收听").exists() || textContains("最近收听").exists() || textContains("推荐收听").exists())) {
1675 | log("等待加载");
1676 | delay(2);
1677 | }
1678 | if (textContains("正在收听").exists()) {
1679 | click("正在收听");
1680 | console.log("正在停止广播...");
1681 | delay(2);
1682 | id("v_play").findOnce(0).click();//点击暂停播放按钮
1683 | delay(2);
1684 | if (id("btn_back").findOne().click() == 0) {//后退
1685 | delay(2);
1686 | back();
1687 | }
1688 | }
1689 | console.log("广播已停止播放...");
1690 | delay(1);
1691 | if (!id("home_bottom_tab_button_work").exists()) {
1692 | start_app(1);
1693 | }
1694 | delay(1);
1695 | }
1696 |
1697 |
1698 | function CollectAndShare(i) {
1699 | while (!textContains("欢迎发表你的观点").exists())//如果没有找到评论框则认为没有进入文章界面,一直等待
1700 | {
1701 | delay(1);
1702 | console.log("等待进入文章界面")
1703 | }
1704 | console.log("正在进行第" + (i + 1) + "次收藏和分享...");
1705 |
1706 | var textOrder = text("欢迎发表你的观点").findOnce().drawingOrder();
1707 | var collectOrder = textOrder + 2;
1708 | var shareOrder = textOrder + 3;
1709 | var collectIcon = className("ImageView").filter(function (iv) {
1710 | return iv.drawingOrder() == collectOrder;
1711 | }).findOnce();
1712 |
1713 | var shareIcon = className("ImageView").filter(function (iv) {
1714 | return iv.drawingOrder() == shareOrder;
1715 | }).findOnce();
1716 |
1717 | //var collectIcon = classNameContains("ImageView").depth(10).findOnce(0);//右下角收藏按钮
1718 | collectIcon.click();//点击收藏
1719 | console.info("收藏成功!");
1720 | delay(1);
1721 |
1722 | //var shareIcon = classNameContains("ImageView").depth(10).findOnce(1);//右下角分享按钮
1723 | shareIcon.click();//点击分享
1724 | while (!textContains("分享到学习强国").exists());//等待弹出分享选项界面
1725 | delay(1);
1726 | click("分享到学习强国");
1727 | delay(2);
1728 | console.info("分享成功!");
1729 | back();//返回文章界面
1730 | delay(1);
1731 | collectIcon.click();//再次点击,取消收藏
1732 | console.info("取消收藏!");
1733 | delay(1);
1734 | }
1735 |
1736 | function Comment(i) {
1737 | while (!textContains("欢迎发表你的观点").exists())//如果没有找到评论框则认为没有进入文章界面,一直等待
1738 | {
1739 | delay(1);
1740 | console.log("等待进入文章界面")
1741 | }
1742 | click("欢迎发表你的观点");//单击评论框
1743 | console.log("正在进行第" + (i + 1) + "次评论...");
1744 | delay(1);
1745 | var num = random(0, commentText.length - 1)//随机数
1746 | setText(commentText[num]);//输入评论内容
1747 | delay(1);
1748 | click("发布");//点击右上角发布按钮
1749 | console.info("评论成功!");
1750 | delay(2);
1751 | click("删除");//删除该评论
1752 | delay(2);
1753 | click("确认");//确认删除
1754 | console.info("评论删除成功!");
1755 | delay(1);
1756 | }
1757 |
1758 |
1759 | //基于控件点击 20200911 部分手机 本地在频道列表为控件3 但部分为控件14,可点击后基于切换地区判断。
1760 | //20201020如果在综合页面进入本地,则识别不到新思想,因此改基于综合判断。20201022 山东省界面更新频道内控件3会跳转外部链接故改0
1761 | //20210116 控件14改动为15,控件3有无变动未知
1762 | function localChannel1() {
1763 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1764 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1765 | delay(2);
1766 | console.log("点击本地频道");
1767 | delay(1);
1768 | if (className("android.widget.TextView").text("综合").exists()) {
1769 | className("android.widget.TextView").text("综合").findOne().parent().parent().child(3).click();
1770 | delay(2);
1771 | if(className("android.widget.TextView").text("切换地区").exists()){
1772 | className("android.support.v7.widget.RecyclerView").findOne().child(0).click();
1773 | delay(2);
1774 | console.log("返回主界面");
1775 | back();
1776 | className("android.widget.TextView").text("综合").findOne().parent().parent().child(0).click();
1777 | }else{
1778 | className("android.widget.TextView").text("综合").findOne().parent().parent().child(15).click(); //14 15
1779 | delay(2);
1780 | className("android.support.v7.widget.RecyclerView").findOne().child(0).click();
1781 | delay(2);
1782 | console.log("返回主界面");
1783 | back();
1784 | className("android.widget.TextView").text("综合").findOne().parent().parent().child(11).click();
1785 | }
1786 | id("home_bottom_tab_button_work").findOne().click();
1787 | delay(1);
1788 | } else {
1789 | console.log("请手动点击本地频道!");
1790 | }
1791 | }
1792 |
1793 |
1794 | function sub1() {
1795 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1796 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1797 | delay(2);
1798 | click("订阅");
1799 | delay(2);
1800 | click("添加");
1801 | delay(2);
1802 | click("学习平台", 0); // text("学习平台").findOne().click() == click("学习平台", 0) 解决订阅问题
1803 | delay(0.5)
1804 | click("强国号", 0)
1805 | let sublist = className("ListView").findOnce(0);
1806 | var i = 0;
1807 | while (i < asub) {
1808 | let object = desc("订阅").find();
1809 | if (!object.empty()) {
1810 | object.forEach(function (currentValue) {
1811 | if (currentValue && i < asub) {
1812 | let like = currentValue.parent()
1813 | if (like.click()) {
1814 | console.log("订阅成功");
1815 | i++;
1816 | delay(2);
1817 | } else {
1818 | console.error("订阅失败");
1819 | }
1820 | }
1821 | })
1822 | } else if (text("你已经看到我的底线了").exists()) {
1823 | console.log("尝试订阅学习平台")
1824 | back();
1825 | delay(1);
1826 | click("添加");
1827 | delay(1);
1828 | click("学习平台", 0);
1829 | delay(2);
1830 | let sublist = className("ListView").findOnce(1);
1831 | while (i < asub) {
1832 | let object = desc("订阅").find();
1833 | if (!object.empty()) {
1834 | object.forEach(function (currentValue) {
1835 | if (currentValue && i < asub) {
1836 | let like = currentValue.parent()
1837 | if (like.click()) {
1838 | console.log("订阅成功");
1839 | i++;
1840 | delay(2);
1841 | } else {
1842 | console.error("订阅失败");
1843 | }
1844 | }
1845 | })
1846 | } else if (text("你已经看到我的底线了").exists()) {
1847 | console.log("没有可订阅的强国号了,退出!!!")
1848 | back();
1849 | delay(2);
1850 | return;
1851 | } else {
1852 | delay(1);
1853 | sublist.scrollForward();
1854 | }
1855 | }
1856 | } else {
1857 | delay(1);
1858 | sublist.scrollForward();
1859 | }
1860 | }
1861 | back();
1862 | delay(2);
1863 | }
1864 |
1865 | /*if (ui.sub_quiz.isChecked()) {
1866 | if (myScores["订阅"][0] < myScores["订阅"][1]) {
1867 | if (getPackageVersion("cn.xuexi.android") <= "2.18.1") {
1868 | console.log("----------------------------");
1869 | console.info("开始执行订阅任务");
1870 | sub();
1871 | console.info("订阅任务已完成!");
1872 | }
1873 | else {
1874 | console.info("订阅任务未适配该强国版本,跳过!");
1875 | delay(1);
1876 | }
1877 | }
1878 | else {
1879 | console.info("订阅任务已完成!");
1880 | delay(1);
1881 | }
1882 | }*/
1883 |
1884 | function sub2() {
1885 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1886 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1887 | delay(2);
1888 | click("订阅");
1889 | delay(2);
1890 | click("添加");
1891 | delay(2);
1892 | className("android.view.View").desc("地方平台 Tab 2 of 2").findOne().click();
1893 | delay(2);
1894 |
1895 | while(true){
1896 | className("android.view.View").findOnce(5).click();
1897 | break;
1898 | }
1899 | }
1900 |
1901 | function dateToString(y, m, d) {
1902 | var year = y.toString();
1903 | if ((m + 1) < 10) {
1904 | var month = "0" + (m + 1).toString();
1905 | } else {
1906 | var month = (m + 1).toString();
1907 | }
1908 | if (d < 10) {
1909 | var day = "0" + d.toString();
1910 | } else {
1911 | var day = d.toString();
1912 | }
1913 | var s = year + "-" + month + "-" + day;//年-月-日
1914 | return s;
1915 | }
1916 |
1917 | function getTodayDateString() {
1918 | var date = new Date();
1919 | var y = date.getFullYear();
1920 | var m = date.getMonth();
1921 | var d = date.getDate();
1922 | var s = dateToString(y, m, d);//年,月,日
1923 | return s
1924 | }
1925 |
1926 | function getYestardayDateString() {
1927 | var date = new Date();
1928 | num++;//num是程序开始获取的随机数,前1-3天,+1防止num=0的情况
1929 | date.setDate(date.getDate() - num);
1930 | var y = date.getFullYear();
1931 | var m = date.getMonth();
1932 | var d = date.getDate();
1933 | var s = dateToString(y, m, d);//年,月,日
1934 | return s
1935 | }
1936 |
1937 |
1938 | /*************************************************挑战 争上游 双人答题部分******************************************************/
1939 |
1940 | function indexFromChar(str) {
1941 | return str.charCodeAt(0) - "A".charCodeAt(0);
1942 | }
1943 |
1944 | function zsyQuestion() {
1945 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
1946 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
1947 | delay(2);
1948 | text("我的").click();
1949 | if (!textContains("我要答题").exists()) {
1950 | delay(1);
1951 | click("我要答题");
1952 | }else {
1953 | (!text("我要答题").exists());
1954 | delay(1);
1955 | text("我要答题").findOne().parent().click();
1956 | }
1957 | while (!text("答题练习").exists());//可用词:排行榜 答题竞赛
1958 | delay(1);
1959 | className("android.view.View").text("答题练习").findOne().parent().child(8).click();
1960 | console.log("开始争上游答题")
1961 | delay(2);
1962 | if(className("android.view.View").text("开始比赛").exists()){
1963 | className("android.view.View").text("开始比赛").findOne().click();
1964 | }
1965 | delay(3);
1966 | if (className("android.widget.Button").text("知道了").exists() || className("android.view.View").text("温馨提示").exists() || className("android.view.View").text("您已超过今日对战次数,请明日再来。").exists() ){
1967 | console.log("今日已完成30次对战,请明日再来");
1968 | back(); delay(1);
1969 | back(); delay(1);
1970 | back(); delay(1);
1971 | if (id("my_display_name").exists()){//我的主页,再退一步回主页
1972 | back(); delay(1); } //单纯back有概率退出但又有可能只退到我的页面 故加判断
1973 | return;
1974 | }
1975 | delay(3);
1976 | let zNum = 0;//轮数
1977 | while (true) {
1978 | if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists())//遇到继续挑战,则本局结束
1979 | {console.info("争上游答题本局结束!");
1980 | zNum++;
1981 | if (zNum >= zCount) {
1982 | console.log("争上游答题结束,返回主页!");
1983 | //回退4次返回主页
1984 | back(); delay(1);
1985 | back(); delay(1);
1986 | back(); delay(1);
1987 | back(); delay(1);
1988 | if (id("my_display_name").exists()){//我的主页,再退一步回主页
1989 | back(); delay(1); } //单纯back有概率退出但又有可能只退到我的页面 故加判断
1990 | break;
1991 | } else {
1992 | console.log("即将开始下一轮...")
1993 | delay(2);//等待2秒开始下一轮
1994 | back();
1995 | delay(1);
1996 | back();
1997 | while (!text("答题练习").exists());//排行榜 答题竞赛
1998 | delay(1);
1999 | className("android.view.View").text("答题练习").findOne().parent().child(8).click();
2000 | console.log("开始争上游答题")
2001 | delay(2);
2002 | if (className("android.view.View").text("开始比赛").exists()){
2003 | className("android.view.View").text("开始比赛").findOne().click();
2004 | }
2005 | delay(3);
2006 | if (className("android.widget.Button").text("知道了").exists() || className("android.view.View").text("温馨提示").exists() || className("android.view.View").text("您已超过今日对战次数,请明日再来。").exists() ){
2007 | console.log("今日已完成30次对战,请明日再来");
2008 | back(); delay(1);
2009 | back(); delay(1);
2010 | back(); delay(1);
2011 | if (id("my_display_name").exists()){//我的主页,再退一步回主页
2012 | back(); delay(1); } //单纯back有概率退出但又有可能只退到我的页面 故加判断
2013 | return;
2014 | }
2015 | delay(3);
2016 | }
2017 | console.warn("第" + (zNum + 1).toString() + "轮开始...")
2018 | }
2019 | if (/*textContains("距离答题结束").exists() &&*/ !text("继续挑战").exists()){ //20201225答题界面变化 距离答题结束 删除
2020 | zsyQuestionLoop();
2021 | }
2022 | }
2023 | }
2024 |
2025 | function SRQuestion() {
2026 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
2027 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
2028 | delay(2);
2029 | text("我的").click();
2030 | if (!textContains("我要答题").exists()) {
2031 | delay(1);
2032 | click("我要答题");
2033 | } else {
2034 | (!text("我要答题").exists());
2035 | delay(1);
2036 | text("我要答题").findOne().parent().click();
2037 | }
2038 | while (!text("答题练习").exists());//可用词:排行榜 答题竞赛
2039 | delay(1);
2040 | className("android.view.View").text("答题练习").findOne().parent().child(9).click();
2041 | console.log("开始双人对战")
2042 | delay(2);
2043 | if(className("android.view.View").text("邀请对手").exists()){
2044 | className("android.view.View").text("邀请对手").findOne().parent().child(0).click();
2045 | }//原为随机邀请对手
2046 | if(className("android.view.View").text("随机匹配").exists()){
2047 | className("android.view.View").text("随机匹配").findOne().parent().child(0).click();
2048 | }//20200125修改为邀请好友&随机匹配
2049 | delay(1);
2050 | if(className("android.view.View").text("开始对战").exists()){
2051 | className("android.view.View").text("开始对战").findOne().click();
2052 | }
2053 | delay(3);
2054 | if (className("android.widget.Button").text("知道了").exists() || className("android.view.View").text("温馨提示").exists() || className("android.view.View").text("您已超过今日对战次数,请明日再来。").exists() ){
2055 | console.log("今日已完成30次对战,请明日再来");
2056 | back(); delay(1);
2057 | back(); delay(1);
2058 | back(); delay(1);
2059 | if (id("my_display_name").exists()){//我的主页,再退一步回主页
2060 | back(); delay(1); } //单纯back有概率退出但又有可能只退到我的页面 故加判断
2061 | return;
2062 | }
2063 | delay(3);
2064 | let zNum = 1;//轮数
2065 | while (true) {
2066 | if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists())//遇到继续挑战,则本局结束
2067 | { console.info("双人对战本局结束!");
2068 | zNum++;
2069 | if (zNum >= zCount) {
2070 | console.log("双人对战结束!返回主页!");
2071 | //回退4次返回主页
2072 | back(); delay(1);
2073 | back(); delay(1);
2074 | if (text("退出").exists()){
2075 | className("android.widget.Button").text("退出").findOne().click();
2076 | delay(1);
2077 | }
2078 | back(); delay(1);
2079 | back(); delay(1);
2080 | if (id("my_display_name").exists()){//我的主页,再退一步回主页
2081 | back(); delay(1); } //单纯back有概率退出但又有可能只退到我的页面 故加判断
2082 | break;
2083 | } else {
2084 | console.log("即将开始下一轮...")
2085 | back();
2086 | delay(1);
2087 | back();
2088 | delay(1);
2089 | if (textContains("退出").exists()){
2090 | className("android.widget.Button").text("退出").findOne().click();
2091 | delay(1);
2092 | }
2093 | while (!text("答题练习").exists());//排行榜 答题竞赛
2094 | delay(1);
2095 | className("android.view.View").text("答题练习").findOne().parent().child(9).click();
2096 | console.log("开始双人对战");
2097 | delay(2);
2098 | if(className("android.view.View").text("邀请对手").exists()){
2099 | className("android.view.View").text("邀请对手").findOne().parent().child(0).click();
2100 | }//原为随机邀请对手
2101 | if(className("android.view.View").text("随机匹配").exists()){
2102 | className("android.view.View").text("随机匹配").findOne().parent().child(0).click();
2103 | }//20200125修改为邀请好友&随机匹配
2104 | delay(1);
2105 | if(className("android.view.View").text("开始对战").exists()){
2106 | className("android.view.View").text("开始对战").findOne().click();
2107 | }
2108 | delay(3);
2109 | if (className("android.widget.Button").text("知道了").exists() || className("android.view.View").text("温馨提示").exists() || className("android.view.View").text("您已超过今日对战次数,请明日再来。").exists() ){
2110 | console.log("今日已完成30次对战,请明日再来");
2111 | back(); delay(1);
2112 | back(); delay(1);
2113 | back(); delay(1);
2114 | if (id("my_display_name").exists()){//我的主页,再退一步回主页
2115 | back(); delay(1); } //单纯back有概率退出但又有可能只退到我的页面 故加判断
2116 | return;
2117 | }
2118 | delay(3);
2119 | }
2120 | console.warn("第" + zNum.toString() + "轮开始...")
2121 | }
2122 | if (/*textContains("距离答题结束").exists() &&*/ !text("继续挑战").exists()){ //20201225界面变化 距离答题结束 删除
2123 | zsyQuestionLoop();
2124 | }
2125 | }
2126 | }
2127 |
2128 | //循环1 基于延时进行题目刷新做题,4+0.3秒,结束偶尔故障;20201022修改为基于前后题目判断
2129 | function zsyQuestionLoop() {
2130 | let ClickAnswer;
2131 | try{//20201025使用try catch(e)语句处理错误,去除前后置0.5s延时
2132 | /*delay(0.5);*///4-0.5,前置0.5延时判断结束标志
2133 | if (!className("RadioButton").exists() || className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists() /*|| !textContains("距离答题结束").exists()*/){//不存在本局结束标志 继续挑战,则执行 20201225界面变化,距离答题结束 删除
2134 | /*console.info("答题结束!");*/ //配合20201225界面变化 距离答题结束 去除,本语句去除
2135 | return;
2136 | } else {
2137 | while(!className("RadioButton").exists());//@KB64ba建议使用while判断
2138 | if (className("RadioButton").exists() || aquestion.length == 0) {
2139 | /*delay(0.3);*/
2140 | var aquestion = className("ListView").findOnce().parent().child(0).text();
2141 | var question = aquestion.substring(3); //争上游和对战题目前带1.2.3.需去除
2142 | while (aquestion == oldaquestion || question == "") {
2143 | /*delay(0.8);*/
2144 | if (!className("RadioButton").exists() || className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists()) {
2145 | console.info("答题结束!");
2146 | return;
2147 | }else if(className("RadioButton").exists()){
2148 | aquestion = className("ListView").findOnce().parent().child(0).text();
2149 | question = aquestion.substring(3);
2150 | }
2151 | }
2152 | }else {
2153 | console.error("提取题目失败!");
2154 | let listArray = className("ListView").findOnce().children();//题目选项列表
2155 | let i = random(0, listArray.length - 1);
2156 | console.log("随机点击");
2157 | listArray[i].child(0).click();//随意点击一个答案
2158 | ClickAnswer = listArray[i].child(0).child(1).text();//记录已点击答案
2159 | console.log("随机点击:"+ClickAnswer);
2160 | return;
2161 | }
2162 | var chutiIndex = question.lastIndexOf("出题单位");//@chongyadong添加
2163 | if (chutiIndex != -1) {
2164 | question = question.substring(0, chutiIndex - 2);
2165 | }
2166 | question = question.replace(/\s/g, "");
2167 | var options = [];//选项列表
2168 | if (className("RadioButton").exists()) {
2169 | className("ListView").findOne().children().forEach(child => {
2170 | var answer_q = child.child(0).child(1).text();
2171 | options.push(answer_q);
2172 | });
2173 | } else {
2174 | console.error("答案获取失败!");
2175 | return;
2176 | }
2177 | if (aquestion != oldaquestion){
2178 | if (question == ZiXingTi.replace(/\s/g, "") || question == DuYinTi.replace(/\s/g, "") || question == ErShiSiShi.replace(/\s/g, "")) {
2179 | question = question + options[0].substring(3); //字形题 读音题 二十四史 在题目后面添加第一选项,选项带A.去除
2180 | }
2181 | console.log(aquestion.substring(0,2) + "题目:" + question);
2182 | var answer = getAnswer(question, 'tiku');
2183 | if (answer.length == 0) {//tiku表中没有则到tikuNet表中搜索答案
2184 | answer = getAnswer(question, 'tikuNet');
2185 | }
2186 | console.info("答案:" + answer);
2187 | if (/^[a-zA-Z]{1}$/.test(answer)) {//如果为ABCD形式
2188 | var indexAnsTiku = indexFromChar(answer.toUpperCase());
2189 | answer = options[indexAnsTiku];
2190 | toastLog("answer from char=" + answer);
2191 | }
2192 | let hasClicked = false;
2193 | let listArray = className("ListView").findOnce().children();//题目选项列表
2194 | /* if (answer == "")*/ //如果没找到答案
2195 | if(answer.length ==0){
2196 | let i = random(0, listArray.length - 1);
2197 | console.error("没有找到答案,随机点击");
2198 | listArray[i].child(0).click();//随意点击一个答案
2199 | hasClicked = true;
2200 | ClickAnswer = listArray[i].child(0).child(1).text();;//记录已点击答案
2201 | console.log("随机点击:"+ClickAnswer);
2202 | console.log("---------------------------");
2203 | }else{//如果找到了答案 该部分问题: 选项带A.B.C.D.,题库返回答案不带,char返回答案带
2204 | var answer_a = answer.substring(0,2);//定义answer_a,获取答案前两个字符对比A.B.C.D.应该不会出现E选项
2205 | if(answer_a == "A." || answer_a == "B." || answer_a == "C." || answer_a =="D."){
2206 | listArray.forEach(item => {
2207 | var listDescStrb = item.child(0).child(1).text();
2208 | if (listDescStrb == answer) {
2209 | item.child(0).click();//点击答案
2210 | hasClicked = true;
2211 | console.log("---------------------------");
2212 | }
2213 | });
2214 | }else{
2215 | listArray.forEach(item => {
2216 | var listDescStra = item.child(0).child(1).text();
2217 | var listDescStrb = listDescStra.substring(3);//选项去除A.B.C.D.再与answer对比
2218 | if (listDescStrb == answer) {
2219 | item.child(0).click();//点击答案
2220 | hasClicked = true;
2221 |
2222 | console.log("---------------------------");
2223 | }
2224 | });
2225 | }
2226 | }
2227 | if (!hasClicked)//如果没有点击成功
2228 | {
2229 | console.error("未能成功点击,随机点击");
2230 | let i = random(0, listArray.length - 1);
2231 | listArray[i].child(0).click();//随意点击一个答案
2232 | ClickAnswer = listArray[i].child(0).child(1).text();;//记录已点击答案
2233 | console.log("随机点击:"+ClickAnswer);
2234 | console.log("---------------------------");
2235 | }
2236 | }
2237 | oldaquestion = aquestion;
2238 | /*delay(0.5);*/
2239 | }
2240 | //delay(3.5);//后置3.5延时与前置0.5构成4s延时
2241 | }catch (e){
2242 | delay(3);
2243 | if (!className("RadioButton").exists() || className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists() /*|| !textContains("距离答题结束").exists()*/){//不存在本局结束标志 继续挑战,则执行
2244 | /*console.info("答题结束!");*/ //配合20201225界面变化 距离答题结束 删除,本语句删除
2245 | return;
2246 | }
2247 | }
2248 | }
2249 |
2250 | //循环2 基于上下题干进行判断题目是否已刷新 感谢ivan-cn
2251 | function zsyQuestionLoop1() {
2252 | //delay(1);
2253 | let ClickAnswer;
2254 | if (!className("RadioButton").exists() || className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists() /*|| !textContains("距离答题结束").exists()*/){//不存在本局结束标志 继续挑战,则执行
2255 | /* console.info("答题结束!");*/
2256 | return;
2257 | } else {
2258 | while (!className("RadioButton").exists());//@KB64ba建议使用while判断
2259 | if (className("RadioButton").exists() || aquestion.length == 0) {
2260 | var aquestion = className("ListView").findOnce().parent().child(0).text();
2261 | var question = aquestion.substring(3); //争上游和对战题目前带1.2.3.需去除
2262 | //找题目,防出错
2263 | while (aquestion == oldaquestion || question == "") {
2264 | delay(0.8);
2265 | if (!className("RadioButton").exists() || className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists()) {
2266 | console.info("答题结束!");
2267 | return;
2268 | }
2269 | //找题目
2270 | aquestion = className("ListView").findOnce().parent().child(0).text();
2271 | question = aquestion.substring(3);
2272 | }
2273 | //
2274 | } else {
2275 | console.error("提取题目失败!");
2276 | let listArray = className("ListView").findOnce().children();//题目选项列表
2277 | let i = random(0, listArray.length - 1);
2278 | console.log("随机点击");
2279 | listArray[i].child(0).click();//随意点击一个答案
2280 | return;
2281 | }
2282 | var chutiIndex = question.lastIndexOf("出题单位");//@chongyadong添加
2283 | if (chutiIndex != -1) {
2284 | question = question.substring(0, chutiIndex - 2);
2285 | }
2286 | question = question.replace(/\s/g, "");
2287 | var options = [];//选项列表
2288 | if (className("RadioButton").exists()) {
2289 | className("ListView").findOne().children().forEach(child => {
2290 | var answer_q = child.child(0).child(1).text();
2291 | options.push(answer_q);
2292 | });
2293 | } else {
2294 | console.error("答案获取失败!");
2295 | return;
2296 | }
2297 | //
2298 | if (aquestion != oldaquestion) {
2299 | reg = /.*择词语的正确.*/g // 正则判断是否为字形
2300 | if (reg.test(question)) {
2301 | //log(options)
2302 | var optionStr = options;
2303 | for (i in optionStr) {//替换搜索用的数组
2304 | optionStr[i] = options[i].substring(3);
2305 | }
2306 | var optionStr = options.join("");
2307 | question = question + optionStr;//Ivan-cn原版代码,会造成搜题失败,不掐头去尾正确率更高 后续:该部分应当配合题库使用
2308 | /*question = question.substr(1);//开头删除一个字
2309 | question = question.substr(0, question.length - 1);//结尾删除一个字,增加搜索的准确率
2310 | } else {
2311 | question = question.substr(1);//开头删除一个字
2312 | question = question.substr(0, question.length - 1);*/ //结尾删除一个字,增加搜索的准确率
2313 | }
2314 | console.log(aquestion.substring(0, 2) + "题目:" + question);
2315 | if (question == ZiXingTi.replace(/\s/g, "") || question == DuYinTi.replace(/\s/g, "")|| question == ErShiSiShi.replace(/\s/g, "")) {
2316 | question = question + options[0].substring(3); //字形题 读音题 在题目后面添加第一选项,选项带A.去除
2317 | }
2318 | var answer = getAnswer(question, 'tiku');
2319 | if (answer.length == 0) {//tiku表中没有则到tikuNet表中搜索答案
2320 | answer = getAnswer(question, 'tikuNet');
2321 | }
2322 | console.info("答案:" + answer);
2323 | if (/^[a-zA-Z]{1}$/.test(answer)) {//如果为ABCD形式
2324 | var indexAnsTiku = indexFromChar(answer.toUpperCase());
2325 | answer = options[indexAnsTiku];
2326 | toastLog("answer from char=" + answer);
2327 | }
2328 | let hasClicked = false;
2329 | let listArray = className("ListView").findOnce().children();//题目选项列表
2330 | /* if (answer == "")*/ //如果没找到答案
2331 | if (answer.length == 0) {
2332 | let i = random(0, listArray.length - 1);
2333 | console.error("没有找到答案,随机点击");
2334 | listArray[i].child(0).click();//随意点击一个答案
2335 | hasClicked = true;
2336 | ClickAnswer = listArray[i].child(0).child(1).text();;//记录已点击答案
2337 | console.log("随机点击:"+ClickAnswer);
2338 | console.log("---------------------------");
2339 | }
2340 | else//如果找到了答案
2341 | { //该部分问题: 选项带A.B.C.D.,题库返回答案不带,char返回答案带
2342 | var answer_a = answer.substring(0, 2);//定义answer_a,获取答案前两个字符对比A.B.C.D.应该不会出现E选项
2343 | if (answer_a == "A." || answer_a == "B." || answer_a == "C." || answer_a == "D.") {
2344 | listArray.forEach(item => {
2345 | var listDescStrb = item.child(0).child(1).text();
2346 | if (listDescStrb == answer) {
2347 | item.child(0).click();//点击答案
2348 | hasClicked = true;
2349 | console.log("---------------------------");
2350 | }
2351 | });
2352 | } else {
2353 | listArray.forEach(item => {
2354 | var listDescStra = item.child(0).child(1).text();
2355 | var listDescStrb = listDescStra.substring(3);//选项去除A.B.C.D.再与answer对比
2356 | if (listDescStrb == answer) {
2357 | item.child(0).click();//点击答案
2358 | hasClicked = true;
2359 | console.log("---------------------------");
2360 | }
2361 | });
2362 | }
2363 | }
2364 | if (!hasClicked)//如果没有点击成功
2365 | {
2366 | console.error("未能成功点击,随机点击");
2367 | let i = random(0, listArray.length - 1);
2368 | listArray[i].child(0).click();//随意点击一个答案
2369 | console.log("---------------------------");
2370 | }
2371 | }
2372 | //旧题目
2373 | oldaquestion = aquestion;
2374 | delay(1);
2375 | }
2376 | }
2377 |
2378 | function challengeQuestion() {
2379 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
2380 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
2381 | delay(2);
2382 | text("我的").click();
2383 | if (!textContains("我要答题").exists()) {
2384 | delay(1);
2385 | click("我要答题");
2386 | } else {
2387 | (!text("我要答题").exists());
2388 | delay(1);
2389 | text("我要答题").findOne().parent().click();
2390 | }
2391 | if(!textContains("答题练习").exists()){
2392 | while (!text("答题练习").exists());//排行榜 答题竞赛
2393 | delay(1);
2394 | className("android.view.View").text("答题练习").findOne().parent().child(10).click();
2395 | }else{
2396 | while (!text("挑战答题").exists());
2397 | delay(1);
2398 | text("挑战答题").click();//原流程,20200910改版,ver2.14不会自动更新,因可以判断故保留。
2399 | }
2400 | console.log("开始挑战答题")
2401 | delay(4);
2402 | let conNum = 0;//连续答对的次数
2403 | let lNum = 1;//轮数
2404 | while (true) {
2405 | challengeQuestionLoop(conNum);
2406 | delay(4);
2407 | if (text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2408 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2409 | {//该部分修改,逻辑为a:>=5题,失败则结束挑战答题返回主界面;b0:<5题,第一次失败,分享复活;b1:分享复活再次失败,仍<5题,需再来一局;b2:分享复活再次失败,已>5题,结束挑战答题返回主界面
2410 | delay(2);
2411 | if (lNum >= lCount && conNum >= qCount) {
2412 | console.log("挑战答题结束!返回主页!");
2413 | if(textContains("结束本局").exists()){
2414 | /*在分享页面回退4次返回主页*/
2415 | back(); delay(1);
2416 | back(); delay(1);
2417 | back(); delay(1);
2418 | back(); delay(1);
2419 | }else{
2420 | /*在本局结束页面回退3次返回主页*/
2421 | back(); delay(1);
2422 | back(); delay(1);
2423 | back(); delay(1);
2424 | }
2425 | break;
2426 | }else if(textContains("分享就能复活").exists() || textContains("每周仅可复活一次").exists()){
2427 | console.log("分享复活...")
2428 | delay(1);
2429 | click("分享就能复活");
2430 | delay(2);
2431 | console.info("分享成功!");
2432 | back();//返回答题界面
2433 | delay(4);
2434 | } else {
2435 | console.log("等3秒开始下一轮...")
2436 | delay(3);//等待3秒开始下一轮
2437 | text("再来一局").click();
2438 | /* back();
2439 | //desc("结束本局").click();//有可能找不到结束本局字样所在页面控件,所以直接返回到上一层
2440 | delay(1);
2441 | //desc("再来一局").click();
2442 | back();
2443 | if(!textContains("答题练习").exists()){
2444 | while (!text("答题练习").exists());//排行榜 答题竞赛
2445 | delay(1);
2446 | className("android.view.View").text("答题练习").findOne().parent().child(10).click();
2447 | }else{
2448 | while (!text("挑战答题").exists());
2449 | delay(1);
2450 | text("挑战答题").click();//原流程,20200910改版
2451 | }*/
2452 | delay(4);
2453 | if (conNum >= qCount) {
2454 | lNum++;
2455 | }
2456 | conNum = 0;
2457 | }
2458 | console.warn("第" + (lNum+1).toString() + "轮开始...")
2459 | }
2460 | else//答对了
2461 | {
2462 | conNum++;
2463 | }
2464 | }
2465 | }
2466 |
2467 | function challengeQuestionLoop(conNum) {
2468 | let ClickAnswer;//定义已点击答案
2469 | if (conNum >= qCount)//答题次数足够退出,每轮qCount=5+随机1-3次
2470 | {
2471 | let listArray = className("ListView").findOnce().children();//题目选项列表
2472 | let i = random(0, listArray.length - 1);
2473 | console.log("本轮答题数足够,随机点击答案");
2474 | var question = className("ListView").findOnce().parent().child(0).text();
2475 | question = question.replace(/\s/g, "");
2476 | var options = [];//选项列表
2477 | if (className("ListView").exists()) {
2478 | className("ListView").findOne().children().forEach(child => {
2479 | var answer_q = child.child(0).child(1).text();
2480 | options.push(answer_q);
2481 | });
2482 | } else {
2483 | console.error("答案获取失败!");
2484 | return;
2485 | }//20201217添加 极低概率下,答题数足够,下一题随机点击,碰到字形题
2486 | if (question == ZiXingTi.replace(/\s/g, "") || question == DuYinTi.replace(/\s/g, "") || question == ErShiSiShi.replace(/\s/g, "")) {
2487 | question = question + options[0]; //字形题 读音题 在题目后面添加第一选项
2488 | }
2489 | console.log((conNum + 1).toString() + ".随机点击题目:" + question);
2490 | delay(random(0.5, 1));//随机延时0.5-1秒
2491 | listArray[i].child(0).click();//随意点击一个答案
2492 | ClickAnswer = listArray[i].child(0).child(1).text();;//记录已点击答案
2493 | console.log("随机点击:"+ClickAnswer);
2494 | //如果随机点击答案正确,则更新到本地题库tiku表
2495 | delay(0.5);//等待0.5秒,是否出现X
2496 | if (!text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2497 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2498 | { console.log("更新本地题库答案...");
2499 | checkAndUpdate(question, answer, ClickAnswer);
2500 | }
2501 | console.log("---------------------------");
2502 | return;
2503 | }
2504 | if (className("ListView").exists()) {
2505 | var question = className("ListView").findOnce().parent().child(0).text();
2506 | }
2507 | else {
2508 | console.error("提取题目失败!");
2509 | let listArray = className("ListView").findOnce().children();//题目选项列表
2510 | let i = random(0, listArray.length - 1);
2511 | console.log("随机点击");
2512 | delay(random(0.5, 1));//随机延时0.5-1秒
2513 | listArray[i].child(0).click();//随意点击一个答案
2514 | return;
2515 | }
2516 | var chutiIndex = question.lastIndexOf("出题单位");
2517 | if (chutiIndex != -1) {
2518 | question = question.substring(0, chutiIndex - 2);
2519 | }
2520 | question = question.replace(/\s/g, "");
2521 | var options = [];//选项列表
2522 | if (className("ListView").exists()) {
2523 | className("ListView").findOne().children().forEach(child => {
2524 | var answer_q = child.child(0).child(1).text();
2525 | options.push(answer_q);
2526 | });
2527 | } else {
2528 | console.error("答案获取失败!");
2529 | return;
2530 | }
2531 | if (question == ZiXingTi.replace(/\s/g, "") || question == DuYinTi.replace(/\s/g, "") || question == ErShiSiShi.replace(/\s/g, "")) {
2532 | question = question + options[0]; //字形题 读音题 在题目后面添加第一选项
2533 | }
2534 | console.log((conNum + 1).toString() + "搜库题目:" + question);
2535 | var answer = getAnswer(question, 'tiku');
2536 | if (answer.length == 0) {//tiku表中没有则到tikuNet表中搜索答案
2537 | answer = getAnswer(question, 'tikuNet');
2538 | }
2539 | console.info("答案:" + answer);
2540 | if (/^[a-zA-Z]{1}$/.test(answer)) {//如果为ABCD形式
2541 | var indexAnsTiku = indexFromChar(answer.toUpperCase());
2542 | answer = options[indexAnsTiku];
2543 | toastLog("answer from char=" + answer);
2544 | }
2545 | let hasClicked = false;
2546 | let listArray = className("ListView").findOnce().children();//题目选项列表
2547 | if (answer == "")//如果没找到答案
2548 | {
2549 | let i = random(0, listArray.length - 1);
2550 | console.error("没有找到答案,随机点击");
2551 | delay(random(0.5, 1));//随机延时0.5-1秒
2552 | listArray[i].child(0).click();//随意点击一个答案
2553 | ClickAnswer = listArray[i].child(0).child(1).text();;//记录已点击答案
2554 | hasClicked = true;
2555 | console.log("随机点击:"+ClickAnswer);//如果随机点击答案正确,则更新到本地题库tiku表
2556 | delay(0.5);//等待0.5秒,是否出现X
2557 | if (!text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2558 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2559 | { console.log("更新本地题库答案...");
2560 | checkAndUpdate(question, answer, ClickAnswer);
2561 | }
2562 | console.log("---------------------------");
2563 | }
2564 | else//如果找到了答案
2565 | {
2566 | listArray.forEach(item => {
2567 | var listDescStr = item.child(0).child(1).text();
2568 | if (listDescStr == answer) {
2569 | delay(random(0.5, 1));//随机延时0.5-1秒
2570 | item.child(0).click();//点击答案
2571 | hasClicked = true;
2572 | delay(0.5);//等待0.5秒,是否出现X
2573 | if (!text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2574 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2575 | { console.log("题库答案正确……"); }
2576 | if (text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2577 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2578 | { console.error("题库答案错误!!!");
2579 | /*checkAndUpdate(question, answer, ClickAnswer);*/
2580 | }
2581 | console.log("---------------------------");
2582 | }
2583 | });
2584 | }
2585 | if (!hasClicked)//如果没有点击成功
2586 | {//因导致不能成功点击问题较多,故该部分不更新题库,大部分问题是题库题目适配为填空题或多选题或错误选项
2587 | console.error("未能成功点击,随机点击");
2588 | let i = random(0, listArray.length - 1);
2589 | delay(random(0.5, 1));//随机延时0.5-1秒
2590 | listArray[i].child(0).click();//随意点击一个答案
2591 | console.log("随机点击:"+ClickAnswer);
2592 | delay(0.5);//等待0.5秒,是否出现X
2593 | if (!text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2594 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2595 | { console.log("随机点击正确……"); }
2596 | if (text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
2597 | "RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists() || text("再来一局").exists())//遇到❌号,则答错了,不再通过结束本局字样判断
2598 | { console.error("随机点击错误!!!");
2599 | /*checkAndUpdate(question, answer, ClickAnswer);*/
2600 | }
2601 | console.log("---------------------------");
2602 | }
2603 | }
2604 |
2605 | function judge_tiku_existence() {
2606 | var dbName = "tiku.db";//题库文件名
2607 | var path = files.path(dbName);
2608 | if (!files.exists(path)) {
2609 | //files.createWithDirs(path);
2610 | console.error("未找到题库!请将题库文件放置与js文件同一目录下再运行!");
2611 | return false;
2612 | }
2613 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
2614 | var createTable = "\
2615 | CREATE TABLE IF NOT EXISTS tikuNet(\
2616 | question CHAR(253),\
2617 | answer CHAR(100)\
2618 | );";
2619 | db.execSQL(createTable);
2620 | return true;
2621 | }
2622 |
2623 | function getAnswer(question, table_name) {
2624 | var dbName = "tiku.db";//题库文件名
2625 | var path = files.path(dbName);
2626 |
2627 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
2628 |
2629 | sql = "SELECT answer FROM " + table_name + " WHERE question LIKE '" + question + "%'"
2630 | var cursor = db.rawQuery(sql, null);
2631 | if (cursor.moveToFirst()) {
2632 | var answer = cursor.getString(0);
2633 | cursor.close();
2634 | return answer;
2635 | }
2636 | else {
2637 | console.error("题库中未找到答案");
2638 | cursor.close();
2639 | return '';
2640 | }
2641 | }
2642 |
2643 | function insertOrUpdate(sql) {
2644 | var dbName = "tiku.db";
2645 | var path = files.path(dbName);
2646 | if (!files.exists(path)) {
2647 | //files.createWithDirs(path);
2648 | console.error("未找到题库!请将题库放置与js同一目录下");
2649 | }
2650 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
2651 | db.execSQL(sql);
2652 | db.close();
2653 | }
2654 |
2655 | /*************************************************每日答题/每周答题部分***************************************************/
2656 |
2657 | function dailyQuestion() {
2658 | while (!id("home_bottom_tab_button_work").exists());//等待加载出主页
2659 | id("home_bottom_tab_button_work").findOne().click();//点击主页正下方的"学习"按钮
2660 | delay(2);
2661 | text("我的").click();
2662 | if (!textContains("我要答题").exists()) {
2663 | delay(1);
2664 | click("我要答题");
2665 | } else {
2666 | (!text("我要答题").exists());
2667 | delay(1);
2668 | text("我要答题").findOne().parent().click();
2669 | }
2670 | while (!text("每日答题").exists());
2671 | delay(1);
2672 | text("每日答题").click();
2673 | console.log("开始每日答题")
2674 | delay(2);
2675 | let dlNum = 0;//每日答题轮数
2676 | while (true) {
2677 | dailyQuestionLoop();
2678 | /*dailyQuiz();*/
2679 | if (text("再来一组").exists()) {
2680 | delay(2);
2681 | dlNum++;
2682 | if (!text("领取奖励已达今日上限").exists()) {
2683 | text("再来一组").click();
2684 | console.warn("第" + (dlNum + 1).toString() + "轮答题:");
2685 | delay(1);
2686 | } else {
2687 | console.log("每日答题结束!返回主页!")
2688 | text("返回").click(); delay(0.5);
2689 | back(); delay(1);
2690 | back(); delay(1);
2691 | break;
2692 | }
2693 | }
2694 | }
2695 | }
2696 |
2697 |
2698 | function weeklyQuestion() {
2699 | let h = device.height;//屏幕高
2700 | let w = device.width;//屏幕宽
2701 | let x = (w / 3) * 2;//横坐标2分之3处
2702 | let h1 = (h / 6) * 5;//纵坐标6分之5处
2703 | let h2 = (h / 6);//纵坐标6分之1处
2704 | text("我的").click();
2705 | if (!textContains("我要答题").exists()) {
2706 | delay(1);
2707 | click("我要答题");
2708 | } else {
2709 | (!text("我要答题").exists());
2710 | delay(1);
2711 | text("我要答题").findOne().parent().click();
2712 | }
2713 | /*while (!textContains("我要答题").exists());
2714 | delay(1);
2715 | click("我要答题");*/
2716 | while (!text("每周答题").exists());
2717 | delay(1);
2718 | text("每周答题").click();
2719 | console.log("开始每周答题")
2720 | //delay(2);
2721 | //text("未作答").click();
2722 |
2723 | //翻页点击每周作答
2724 | //let sublist = className("ListView").findOnce(0);//控件错误,用swipe划,7.0以下可能错误
2725 | let i = 0;//参考订阅的翻页,只进行一次点击
2726 | while (i < 1) {
2727 | if (text("未作答").exists()) {
2728 | text("未作答").click();
2729 | i++;
2730 | } else if (text("您已经看到了我的底线").exists()) {
2731 | console.log("没有可作答的每周答题了,退出!!!")
2732 | back(); delay(1);
2733 | back(); delay(1);
2734 | back(); delay(1);
2735 | return;
2736 | } else {
2737 | delay(1);
2738 | swipe(x, h1, x, h2, 500);//往下翻(纵坐标从5/6处滑到1/6处)
2739 | //console.log("滑动查找未作答的每周答题")
2740 | }
2741 | }
2742 | ////翻页点击每周作答
2743 |
2744 | let dlNum = 0;//每日答题轮数
2745 | while (true) {
2746 | delay(1)
2747 | while (!(textStartsWith("填空题").exists() || textStartsWith("多选题").exists() || textStartsWith("单选题").exists())) {
2748 | console.error("没有找到题目!请检查是否进入答题界面!");
2749 | delay(2);
2750 | }
2751 | dailyQuestionLoop();
2752 | if (text("再练一次").exists()) {
2753 | console.log("每周答题结束,返回!")
2754 | text("返回").click(); delay(2);
2755 | back(); delay(1);
2756 | back(); delay(1);
2757 | while (!textContains("我要答题").exists()) {
2758 | back(); delay(1);
2759 | }
2760 | break;
2761 | } else if (text("查看解析").exists()) {
2762 | console.log("每周答题结束!")
2763 | back(); delay(0.5);
2764 | back(); delay(0.5);
2765 | break;
2766 | } else if (text("再来一组").exists()) {
2767 | delay(2);
2768 | dlNum++;
2769 | if (!text("领取奖励已达今日上限").exists()) {
2770 | text("再来一组").click();
2771 | console.warn("第" + (dlNum + 1).toString() + "轮答题:");
2772 | delay(1);
2773 | }
2774 | else {
2775 | console.log("每周答题结束,返回!")
2776 | text("返回").click(); delay(2);
2777 | while (!textContains("我要答题").exists()) {
2778 | console.log("专项答题结束,返回!")
2779 | back(); delay(1);
2780 | }
2781 | back(); delay(1);
2782 | break;
2783 | }
2784 | }
2785 | }
2786 | //回退返回主页
2787 | while (!id("home_bottom_tab_button_work").exists()) {
2788 | back();
2789 | delay(0.5);
2790 | }
2791 | }
2792 |
2793 | function specialQuestion() {
2794 | let h = device.height;//屏幕高
2795 | let w = device.width;//屏幕宽
2796 | let x = (w / 3) * 2;//横坐标2分之3处
2797 | let h1 = (h / 6) * 5;//纵坐标6分之5处
2798 | let h2 = (h / 6);//纵坐标6分之1处
2799 | text("我的").click();
2800 | if (!textContains("我要答题").exists()) {
2801 | delay(1);
2802 | click("我要答题");
2803 | } else {
2804 | (!text("我要答题").exists());
2805 | delay(1);
2806 | text("我要答题").findOne().parent().click();
2807 | }
2808 | /*while (!textContains("我要答题").exists());
2809 | delay(1);
2810 | click("我要答题");*/
2811 | while (!text("专项答题").exists());
2812 | delay(1);
2813 | text("专项答题").click();
2814 | console.log("开始专项答题")
2815 | delay(2);
2816 | /*
2817 | if(text("继续答题").exists())
2818 | {
2819 | text("继续答题").click();
2820 | }else{
2821 | text("开始答题").click();
2822 | }
2823 | */
2824 |
2825 | //翻页点击专项答题
2826 | let i = 0;
2827 | while (i < 1) {
2828 | if (text("继续答题").exists()) {
2829 | text("继续答题").click();
2830 | i++;
2831 | //console.log("1471")
2832 | } else if (text("开始答题").exists()) {
2833 | text("开始答题").click();
2834 | i++;
2835 | //console.log("1474")
2836 | } else if (text("您已经看到了我的底线").exists()) {
2837 | console.log("没有可作答的专项答题了,退出!!!")
2838 | back(); delay(1);
2839 | back(); delay(1);
2840 | back(); delay(1);
2841 | return;
2842 | } else if (text("已过期").exists()) {
2843 | console.log("存在已过期的专项答题,无法作答,退出!!!")
2844 | back();
2845 | delay(2);
2846 | back(); delay(1);
2847 | back(); delay(1);
2848 | return;
2849 | } else {
2850 | delay(1);
2851 | swipe(x, h1, x, h2, 500);//往下翻(纵坐标从5/6处滑到1/6处)
2852 | delay(1);
2853 | console.log("滑动查找未作答的专项答题")
2854 | }
2855 | }
2856 | ////翻页点击专项答题
2857 |
2858 | let dlNum = 0;//每日答题轮数
2859 | while (true) {
2860 | delay(1)
2861 | while (!(textStartsWith("填空题").exists() || textStartsWith("多选题").exists() || textStartsWith("单选题").exists())) {
2862 | console.error("没有找到题目!请检查是否进入答题界面!");
2863 | delay(2);
2864 | }
2865 | dailyQuestionLoop();
2866 | if (text("再练一次").exists()) {
2867 | console.log("专项答题结束!")
2868 | text("返回").click(); delay(2);
2869 | back();
2870 | break;
2871 | } else if (text("查看解析").exists()) {
2872 | console.log("专项答题结束,返回!")
2873 | back(); delay(0.5);
2874 | back(); delay(0.5);
2875 | back(); delay(1);
2876 | while (!textContains("我要答题").exists()) {
2877 | back(); delay(1);
2878 | }
2879 | break;
2880 | } else if (text("再来一组").exists()) {
2881 | delay(2);
2882 | dlNum++;
2883 | if (!text("领取奖励已达今日上限").exists()) {
2884 | text("再来一组").click();
2885 | console.warn("第" + (dlNum + 1).toString() + "轮答题:");
2886 | delay(1);
2887 | }
2888 | else {
2889 | console.log("专项答题结束,返回!")
2890 | delay(2);
2891 | while (!textContains("专项答题").exists()) {
2892 | console.log("专项答题结束,返回!")
2893 | back(); delay(1);
2894 | }
2895 | back(); delay(1);
2896 | break;
2897 | }
2898 | }
2899 | }
2900 | //回退返回主页
2901 | while (!id("home_bottom_tab_button_work").exists()) {
2902 | back();
2903 | delay(0.5);
2904 | }
2905 | }
2906 |
2907 | function drawfloaty(x, y) {
2908 | //floaty.closeAll();
2909 | var window = floaty.window(
2910 |
2911 |
2912 |
2913 | );
2914 | window.setPosition(x, y - 45);
2915 | return window;
2916 | }
2917 |
2918 | function dailyQuestionLoop() {
2919 | var blankArray = [];
2920 | var question = "";
2921 | var answer = "";
2922 | if (textStartsWith("填空题").exists()) {
2923 | var questionArray = getFitbQuestion();
2924 | questionArray.forEach(item => {
2925 | if (item != null && item.charAt(0) == "|") { //是空格数
2926 | blankArray.push(item.substring(1));
2927 | } else { //是题目段
2928 | question += item;
2929 | }
2930 | });
2931 | question = question.replace(/\s/g, "");
2932 | console.log("题目:" + question);
2933 | var ansTiku = getAnswer(question, 'tiku');
2934 | if (ansTiku.length == 0) {//tiku表中没有则到tikuNet表中搜索答案
2935 | ansTiku = getAnswer(question, 'tikuNet');
2936 | }
2937 | answer = ansTiku.replace(/(^\s*)|(\s*$)/g, "");
2938 | if (answer == "") { //答案空,前面题库未找到答案,找提示
2939 | var tipsStr = getTipsStr();
2940 | answer = getAnswerFromTips(questionArray, tipsStr);
2941 | console.info("提示答案:" + answer);
2942 | setText(0, answer.substr(0, blankArray[0]));
2943 | if (blankArray.length > 1) {
2944 | for (var i = 1; i < blankArray.length; i++) {
2945 | setText(i, answer.substr(blankArray[i - 1], blankArray[i]));
2946 | }
2947 | }
2948 | checkAndUpdate(question, ansTiku, answer);
2949 | } else { //答案非空,题库中已找到答案
2950 | console.info("答案:" + answer);
2951 | setText(0, answer.substr(0, blankArray[0]));
2952 | if (blankArray.length > 1) {
2953 | for (var i = 1; i < blankArray.length; i++) {
2954 | setText(i, answer.substr(blankArray[i - 1], blankArray[i]));
2955 | }
2956 | }
2957 | }
2958 | }
2959 | else if (textStartsWith("多选题").exists() || textStartsWith("单选题").exists()) {
2960 | var questionArray = getChoiceQuestion();
2961 | questionArray.forEach(item => {
2962 | if (item != null && item.charAt(0) == "|") { //是空格数
2963 | blankArray.push(item.substring(1));
2964 | } else { //是题目段
2965 | question += item;
2966 | }
2967 | });
2968 | var options = [];//选项列表
2969 | if (className("ListView").exists()) {//选择题提取答案,为字形题 注音题准备
2970 | className("ListView").findOne().children().forEach(child => {
2971 | var answer_q = child.child(0).child(2).text();//此处child(2)为去除选项A.的选项内容,与争上游不同
2972 | options.push(answer_q);
2973 | });
2974 | } else {
2975 | console.error("答案获取失败!");
2976 | return;
2977 | }
2978 | question = question.replace(/\s/g, "");
2979 | if (question == ZiXingTi.replace(/\s/g, "") || question == DuYinTi.replace(/\s/g, "") || question == ErShiSiShi.replace(/\s/g, "")) {
2980 | question = question + options[0]; //字形题 读音题 在题目后面添加第一选项
2981 | }
2982 | console.log("题目:" + question);
2983 | var ansTiku = getAnswer(question, 'tiku');
2984 | if (ansTiku.length == 0) {//tiku表中没有则到tikuNet表中搜索答案
2985 | ansTiku = getAnswer(question, 'tikuNet');
2986 | }
2987 | answer = ansTiku.replace(/(^\s*)|(\s*$)/g, "");
2988 | if (answer == "") {
2989 | var tipsStr = getTipsStr();
2990 | answer = clickByTips(tipsStr);
2991 | console.info("提示中的答案:" + answer);
2992 | if (text("单选题").exists()){//仅单选题更新题库,多选题不更新进题库
2993 | checkAndUpdate(question, ansTiku, answer);
2994 | }
2995 | } else {
2996 | console.info("答案:" + ansTiku);
2997 | delay(random(0.5, 1));//随机延时0.5-1秒
2998 | clickByAnswer(answer);
2999 | }
3000 | }
3001 | delay(random(0.5, 1));//随机延时0.5-1秒
3002 | if (text("确定").exists()) {//每日每周答题
3003 | text("确定").click();
3004 | delay(random(0.5, 1));//随机延时0.5-1秒
3005 | } else if (text("下一题").exists()) {//专项答题
3006 | text("下一题").click();
3007 | delay(random(0.5, 1));//随机延时0.5-1秒
3008 | }else if (text("完成").exists()) {//专项答题最后一题
3009 | text("完成").click();
3010 | delay(random(0.5, 1));//随机延时0.5-1秒
3011 | } else{
3012 | console.warn("未找到右上角按钮,尝试根据坐标点击");
3013 | click(device.width * 0.85, device.height * 0.06);//右上角确定按钮,根据自己手机实际修改
3014 | console.warn("请手动处理");
3015 | delay(5);
3016 | }
3017 | console.log("---------------------------");
3018 | delay(2);
3019 | }
3020 |
3021 |
3022 | function getFitbQuestion() {
3023 | var questionCollections = className("EditText").findOnce().parent().parent();
3024 | var questionArray = [];
3025 | var findBlank = false;
3026 | var blankCount = 0;
3027 | var blankNumStr = "";
3028 | var i = 0;
3029 | questionCollections.children().forEach(item => {
3030 | if (item.className() != "android.widget.EditText") {
3031 | if (item.text() != "") {//题目段
3032 | if (findBlank) {
3033 | blankNumStr = "|" + blankCount.toString();
3034 | questionArray.push(blankNumStr);
3035 | findBlank = false;
3036 | }
3037 | questionArray.push(item.text());
3038 | } else {
3039 | findBlank = true;
3040 | /*blankCount += 1;*/
3041 | blankCount = (className("EditText").findOnce(i).parent().childCount() -1);
3042 | i++;
3043 | }
3044 | }
3045 | });
3046 | return questionArray;
3047 | }
3048 |
3049 |
3050 | function getChoiceQuestion() {
3051 | var questionCollections = className("ListView").findOnce().parent().child(1);
3052 | var questionArray = [];
3053 | questionArray.push(questionCollections.text());
3054 | return questionArray;
3055 | }
3056 |
3057 |
3058 | function getTipsStr() {
3059 | var tipsStr = "";
3060 | while (tipsStr == "") {
3061 | if (text("查看提示").exists()) {
3062 | var seeTips = text("查看提示").findOnce();
3063 | seeTips.click();
3064 | delay(1);
3065 | click(device.width * 0.5, device.height * 0.41);
3066 | delay(1);
3067 | click(device.width * 0.5, device.height * 0.35);
3068 | } else {
3069 | console.error("未找到查看提示");
3070 | }
3071 | if (text("提示").exists()) {
3072 | var tipsLine = text("提示").findOnce().parent();
3073 | //获取提示内容
3074 | var tipsView = tipsLine.parent().child(1).child(0);
3075 | tipsStr = tipsView.text();
3076 | //关闭提示
3077 | tipsLine.child(1).click();
3078 | break;
3079 | }
3080 | delay(1);
3081 | }
3082 | return tipsStr;
3083 | }
3084 |
3085 |
3086 | function getAnswerFromTips(questionArray, tipsStr) {
3087 | var ansTips = "";
3088 | for (var i = 1; i < questionArray.length -1; i++) {
3089 | if (questionArray[i].charAt(0) == "|") {
3090 | var blankLen = questionArray[i].substring(1);
3091 | var indexKey = tipsStr.indexOf(questionArray[i + 1]);
3092 | var ansFind = tipsStr.substr(indexKey - blankLen, blankLen);
3093 | /*ansTips += ansFind;*/
3094 | ansTips = ansTips.concat(ansFind);
3095 | }
3096 | }
3097 | return ansTips;
3098 | }
3099 |
3100 | function clickByTips(tipsStr) {
3101 | var clickStr = "";
3102 | var isFind = false;
3103 | if (className("ListView").exists()) {
3104 | var listArray = className("ListView").findOne().children();
3105 | listArray.forEach(item => {
3106 | var ansStr = item.child(0).child(2).text();
3107 | if (tipsStr.indexOf(ansStr) >= 0) {
3108 | item.child(0).click();
3109 | clickStr += item.child(0).child(1).text().charAt(0);
3110 | isFind = true;
3111 | }
3112 | });
3113 | if (!isFind) { //没有找到 点击第一个
3114 | listArray[0].child(0).click();
3115 | clickStr += listArray[0].child(0).child(1).text().charAt(0);
3116 | }
3117 | }
3118 | return clickStr;
3119 | }
3120 |
3121 |
3122 | function clickByAnswer(answer) {
3123 | if (className("ListView").exists()) {
3124 | var listArray = className("ListView").findOnce().children();
3125 | listArray.forEach(item => {
3126 | var listIndexStr = item.child(0).child(1).text().charAt(0);
3127 | //单选答案为非ABCD
3128 | var listDescStr = item.child(0).child(2).text();
3129 | if (answer.indexOf(listIndexStr) >= 0 || answer == listDescStr) {
3130 | item.child(0).click();
3131 | }
3132 | });
3133 | }
3134 | }
3135 |
3136 | function checkAndUpdate(question, ansTiku, answer) {
3137 | if (className("Button").desc("下一题").exists() || className("Button").desc("完成").exists()) {//答错了
3138 | swipe(100, device.height - 100, 100, 100, 500);
3139 | var nCout = 0
3140 | while (nCout < 5) {
3141 | if (descStartsWith("正确答案").exists()) {
3142 | var correctAns = descStartsWith("正确答案").findOnce().desc().substr(5);
3143 | console.info("正确答案是:" + correctAns);
3144 | if (ansTiku == "") { //题库为空则插入正确答案
3145 | var sql = "INSERT INTO tiku VALUES ('" + question + "','" + correctAns + "','')";
3146 | } else { //更新题库答案
3147 | var sql = "UPDATE tiku SET answer='" + correctAns + "' WHERE question LIKE '" + question + "'";
3148 | }
3149 | insertOrUpdate(sql);
3150 | console.log("更新题库答案...");
3151 | delay(1);
3152 | break;
3153 | } else {
3154 | var clickPos = className("android.webkit.WebView").findOnce().child(2).child(0).child(1).bounds();
3155 | click(clickPos.left + device.width * 0.13, clickPos.top + device.height * 0.1);
3156 | console.error("未捕获正确答案,尝试修正");
3157 | }
3158 | nCout++;
3159 | }
3160 | if (className("Button").exists()) {
3161 | className("Button").findOnce().click();
3162 | } else {
3163 | click(device.width * 0.85, device.height * 0.06);
3164 | }
3165 | } else { //正确后进入下一题,或者进入再来一局界面
3166 | if (ansTiku == "" && answer != "") { //正确进入下一题,且题库答案为空
3167 | var sql = "INSERT INTO tiku VALUES ('" + question + "','" + answer + "','')";
3168 | insertOrUpdate(sql);
3169 | console.log("更新题库答案...");
3170 | }
3171 | }
3172 | }
3173 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | 2022.12.23:这个项目已经废弃了,因为我用不上了,不学习强国了。推荐使用https://github.com/TechXueXi/TechXueXi这个库。
2 |
3 | 2021.10.15:新添加了一个大哥的,不过我看他GitHub上只更新到了去年,不知道后面又是谁二次加工的,可以试试看,因为我确实用不到学习强国了,所以实在是不想继续写了,可以等以后用Python写一个,不过近期是不考虑了,但是有需求的大哥可以发邮件给我!
4 |
5 |
6 | 2021.10.5:好久好久没有这个东西了,懒得进行更新了,因为我好久好久没有打开过学习强国这个东西了,其实逻辑什么的就是那些东西,非常非常简单,大家自己随便改改就好了。然后再就是如果有功能比较nice的autojs脚本可以发我瞅瞅,不过其实大部分的autojs脚本都可以通过庖丁来进行解密,并且其实GitHub上面有许多许多强国的脚本,大家可以自己寻找一下自己需要的。
7 |
8 |
9 | 按键精灵root版:目前版本趋于稳定,技术水平有所提高,所以将软件源码进行开源,没有加上每日答题和每周答题,因为我懒得加了,反正看上面的代码就能明白我的思路了,截图我也不往上放了,只是提供一个借鉴的地方而已,当然这种东西也就自己用用。
10 | 软件成品大概率不会进行更新了,咱们的缘分大概也就到这里了。
11 | 另外如果有手游脚本,每日任务之类的可以找我有偿写。
12 | 另外如果有什么关于按键精灵的问题可以在discord上问我,欢迎提问!
13 |
14 |
15 |
16 |
17 |
18 | 使用说明:
19 | 1.root权限手机一台,推荐使用模拟器(如果出现问题,请将模拟器的机型设置为小米9)
20 | 2.手机分辨率为720*1280,dpi为320
21 | 3.学习强国app
22 | 4.就要强国app
23 | 5.登录学习强国并且将版本升级,权限请求之类的弹窗点掉
24 |
25 |
26 | 然后我们打开就要强国,勾选相应功能,点击启动即可!本脚本完全免费,如果您为该脚本进行付费请进行相应的退款等操作.
27 | 解锁密码很容易找到,我们勾选同意并且填入解锁密码就能开始使用了.
28 |
29 | 目前功能:选读文章,看视频,订阅,双人对战,多人对战,挑战答题,每日答题,每周答题,专项答题,评论,分享,本地频道等除强国运动外的所有功能.
30 |
31 | 推荐使用功能:选读文章,看视频,订阅,双人对战,多人对战,挑战答题,每日答题,评论,分享,本地频道.
32 | autojs免root版:目前开始功能测试,欢迎大家提交反馈。
33 | 使用说明:
34 | 1.安卓手机一台(不能太老)
35 | 2.给予无障碍以及悬浮窗权限
36 | 3.学习强国app
37 | 4.就要强国app
38 | 5.登录账号,并处理弹窗/问题不是很大
39 |
40 | 功能:选读文章,看视频,订阅,双人对战,多人对战,挑战答题,分享,评论,本地频道。
41 |
42 | 下载地址:同上。
43 |
44 | 如果有什么疑问请发邮件or前往discord询问。
45 | 也可以通过telegram加我:datehoer
46 |
--------------------------------------------------------------------------------
/tikuCommon.js:
--------------------------------------------------------------------------------
1 | importClass(android.database.sqlite.SQLiteDatabase);
2 |
3 | function searchTiku(keyw) {
4 | //表名
5 | var tableName = "tiku";
6 | var ansArray = searchDb(keyw, tableName, "");
7 | return ansArray;
8 |
9 | }
10 |
11 | function searchDb(keyw, _tableName, queryStr) {
12 | var tableName = _tableName;
13 | //数据文件名
14 | var dbName = "tiku.db";
15 | //文件路径
16 | var path = files.path(dbName);
17 | //确保文件存在
18 | if (!files.exists(path)) {
19 | files.createWithDirs(path);
20 | }
21 | //创建或打开数据库
22 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
23 | var query = "";
24 | if (queryStr == "") {
25 | query = "SELECT question,answer FROM " + tableName + " WHERE question LIKE '" + keyw + "%'";//前缀匹配
26 | } else {
27 | query = queryStr;
28 | }
29 |
30 | log(query);
31 | //query="select * from tiku"
32 | //db.execSQL(query);
33 |
34 | var cursor = db.rawQuery(query, null);
35 | cursor.moveToFirst();
36 | var ansTiku = [];
37 | if (cursor.getCount() > 0) {
38 | do {
39 | var timuObj={"question" : cursor.getString(0),"answer":cursor.getString(1)};
40 | ansTiku.push(timuObj);
41 | } while (cursor.moveToNext());
42 | } else {
43 | log("题库中未找到: " + keyw);
44 | }
45 | cursor.close();
46 | return ansTiku;
47 |
48 | }
49 |
50 | function executeSQL(sqlstr) {
51 | //数据文件名
52 | var dbName = "tiku.db";
53 | //文件路径
54 | var path = files.path(dbName);
55 | //确保文件存在
56 | if (!files.exists(path)) {
57 | files.createWithDirs(path);
58 | }
59 | //创建或打开数据库
60 | var db = SQLiteDatabase.openOrCreateDatabase(path, null);
61 | db.execSQL(sqlstr);
62 | toastLog(sqlstr);
63 | db.close();
64 | }
65 |
66 |
67 | function indexFromChar(str) {
68 | return str.charCodeAt(0) - "A".charCodeAt(0);
69 | }
70 |
71 | function searchNet(keyw) {
72 | var tableName = "tikuNet";
73 | var ansArray = searchDb(keyw, tableName, "");
74 | return ansArray;
75 | }
76 |
77 | exports.searchTiku = searchTiku;
78 | exports.searchNet = searchNet;
79 | exports.searchDb = searchDb;
80 | exports.indexFromChar = indexFromChar;
81 | exports.executeSQL = executeSQL;
82 |
--------------------------------------------------------------------------------
/双人对战.mq:
--------------------------------------------------------------------------------
1 | Do
2 | FindPic 0,0,0,0,"Attachment:双人对战标志.png","000000",0,0.9,intX,intY
3 | If intX > -1 And intY > -1 Then
4 | Tap intX + 490, intY
5 | TracePrint "双人对战"
6 | Delay 3000
7 | Exit Do
8 | Else
9 | Swipe 238, 616, 238, 437, 3000
10 | Delay 2000
11 | End If
12 | Loop
13 | FindPic 0,0,0,0,"Attachment:随即对战.png","000000",0,0.9,intX,intY
14 | If intX > -1 And intY > -1 Then
15 | Tap intX,intY
16 | TracePrint "随机对战"
17 | Delay 3000
18 | End If
19 | Dim x1,y1,d1,x,y,d
20 | Randomize
21 | x1 = Array("189", "500")
22 | y1 = Array("560", "1036")
23 | d1 = Array("1000", "1500")
24 | Do
25 | x = Int((x1(0) - x1(1) + 1) * Rnd() + x1(1))
26 | y = Int((y1(0) - y1(1) + 1) * Rnd() + y1(1))
27 | d = Int((d1(0) - d1(1) + 1) * Rnd() + d1(1))
28 | Tap x, y
29 | Delay d
30 | FindPic 0,0,0,0,"Attachment:对战失败.png","000000",0,0.9,intX,intY
31 | If intX > -1 And intY > -1 Then
32 | Exit Do
33 | End If
34 | FindPic 0,0,0,0,"Attachment:对战胜利.png","000000",0,0.9,intX,intY
35 | If intX > -1 And intY > -1 Then
36 | Exit Do
37 | End If
38 | FindPic 0,0,0,0,"Attachment:继续挑战.png","000000",0,0.9,intX,intY
39 | If intX > -1 And intY > -1 Then
40 | Exit Do
41 | End If
42 | Loop
43 | Delay 3000
44 | Tap 51, 92
45 | Delay 2000
46 | Tap 48, 89
47 | Delay 2000
48 | Tap 229, 725
49 | Delay 2000
50 | Tap 41, 96
51 | Delay 2000
52 |
53 |
--------------------------------------------------------------------------------
/多人对战.mq:
--------------------------------------------------------------------------------
1 | Do
2 | FindPic 0,0,0,0,"Attachment:多人对战.png","000000",0,0.9,intX,intY
3 | If intX > -1 And intY > -1 Then
4 | Tap intX+460,intY
5 | TracePrint "多人对战"
6 | Delay 1500
7 | Exit Do
8 | Else
9 | Swipe 370, 1017, 370, 717
10 | Delay 2000
11 | End If
12 | Loop
13 |
14 | For 2
15 | Tap 358, 1020
16 | Delay 3000
17 | Dim x1,y1,d1,x,y,d
18 | Randomize
19 | x1 = Array("189", "500")
20 | y1 = Array("560", "1036")
21 | d1 = Array("1000", "1500")
22 | Do
23 | x = Int((x1(0) - x1(1) + 1) * Rnd() + x1(1))
24 | y = Int((y1(0) - y1(1) + 1) * Rnd() + y1(1))
25 | d = Int((d1(0) - d1(1) + 1) * Rnd() + d1(1))
26 | Tap x, y
27 | Delay d
28 | FindPic 0,0,0,0,"Attachment:对战失败.png","000000",0,0.9,intX,intY
29 | If intX > -1 And intY > -1 Then
30 | Exit Do
31 | End If
32 | FindPic 0,0,0,0,"Attachment:对战胜利.png","000000",0,0.9,intX,intY
33 | If intX > -1 And intY > -1 Then
34 | Exit Do
35 | End If
36 | FindPic 0,0,0,0,"Attachment:多人对战标志完成标志.png","000000",0,0.9,intX,intY
37 | If intX > -1 And intY > -1 Then
38 | Exit Do
39 | End If
40 | Loop
41 | Delay 3000
42 | Tap 190, 1188
43 | Delay 1500
44 | Next
45 | Tap 49, 93
46 | Delay 1500
47 | Tap 41, 99
48 | Delay 1500
49 |
--------------------------------------------------------------------------------
/就要强国1.96-0312.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datehoer/studygoodcountry/e55d77cf69601d353016b885d7c88ab8d74ef4d7/就要强国1.96-0312.apk
--------------------------------------------------------------------------------
/就要强国_v0.9.9.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datehoer/studygoodcountry/e55d77cf69601d353016b885d7c88ab8d74ef4d7/就要强国_v0.9.9.apk
--------------------------------------------------------------------------------
/挑战答题.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datehoer/studygoodcountry/e55d77cf69601d353016b885d7c88ab8d74ef4d7/挑战答题.mp4
--------------------------------------------------------------------------------
/挑战答题.mq:
--------------------------------------------------------------------------------
1 | // 简单开源一下这个挑战答题的功能,因为我发现这个其实很好想,但是挺难做的。
2 | // 请勿将它使用到商业用途,因为会被抓。
3 | // 仅供学习交流。
4 | Function 挑战答题
5 | Dim num = 1
6 | Swipe 364, 1161, 364, 735
7 | Delay 1500
8 | Swipe 364, 1161, 364, 935
9 | Delay 1500
10 | Dim intX,intY
11 | FindPic 0,0,0,0,"Attachment:挑战答题识别.png","000000",0,0.9,intX,intY
12 | If intX > -1 And intY > -1 Then
13 | Tap intX+500,intY
14 | TracePrint "挑战答题"
15 | Delay 5000
16 | Else
17 | Tap 41, 102
18 | Delay 1000
19 | Exit Function
20 | End If
21 | Import "shanhai.lua"
22 | Import "zm.luae" //导入插件,只需执行一次
23 | zm.Init //初始化插件,只需执行一次
24 | Dim t(),题目
25 | If Not zm.OcrBaiDuInit("api""密钥") Then
26 | TracePrint "初始化设置百度云识别失败"
27 | EndScript
28 | End If
29 | //全屏识别文字
30 | Do
31 |
32 | For 9
33 | 题目 = zm.OcrBaiDu(443,290,676,349)
34 | TracePrint 题目
35 | dim a = zm.HttpGet("http://www.syiban.com/search/index/init.html?modelid=1&q="&题目)
36 | TracePrint a
37 | //LUA模式匹配,返回数组
38 | dim RegexArr = shanhai.RegexFind(a,"答案:(.-)%<")
39 | TracePrint RegexArr(0)
40 | If RegexArr(0) = null Then
41 | //76,294,323,343
42 | 题目 = zm.OcrBaiDu(76,294,323,343)
43 | TracePrint 题目
44 | a = zm.HttpGet("http://www.syiban.com/search/index/init.html?modelid=1&q="&题目)
45 | TracePrint a
46 | //LUA模式匹配,返回数组
47 | RegexArr = shanhai.RegexFind(a,"答案:(.-)%<")
48 | If RegexArr(0) = null Then
49 | // 349,349,531,394
50 | 题目 = zm.OcrBaiDu(349,349,531,394)
51 | TracePrint 题目
52 | a = zm.HttpGet("http://www.syiban.com/search/index/init.html?modelid=1&q="&题目)
53 | TracePrint a
54 | TracePrint RegexArr(0)
55 | If RegexArr(0) = null Then
56 | TracePrint "null"
57 | Tap 51, 90
58 | Delay 1500
59 | Tap 220, 756
60 | Delay 1500
61 | Exit For
62 | End If
63 | End If
64 | End If
65 | Dim newanswer = shanhai.RegexFind(RegexArr(0),"[A-Z]")
66 | TracePrint newanswer(0)
67 | If num > 7 Then
68 | Tap 341, 785
69 | Delay 1500
70 | End If
71 | //判断选项位置
72 | FindPic 0,0,0,0,"Attachment:句号判断1.png","000000",2,0.9,intX,intY
73 | If intX > -1 And intY > -1 Then
74 | Tap intX,intY
75 | TracePrint "a"&intX,intY
76 | Delay 1500
77 | Else
78 | FindPic 0, 0, 0, 0, "Attachment:句号判断2.png", "000000", 2, 0.9, intX, intY
79 | If intX > -1 And intY > -1 Then
80 | TracePrint "b"&intX,intY
81 | Delay 1500
82 | Else
83 | FindPic 0,0,0,0,"Attachment:句号判断3.png","000000",2,0.9,intX,intY
84 | If intX > -1 And intY > -1 Then
85 | TracePrint "c"&intX,intY
86 | Delay 1500
87 | End If
88 | End If
89 | End If
90 | If newanswer(0) = "A" Then
91 | TracePrint "a"
92 | Tap intX, intY + 170
93 | TracePrint intX, intY + 170
94 | Delay 1500
95 | ElseIf newanswer(0) = "B" Then
96 | TracePrint "b"
97 | Tap intX, intY + 290
98 | TracePrint intX, intY + 290
99 | Delay 1500
100 | ElseIf newanswer(0) = "C" Then
101 | TracePrint "c"
102 | Tap intX, intY + 410
103 | TracePrint intX, intY + 410
104 | Delay 1500
105 | ElseIf newanswer(0) = "D" Then
106 | TracePrint "d"
107 | Tap intX, intY + 540
108 | TracePrint intX, intY + 540
109 | Delay 1500
110 | Else
111 | Tap 341, 785
112 | Delay 1500
113 | End If
114 | FindPic 0,0,0,0,"Attachment:挑战答题意外结束.png","000000",0,0.9,intX,intY
115 | If intX > -1 And intY > -1 Then
116 | Tap 217,886
117 | Delay 1500
118 | Tap 51, 92
119 | Delay 1500
120 | Exit For
121 | End If
122 | Next
123 | FindPic 0,0,0,0,"Attachment:挑战答题意外结束.png","000000",0,0.9,intX,intY
124 | If intX > -1 And intY > -1 Then
125 | Tap 217,886
126 | Delay 1500
127 | Tap 51, 92
128 | Delay 1500
129 | End If
130 | Delay 3000
131 | FindPic 0,0,0,0,"Attachment:挑战答题识别.png","000000",0,0.9,intX,intY
132 | If intX > -1 And intY > -1 Then
133 | Tap intX+500,intY
134 | TracePrint "挑战答题"
135 | Delay 5000
136 | Else
137 | Tap 41, 102
138 | Delay 1000
139 | Exit Function
140 | End If
141 | Loop
142 | End Function
143 |
--------------------------------------------------------------------------------
/本地频道.mq:
--------------------------------------------------------------------------------
1 | For 3
2 | Swipe 364, 1161, 364, 735
3 | Next
4 | Delay 1500
5 | FindPic 0,0,0,0,"Attachment:本地频道判断.png","000000",0,0.9,intX,intY
6 | If intX > -1 And intY > -1 Then
7 | Tap intX + 460, intY
8 | Delay 1000
9 | End If
10 | Delay 2000
11 | FindPic 0,0,0,0,"Attachment:本地频道.png","000000",0,0.9,intX,intY
12 | If intX > -1 And intY > -1 Then
13 | Tap intX, intY
14 | Delay 3000
15 | Tap 46, 93
16 | Delay 1500
17 | End If
18 |
--------------------------------------------------------------------------------
/查看积分.mq:
--------------------------------------------------------------------------------
1 | //推荐将所有部分打包成函数加在一起
2 | Function 查看积分
3 | Tap 562, 95
4 | Delay 3000
5 | Dim 积分=SmartOcr(232,228,497,319, "FFFFFF-000000")
6 | ShowMessage "你的积分为" & 积分
7 | Delay 1500
8 | End Function
9 |
--------------------------------------------------------------------------------
/看视频.mq:
--------------------------------------------------------------------------------
1 | Do
2 | Do
3 | FindPic 0,0,0,0,"Attachment:视频学习.png","000000",0,0.9,intX,intY
4 | If intX > -1 And intY > -1 Then
5 | Tap intX + 480, intY
6 | Delay 1000
7 | Exit Do
8 | Else
9 | For 3
10 | Swipe 364, 735, 364, 1161
11 | Delay 1500
12 | Next
13 | End If
14 | Loop
15 | FindPic 0,0,0,0,"Attachment:百灵.png","000000",0,0.8,intX,intY
16 | If intX > -1 And intY > -1 Then
17 | Tap intX, intY
18 | Delay 3000
19 | Else
20 | Tap 217, 1227
21 | Delay 3000
22 | End If
23 | Tap 349, 446
24 | Delay 450000
25 | Tap 48, 103
26 | Delay 500
27 | Tap 48, 103
28 | Delay 500
29 | Do
30 | FindPic 0,0,0,0,"Attachment:扫一扫.png","000000",0,0.9,intX,intY
31 | If intX > -1 And intY > -1 Then
32 | TracePrint "回到主页"
33 | Exit Do
34 | Else
35 | KeyPress "Back"
36 | Delay 1500
37 | End If
38 | Loop
39 | 查看积分 //这个是查看积分是否全部获得
40 | Swipe 364,1001, 364, 735
41 | Delay 1500
42 | FindPic 0,0,0,0,"Attachment:视频上限.png","000000",0,0.9,intX,intY
43 | If intX > -1 And intY > -1 Then
44 | Exit Function
45 | End If
46 | Loop
47 |
--------------------------------------------------------------------------------
/订阅.mq:
--------------------------------------------------------------------------------
1 | Function 订阅操作
2 | Dim dy = 0
3 | Do
4 |
5 | FindPic 0,0,0,0,"Attachment:订阅按钮.png","000000",0,0.9,intX,intY
6 | If intX > -1 And intY > -1 Then
7 | Tap intX, intY
8 | dy = dy + 1
9 | Delay 1000
10 | TracePrint dy
11 | If dy = 2 Then
12 | TracePrint "订阅结束"
13 | Exit Do
14 | End If
15 | Else
16 | Swipe 238, 616, 238, 437, 3000
17 | Delay 1000
18 | End If
19 |
20 | Loop
21 | End Function
22 | Function 订阅
23 | TracePrint "订阅"
24 | Dim 订阅栏目
25 | 订阅栏目 = ReadUIConfig("下拉框1", 0)
26 | Delay 1000
27 | 查看积分
28 | For 3
29 | Swipe 364, 1161, 364, 735
30 | Next
31 | Delay 1500
32 | FindPic 0,0,0,0,"Attachment:订阅.png","000000",0,0.9,intX,intY
33 | If intX > -1 And intY > -1 Then
34 | Tap intX+300, intY
35 | Delay 3000
36 | End If
37 | Delay 1500
38 | If 订阅栏目 = 0 Then
39 | TracePrint "执行的是",订阅栏目
40 | 订阅操作
41 | ElseIf 订阅栏目 = 1 Then
42 | TracePrint "执行的是",订阅栏目
43 | FindPic 0,0,0,0,"Attachment:主要媒体.png","000000",0,0.9,intX,intY
44 | If intX > -1 And intY > -1 Then
45 | Tap intX,intY
46 | TracePrint intX
47 | TracePrint intY
48 | Delay 1500
49 | End If
50 | 订阅操作
51 | ElseIf 订阅栏目 = 2 Then
52 | TracePrint "执行的是",订阅栏目
53 | FindPic 0,0,0,0,"Attachment:行业媒体.png","000000",0,0.9,intX,intY
54 | If intX > -1 And intY > -1 Then
55 | Tap intX,intY
56 | TracePrint intX
57 | TracePrint intY
58 | Delay 1500
59 | End If
60 | 订阅操作
61 | ElseIf 订阅栏目 = 3 Then
62 | TracePrint "执行的是",订阅栏目
63 | FindPic 0,0,0,0,"Attachment:机关.png","000000",0,0.9,intX,intY
64 | If intX > -1 And intY > -1 Then
65 | Tap intX,intY
66 | TracePrint intX
67 | TracePrint intY
68 | Delay 1500
69 | End If
70 | 订阅操作
71 | ElseIf 订阅栏目 = 4 Then
72 | TracePrint "执行的是",订阅栏目
73 | FindPic 0,0,0,0,"Attachment:高校.png","000000",0,0.9,intX,intY
74 | If intX > -1 And intY > -1 Then
75 | Tap intX,intY
76 | TracePrint intX
77 | TracePrint intY
78 | Delay 1500
79 | End If
80 | 订阅操作
81 | ElseIf 订阅栏目 = 5 Then
82 | TracePrint "执行的是",订阅栏目
83 | FindPic 0,0,0,0,"Attachment:地方媒体.png","000000",0,0.9,intX,intY
84 | If intX > -1 And intY > -1 Then
85 | Tap intX,intY
86 | TracePrint intX
87 | TracePrint intY
88 | Delay 1500
89 | End If
90 | 订阅操作
91 | ElseIf 订阅栏目 = 6 Then
92 | TracePrint "执行的是",订阅栏目
93 | FindPic 0,0,0,0,"Attachment:社会机构.png","000000",0,0.9,intX,intY
94 | If intX > -1 And intY > -1 Then
95 | Tap intX,intY
96 | TracePrint intX
97 | TracePrint intY
98 | Delay 1500
99 | End If
100 | 订阅操作
101 | End If
102 | Tap 40, 95
103 | Delay 1500
104 | Tap 40, 95
105 | Delay 1000
106 | End Function
107 |
--------------------------------------------------------------------------------
/读文章.mq:
--------------------------------------------------------------------------------
1 | Dim i= 0
2 | Delay 1500
3 | FindPic 0,0,0,0,"Attachment:选读文章标志.png","000000",0,0.9,intX,intY
4 | If intX > -1 And intY > -1 Then
5 | TracePrint "跳转"
6 | Tap intX + 500, intY+70
7 | Delay 1000
8 | End If
9 | Delay 2000
10 | TracePrint "要闻"
11 | // 要闻
12 | FindPic 0,0,0,0,"Attachment:要闻.png","000000",0,0.9,intX,intY
13 | If intX > -1 And intY > -1 Then
14 | TracePrint intX, intY
15 | Tap intX, intY
16 | Delay 1000
17 | End If
18 | Delay 2000
19 | // 查找文章
20 | //语音播报
21 | For 8
22 | TracePrint i
23 | Do
24 | FindPic 0,0,0,0,"Attachment:学习强国学习平台.png","000000",0,0.8,intX,intY
25 | If intX > -1 And intY > -1 Then
26 | Tap intX + 500, intY
27 | Delay 1000
28 | Tap intX, intY
29 | Delay 3000
30 | Exit Do
31 | Else
32 | Swipe 364, 1161, 364, 735
33 | Delay 1500
34 | End If
35 | Loop
36 | Delay 2000
37 | // 分享
38 | If i = 1 Then
39 | TracePrint "分享"
40 | FindPic 0,0,0,0,"Attachment:分享.png","000000",0,0.9,intX,intY
41 | If intX > -1 And intY > -1 Then
42 | Tap intX, intY
43 | Delay 2000
44 | End If
45 | FindPic 0,0,0,0,"Attachment:分享到学习强国.png","000000",0,0.8,intX,intY
46 | If intX > -1 And intY > -1 Then
47 | Tap intX, intY
48 | Delay 2000
49 | End If
50 | FindPic 0,0,0,0,"Attachment:选择群聊.png","000000",0,0.8,intX,intY
51 | If intX > -1 And intY > -1 Then
52 | Tap intX, intY
53 | Delay 2000
54 | End If
55 | FindPic 0,0,0,0,"Attachment:返回上级.png","000000",0,0.9,intX,intY
56 | If intX > -1 And intY > -1 Then
57 | Tap intX, intY
58 | Delay 2000
59 | End If
60 | FindPic 0,0,0,0,"Attachment:返回上级.png","000000",0,0.9,intX,intY
61 | If intX > -1 And intY > -1 Then
62 | Tap intX, intY
63 | Delay 2000
64 | End If
65 | End If
66 | // 评论
67 | If i = 2 Then
68 | TracePrint "评论"
69 | FindPic 0,0,0,0,"Attachment:你的观点.png","000000",0,0.8,intX,intY
70 | If intX > -1 And intY > -1 Then
71 | Tap intX, intY
72 | Delay 2000
73 | End If
74 | FindPic 0,0,0,0,"Attachment:输入文字.png","000000",0,0.8,intX,intY
75 | If intX > -1 And intY > -1 Then
76 | Tap intX, intY
77 | Delay 2000
78 | InputText 评论语句(随机数())
79 | // 如果设置自定义的话,应该增加if
80 | Delay 2000
81 | InputText 评论语句(随机数())
82 | Delay 3000
83 | End If
84 | FindPic 0,0,0,0,"Attachment:发布.png","000000",0,0.8,intX,intY
85 | If intX > -1 And intY > -1 Then
86 | Tap intX, intY
87 | Delay 2000
88 | End If
89 | FindPic 0,0,0,0,"Attachment:删除.png","000000",0,0.8,intX,intY
90 | If intX > -1 And intY > -1 Then
91 | Tap intX, intY
92 | Delay 2000
93 | FindPic 0,0,0,0,"Attachment:删除确定.png","000000",0,0.8,intX,intY
94 | If intX > -1 And intY > -1 Then
95 | Tap intX, intY
96 | Delay 1500
97 | Tap 49, 95
98 | Delay 1500
99 | End If
100 | End If
101 | // 660,434 657,1041
102 | Do
103 | Swipe 364, 1161, 364, 735
104 | Delay 1500
105 | FindPic 0,0,0,0,"Attachment:学习强国学习平台.png","000000",0,0.8,intX,intY
106 | If intX > -1 And intY > -1 Then
107 | Tap intX + 500, intY
108 | Delay 1000
109 | Tap intX, intY
110 | Delay 3000
111 | Exit Do
112 | Else
113 | Swipe 364, 1161, 364, 735
114 | Delay 1500
115 | End If
116 | Loop
117 | Delay 2000
118 | End If
119 | // 分享
120 | If i = 3 Then
121 | TracePrint "分享"
122 | FindPic 0,0,0,0,"Attachment:分享.png","000000",0,0.9,intX,intY
123 | If intX > -1 And intY > -1 Then
124 | Tap intX, intY
125 | Delay 2000
126 | End If
127 | FindPic 0,0,0,0,"Attachment:分享到学习强国.png","000000",0,0.8,intX,intY
128 | If intX > -1 And intY > -1 Then
129 | Tap intX, intY
130 | Delay 2000
131 | End If
132 | FindPic 0,0,0,0,"Attachment:选择群聊.png","000000",0,0.8,intX,intY
133 | If intX > -1 And intY > -1 Then
134 | Tap intX, intY
135 | Delay 2000
136 | End If
137 | FindPic 0,0,0,0,"Attachment:返回上级.png","000000",0,0.9,intX,intY
138 | If intX > -1 And intY > -1 Then
139 | Tap intX, intY
140 | Delay 2000
141 | End If
142 | FindPic 0,0,0,0,"Attachment:返回上级.png","000000",0,0.9,intX,intY
143 | If intX > -1 And intY > -1 Then
144 | Tap intX, intY
145 | Delay 2000
146 | End If
147 | End If
148 | Swipe 316, 424, 316, 1156
149 | Delay 1500
150 | For 30
151 | Swipe 316, 424, 316, 356
152 | Delay 5000
153 | Next
154 | i = i + 1
155 | Tap 49, 95
156 | Delay 1500
157 | Swipe 302, 784, 302, 425, 1000
158 | Delay 1500
159 | Next
160 |
--------------------------------------------------------------------------------
/赞助.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datehoer/studygoodcountry/e55d77cf69601d353016b885d7c88ab8d74ef4d7/赞助.jpg
--------------------------------------------------------------------------------