From 32e3711c0c9fd23202fecd069803b78c494f3272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BA=BF=E6=AF=9B=E8=A1=A3?= Date: Mon, 22 Feb 2021 10:37:45 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E6=AC=A1=E6=95=B0=E4=B8=BA2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++++++ .idea/LazyStudy.iml | 8 +++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 +++++ collectCommentShare.js | 23 +++++++++++-------- 7 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/LazyStudy.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ebfd57f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../../:\Users\bw_ch\Documents\GitHub\LazyStudy\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/LazyStudy.iml b/.idea/LazyStudy.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/LazyStudy.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..696a4ff --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/collectCommentShare.js b/collectCommentShare.js index a07dc60..6238d4f 100644 --- a/collectCommentShare.js +++ b/collectCommentShare.js @@ -35,15 +35,20 @@ function main() // collectIcon.click();//点击收藏 // delay(2); //var shareIcon = className("com.uc.webview.export.WebView").findOnce().parent().child(8);//右下角分享按钮 - shareIcon.click();//点击分享 - while(!textContains("分享到学习强").exists());//等待弹出分享选项界面 - delay(2); - click("分享到学习强国"); - delay(1); - //toastLog("分享成功!"); - delay(1); - back();//返回文章界面 - delay(2); + sharecount = 0; + while(sharecount<2){ + sharecount++; + shareIcon.click();//点击分享 + while(!textContains("分享到学习强").exists());//等待弹出分享选项界面 + delay(2); + click("分享到学习强国"); + delay(1); + toastLog("第"+ sharecount.toString() + "分享成功!"); + delay(1); + back();//返回文章界面 + delay(2); + } + //评论 var num=random(0,commentText.length-1)//随机数 From 5d9a91fb930577984c6a44ab90f7999086cd11f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BA=BF=E6=AF=9B=E8=A1=A3?= Date: Mon, 22 Feb 2021 10:42:45 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dzsy=E8=BF=9B=E5=8E=BB?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=90=E8=A1=8C=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E7=AC=AC2=E6=AC=A1=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=BF=9B=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zsyAnswer.js | 234 +++++++++++++++------------------------------------ 1 file changed, 69 insertions(+), 165 deletions(-) diff --git a/zsyAnswer.js b/zsyAnswer.js index cc852cf..9976eac 100644 --- a/zsyAnswer.js +++ b/zsyAnswer.js @@ -1,8 +1,6 @@ importClass(android.database.sqlite.SQLiteDatabase); -var lCount = 1;//挑战答题轮数 -var qCount = 10;//挑战答题每轮答题数 -var zCount = 2;//争上游答题轮数 +var zCount =2;//争上游答题轮数 /** * @description: 延时函数 @@ -58,154 +56,9 @@ function getAnswer(question, table_name) { function indexFromChar(str) { return str.charCodeAt(0) - "A".charCodeAt(0); } -/** - * @description: 争上游答题 20200928增加 - * @param: null - * @return: null - */ -function zsyQuestion() { - /* - text("我的").click(); - if (!textContains("我要答题").exists()) { - delay(1); - click("我要答题"); - }else { - (!text("我要答题").exists()); - delay(1); - text("我要答题").click(); - } - while (!text("答题练习").exists());//可用词:排行榜 答题竞赛 - delay(1); - className("android.view.View").text("答题练习").findOne().parent().child(8).click(); - console.log("开始争上游答题") - delay(2); - */ - if (className("android.view.View").text("开始比赛").exists()) { - className("android.view.View").text("开始比赛").findOne().click(); - } - delay(10); - let zNum = 0;//轮数 - while (true) { - if (className("RadioButton").exists()) { - zsyQuestionLoop(); - } - if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists())//遇到继续挑战,则本局结束 - { - console.info("争上游答题本局结束!"); - zNum++; - //当天上限两次 - if (className("android.view.View").text("非积分奖励局").exists()) { - console.info("今天已完成争上游答题!"); - zNum++; - }// - if (zNum >= zCount) { - console.log("争上游答题结束"); - //回退4次返回主页 - delay(1); - back(); - break; - } else { - console.log("即将开始下一轮...") - delay(2);//等待2秒开始下一轮 - back(); - delay(1); - back(); - while (!text("答题练习").exists());//排行榜 答题竞赛 - delay(1); - className("android.view.View").text("答题练习").findOne().parent().child(8).click(); - console.log("开始争上游答题") - delay(2); - if (className("android.view.View").text("开始比赛").exists()) { - className("android.view.View").text("开始比赛").findOne().click(); - } - delay(10); - } - console.warn("第" + zNum.toString() + "轮开始...") - } - } -} - -/** - * @description: 双人对战答题 20200928增加 - * @param: null - * @return: null - */ -function SRQuestion() { - /* - text("我的").click(); - if (!textContains("我要答题").exists()) { - delay(1); - click("我要答题"); - } else { - (!text("我要答题").exists()); - delay(1); - text("我要答题").click(); - } - while (!text("答题练习").exists());//可用词:排行榜 答题竞赛 - delay(1); - className("android.view.View").text("答题练习").findOne().parent().child(9).click(); - console.log("开始双人对战") - delay(2); - if(className("android.view.View").text("邀请对手").exists()){ - className("android.view.View").text("邀请对手").findOne().parent().child(0).click(); - } - delay(1); - */ - if (className("android.view.View").text("邀请对手").exists()) { - className("android.view.View").text("邀请对手").findOne().parent().child(0).click(); - } - delay(2) - if (className("android.view.View").text("开始对战").exists()) { - className("android.view.View").text("开始对战").findOne().click(); - } - delay(10); - let zNum = 1;//轮数 - while (true) { - zsyQuestionLoop(); - if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists())//遇到继续挑战,则本局结束 - { - console.info("双人对战本局结束!"); - zNum++; - if (zNum >= zCount) { - console.log("双人对战结束!返回主页!"); - //回退4次返回主页 - back(); delay(1); - back(); delay(1); - if (text("退出").exists()) { - className("android.widget.Button").text("退出").findOne().click(); - delay(1); - } - break; - } else { - console.log("即将开始下一轮...") - back(); - delay(1); - back(); - delay(1); - if (textContains("退出").exists()) { - className("android.widget.Button").text("退出").findOne().click(); - delay(1); - } - while (!text("答题练习").exists());//排行榜 答题竞赛 - delay(1); - console.log("开始双人对战") - delay(2); - if (className("android.view.View").text("邀请对手").exists()) { - className("android.view.View").text("邀请对手").findOne().parent().child(0).click(); - } - delay(1); - if (className("android.view.View").text("开始对战").exists()) { - className("android.view.View").text("开始对战").findOne().click(); - } - delay(10); - } - console.warn("第" + zNum.toString() + "轮开始...") - } - } -} /** - * @description: 争上游答题 双人对战答题循环 + * @description: 争上游答题循环 * @param: null * @return: null */ @@ -331,26 +184,77 @@ function zsyQuestionLoop() { delay(1); } } -//争上游部分 + +/** + * @description: 争上游答题 20200928增加 + * @param: null + * @return: null + */ +function zsyQuestion() { + + if (className("android.view.View").text("开始比赛").exists()) { + className("android.view.View").text("开始比赛").findOne().click(); + } + delay(10); + let zNum = 0;//轮数 + while (true) { + if (className("RadioButton").exists()) { + zsyQuestionLoop(); + } + if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists())//遇到继续挑战,则本局结束 + { + console.info("争上游答题本局结束!"); + zNum++; + //当天上限两次 + if (className("android.view.View").text("非积分奖励局").exists()) { + console.info("今天已完成争上游答题!"); + zNum++; + }// + if (zNum >= zCount) { + console.log("争上游答题结束"); + //回退4次返回主页 + delay(1); + back(); + break; + } else { + console.log("即将开始下一轮...") + console.info("2秒后开始下一轮") + delay(2);//等待2秒开始下一轮 + back(); + text("开始比赛").click(); + delay(10); + } + console.warn("第" + zNum.toString() + "轮开始...") + } + } +} + + +// + +// function main() { +// console.setPosition(0, device.height / 2); +// console.show(); +// delay(1); +// if (className("android.view.View").text("开始比赛").exists() || className("android.view.View").text("区配成功").exists() || className("RadioButton").exists()) {//争上游答题开始页 +// console.log("开始争上游答题"); +// zsyQuestion(); +// } else { +// // toastLog("没有找到 “争上游答题”或“双人对战” 的开始页!请检查是否进入相关界面!"); +// console.error("没有找到 “争上游答题”或“双人对战” 开始页!请检查是否进入相关界面!"); +// console.log("停止"); +// console.hide(); +// } + +// } function main() { - console.setPosition(0, device.height / 2); + console.setPosition(0, device.height / 2);//部分华为手机console有bug请注释本行 console.show(); delay(1); - if (className("android.view.View").text("开始比赛").exists()) {//争上游答题开始页 - console.log("开始争上游答题"); - zsyQuestion(); - } else { - if (className("android.view.View").text("开始对战").exists()) {//双人对战开始页 - console.log("开始双人对战答题"); - SRQuestion(); - } else { - // toastLog("没有找到 “争上游答题”或“双人对战” 的开始页!请检查是否进入相关界面!"); - console.error("没有找到 “争上游答题”或“双人对战” 开始页!请检查是否进入相关界面!"); - console.log("停止"); - console.hide(); - } - } + console.log("开始争上游答题"); + zsyQuestion(); + console.hide() } //main() module.exports = main; \ No newline at end of file From ad0ebae6464551dc882bbdfb91962fa18cb70b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BA=BF=E6=AF=9B=E8=A1=A3?= Date: Mon, 22 Feb 2021 10:43:47 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=8E=BB?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=87=AA=E5=8A=A8=E8=BF=9B=E5=8E=BB=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=BF=9B=E5=85=A5=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=90?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doubleAnswer.js | 259 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 doubleAnswer.js diff --git a/doubleAnswer.js b/doubleAnswer.js new file mode 100644 index 0000000..2af551d --- /dev/null +++ b/doubleAnswer.js @@ -0,0 +1,259 @@ +importClass(android.database.sqlite.SQLiteDatabase); +var zCount = 1; //执行次数 //zNum:0 <= zCount + +/** + * @description: 延时函数 + * @param: seconds-延迟秒数 + * @return: null + */ +function delay(seconds) { + sleep(1000 * seconds);//sleep函数参数单位为毫秒所以乘1000 +} + +/** + * @description: 生成从minNum到maxNum的随机数 + * @param: minNum-较小的数 + * @param: maxNum-较大的数 + * @return: null + */ +function randomNum(minNum, maxNum) { + switch (arguments.length) { + case 1: + return parseInt(Math.random() * minNum + 1, 10); + case 2: + return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10); + default: + return 0; + } +} + +/** + * @description: 从数据库中搜索答案 + * @param: question 问题 + * @return: answer 答案 + */ +function getAnswer(question, table_name) { + var dbName = "tiku.db";//题库文件名 + var path = files.path(dbName); + var db = SQLiteDatabase.openOrCreateDatabase(path, null); + sql = "SELECT answer FROM " + table_name + " WHERE question LIKE '%" + question + "%'"// 关键词前后都加%,增加搜索准确率 + //log(sql) + var cursor = db.rawQuery(sql, null); + if (cursor.moveToFirst()) { + var answer = cursor.getString(0); + cursor.close(); + return answer; + } + else { + console.log("题库中未找到答案"); + cursor.close(); + return ''; + } +} + + +function indexFromChar(str) { + return str.charCodeAt(0) - "A".charCodeAt(0); +} + + +/** + * @description: 争上游答题 双人对战答题循环 + * @param: null + * @return: null + */ +var oldaquestion;//全局变量,定义旧题目,对比新题目用 + +function zsyQuestionLoop() { + //delay(1); + if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists() || !className("RadioButton").exists()) {//不存在本局结束标志 继续挑战,则执行 + console.info("答题结束!"); + return; + } else { + while (!className("RadioButton").exists());//@KB64ba建议使用while判断 + if (className("RadioButton").exists() || aquestion.length == 0) { + var aquestion = className("ListView").findOnce().parent().child(0).text(); + var question = aquestion.substring(4); //争上游和对战题目前带1.2.3.需去除 + //找题目,防出错 + while (aquestion == oldaquestion || question == "") { + delay(0.8); + if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists() || !className("RadioButton").exists()) { + console.info("答题结束!"); + return; + } + //找题目 + aquestion = className("ListView").findOnce().parent().child(0).text(); + question = aquestion.substring(3); + } + // + } else { + console.error("提取题目失败!"); + let listArray = className("ListView").findOnce().children();//题目选项列表 + let i = random(0, listArray.length - 1); + console.log("随机点击"); + listArray[i].child(0).click();//随意点击一个答案 + return; + } + var chutiIndex = question.lastIndexOf("出题单位");//@chongyadong添加 + if (chutiIndex != -1) { + question = question.substring(0, chutiIndex - 2); + } + question = question.replace(/\s/g, ""); + var options = [];//选项列表 + if (className("RadioButton").exists()) { + className("ListView").findOne().children().forEach(child => { + var answer_q = child.child(0).child(1).text(); + options.push(answer_q); + }); + } else { + console.error("答案获取失败!"); + return; + } + // + if (aquestion != oldaquestion) { + console.log(aquestion.substring(0, 2) + "题目:" + question); + reg = /.*择词语的正确.*/g // 正则判断是否为字形 + if (reg.test(question)) { + //log(options) + var optionStr = options; + for (i in optionStr) {//替换搜索用的数组 + optionStr[i] = options[i].substring(3); + } + var optionStr = options.join(""); + question = question + optionStr; + question = question.substr(1);//开头删除一个字 + question = question.substr(0, question.length - 1);//结尾删除一个字,增加搜索的准确率 + } else { + question = question.substr(1);//开头删除一个字 + question = question.substr(0, question.length - 1);//结尾删除一个字,增加搜索的准确率 + } + var answer = getAnswer(question, 'tiku'); + if (answer.length == 0) {//tiku表中没有则到tikuNet表中搜索答案 + answer = getAnswer(question, 'tikuNet'); + } + console.info("答案:" + answer); + if (/^[a-zA-Z]{1}$/.test(answer)) {//如果为ABCD形式 + var indexAnsTiku = indexFromChar(answer.toUpperCase()); + answer = options[indexAnsTiku]; + toastLog("answer from char=" + answer); + } + let hasClicked = false; + let listArray = className("ListView").findOnce().children();//题目选项列表 + /* if (answer == "")*/ //如果没找到答案 + if (answer.length == 0) { + let i = random(0, listArray.length - 1); + console.error("没有找到答案,随机点击"); + listArray[i].child(0).click();//随意点击一个答案 + hasClicked = true; + console.log("---------------------------"); + } + else//如果找到了答案 + { //该部分问题: 选项带A.B.C.D.,题库返回答案不带,char返回答案带 + var answer_a = answer.substring(0, 2);//定义answer_a,获取答案前两个字符对比A.B.C.D.应该不会出现E选项 + if (answer_a == "A." || answer_a == "B." || answer_a == "C." || answer_a == "D.") { + listArray.forEach(item => { + var listDescStrb = item.child(0).child(1).text(); + if (listDescStrb == answer) { + item.child(0).click();//点击答案 + hasClicked = true; + console.log("---------------------------"); + } + }); + } else { + listArray.forEach(item => { + var listDescStra = item.child(0).child(1).text(); + var listDescStrb = listDescStra.substring(3);//选项去除A.B.C.D.再与answer对比 + if (listDescStrb == answer) { + item.child(0).click();//点击答案 + hasClicked = true; + console.log("---------------------------"); + } + }); + } + } + if (!hasClicked)//如果没有点击成功 + { + console.error("未能成功点击,随机点击"); + let i = random(0, listArray.length - 1); + listArray[i].child(0).click();//随意点击一个答案 + console.log("---------------------------"); + } + } + //旧题目 + oldaquestion = aquestion; + delay(1); + } +} + + +/** + * @description: 双人对战答题 2021.02.21修改 + * @param: null + * @return: null + */ +function SRQuestion() { + + if (className("android.view.View").text("随机匹配").exists()) { + className("android.view.View").text("随机匹配").findOne().parent().child(0).click(); + } + delay(2) + if (className("android.view.View").text("开始对战").exists()) { + className("android.view.View").text("开始对战").findOne().click(); + } + delay(10); + let zNum = 0;//轮数 + while (true) { + zsyQuestionLoop(); + if (className("android.view.View").text("继续挑战").exists() || textContains("继续挑战").exists())//遇到继续挑战,则本局结束 + { + console.info("双人对战本局结束!"); + zNum++; + if (zNum >= zCount) { + console.log("双人对战结束!返回主页!"); + //回退4次返回主页 + back(); delay(1); + back(); delay(1); + if (text("退出").exists()) { + className("android.widget.Button").text("退出").findOne().click(); + delay(1); + } + break; + } else { + console.log("即将开始下一轮...") + back(); + delay(1); + back(); + delay(1); + if (textContains("退出").exists()) { + className("android.widget.Button").text("退出").findOne().click(); + delay(1); + } + while (!text("答题练习").exists());//排行榜 答题竞赛 + delay(1); + console.log("开始双人对战") + delay(2); + if (className("android.view.View").text("随机匹配").exists()) { + className("android.view.View").text("随机匹配").findOne().parent().child(0).click(); + } + delay(1); + if (className("android.view.View").text("开始对战").exists()) { + className("android.view.View").text("开始对战").findOne().click(); + } + delay(10); + } + console.warn("第" + zNum.toString() + "轮开始...") + } + } +} + + +function main() { + console.setPosition(0, device.height / 2);//部分华为手机console有bug请注释本行 + console.show(); + delay(1); + console.log("开始双人对战"); + SRQuestion(); + console.hide() +} + +module.exports = main; \ No newline at end of file From 537fc287b9063176da265f4c8db4a9568feabf01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BA=BF=E6=AF=9B=E8=A1=A3?= Date: Mon, 22 Feb 2021 10:44:28 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=94=B6=E8=97=8F?= =?UTF-8?q?=E3=80=81=E5=88=86=E5=BC=80=E5=8F=8C=E4=BA=BA=E5=AF=B9=E6=88=98?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E4=BA=89=E4=B8=8A=E6=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- floating.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/floating.js b/floating.js index 643f2c2..f398ebd 100644 --- a/floating.js +++ b/floating.js @@ -6,10 +6,11 @@ let window = floaty.window(