前两篇介绍的理论比较多,不会编程如何制作Android辅助功能之二(剖析模块配置),有点枯燥。本篇主要是实战,以“简书”为例(仅用于学习研究,严禁用于任何商业用途),介绍具体如何使用“自动构建”来实现辅助功能。
准备工作
- 安装「冰狐智能辅助」,这里就不再赘述了,不了解的可以参考这里。
- 安装简书app,v6.4.3,点击这里去豌豆荚下载,注意必须安装这个版本的简书,否则ui界面可能不同。
- 注册简书账号,然后选择多个自己感兴趣的内容标签(必须选择多个),若没有,可以点击推荐,然后再点击最右边的菜单键,选择多个分类。
- 进入「移动端」/「自动构建」,新建名为“简书阅读”的构建。
业务逻辑梳理
核心业务逻辑其实很简单,一句话就可以描述清楚:
- 打开并进入简书app。
- 点击进入推荐页面。
- 选择一个感兴趣分类标签。
- 然后滚动页面选择多个自己感兴趣的文章。
- 点击进去阅读一段时间再返回到首页,
- 继续滚动页面阅读下一篇感兴趣的文章。。。。
- 退出app。
模块选择和参数配置
根据上述业务逻辑来选择合适的模块,并配置参数。
- 打开并进入简书app。选择“进入APP(enter app)”模块,主要参数packName:com.jianshu.haruki,findTag填“首页”,出现“首页”表示已经进入app。
- 点击进入推荐页面。选择“点击进入页面(clickAndEnter)”模块,主要参数,clickTag:首页,checkTag:推荐。
- 选择一个感兴趣分类标签。使用“遍历容器(traverse)”模块,tag:最新,注意descendant:[-1,-1]表示容器为tag的parent.parent。
- 然后滚动页面选择多个自己感兴趣的文章。选择多个,可以用“循环处理(loop)”模块,count参数选择[1,4]间的随机值,表示阅读随机篇文章。随机选择文章使用“遍历容器(traverse)”模块,tag为com.jianshu.haruki:id/recyclerView。
- 点击进去阅读,选择“点击进入页面(clickAndEnter)”模块,主要参数:checkTag:说点什么吧,出现“说点什么吧”表示进入了文章。
- 阅读一段时间文章,可以选择“循环处理(loop)”模块,配置时间[0.5,1.2],随机阅读0.5和1.2间分钟。在阅读中还需要滚动和判断是否阅读完成,分别使用“滚动处理(scroll)”和“跳出循环(break)”模块。
自动构建源码
将如下自动构建的json数据源码粘贴到自己的“配置源码”中,即可实现“简书自动阅读”功能。
{
"type": "root",
"children": [{
"type": "declareVar",
"var": [{
"name": "ret",
"type": "normal",
"initType": "null",
"initValue": "null"
}, {
"name": "view",
"type": "normal",
"initType": "null",
"initValue": "null"
}, {
"name": "viewContainer",
"type": "normal",
"initType": "null",
"initValue": "null"
}, {
"name": "item",
"type": "normal",
"initType": "null",
"initValue": "null"
}]
}, {
"type": "enterApp",
"desc": "进入APP",
"packageName": "com.jianshu.haruki",
"findTag": "txt:首页-",
"autoInstall": false,
"autoUpdate": false,
"wait": "1000",
"failed": "exitPopup",
"maxStep": "30",
"children": [{
"type": "clickAndEnter",
"desc": "点击进入推荐页面",
"class": 1,
"clickTag": "txt:首页-",
"checkTag": "txt:推荐-",
"root": "",
"mode": "2",
"failed": "exitPopup",
"descendant": [],
"duration": "500",
"maxStep": "8",
"beforeWait": "0",
"afterWait": "0",
"children": [{
"type": "traverse",
"desc": "遍历“推荐”并随机选择一个标签",
"class": 1,
"tag": "txt:最新-",
"failed": "exitPopup",
"descendant": [-1, -1],
"startIndex": "2",
"lastIndex": "2",
"retryCount": "0",
"randomPick": true,
"children": [{
"type": "click",
"desc": "点击选中的标签",
"class": "2",
"mode": "2",
"descendant": [],
"beforeWait": "0",
"afterWait": "3000",
"target": "item"
}, {
"type": "loop",
"desc": "阅读标签下的多篇文章",
"class": "2",
"minCount": "1",
"maxCount": "4",
"children": [{
"type": "scroll",
"desc": "随机滚动页面",
"class": 1,
"direction": "up",
"minDistance": "0.8",
"maxDistance": "0.98",
"minDuration": "500",
"maxDuration": "500",
"beforeWait": "2000",
"afterWait": "3000",
"minScrollCount": "1",
"maxScrollCount": "3"
}, {
"type": "traverse",
"desc": "从该页面中随机挑选一篇文章",
"class": 1,
"tag": "id:com.jianshu.haruki:id/recyclerView-",
"failed": "exitPopup",
"descendant": [],
"startIndex": "0",
"lastIndex": "0",
"retryCount": "0",
"randomPick": true,
"clickable": true,
"children": [{
"type": "clickAndEnter",
"desc": "点击进入并阅读文章",
"class": "2",
"checkTag": "txt:说点什么吧-",
"mode": "2",
"failed": "",
"descendant": [],
"duration": "500",
"maxStep": "5",
"beforeWait": "0",
"afterWait": "0",
"target": "item",
"children": [{
"type": "loop",
"desc": "随机阅读一段时间",
"class": 1,
"minRunTime": "0.5",
"maxRunTime": "1.2",
"children": [{
"type": "scroll",
"desc": "随机滚动文章阅读",
"class": 1,
"direction": "up",
"minDistance": "0.05",
"maxDistance": "0.5",
"minDuration": "450",
"maxDuration": "600",
"beforeWait": "0",
"afterWait": "1000",
"minScrollCount": "1",
"maxScrollCount": "1"
}, {
"type": "break",
"desc": "若阅读完成则跳出循环",
"class": "2",
"breakTag": "txt:赞赏支持|txt:赞-",
"failed": "exitPopup"
}]
}, {
"type": "back2Page",
"desc": "返回首页",
"tag": "txt:推荐-",
"root": "",
"backFirst": "true",
"failed": "",
"duration": "500",
"maxStep": "5",
"beforeWait": "0",
"afterWait": "0",
"false": {}
}],
"false": {
"type": "back2Page",
"desc": "返回页面",
"tag": "txt:推荐-",
"root": "",
"backFirst": "false",
"failed": "",
"duration": "500",
"maxStep": "5",
"beforeWait": "0",
"afterWait": "0"
}
}, {
"type": "break",
"desc": "跳出循环",
"class": 1
}]
}]
}, {
"type": "break",
"desc": "跳出循环",
"class": 1
}],
"clickable": false
}],
"false": {
"type": "log",
"desc": "日志",
"logType": "warning",
"info": ["string-进入推荐失败"]
}
}],
"false": {
"type": "log",
"desc": "日志",
"logType": "error",
"info": ["string-进入app失败"]
}
}, {
"type": "popup",
"name": "exitPopupWithAD",
"false": ["exitPopup", "dealAD"]
}, {
"type": "popup",
"name": "exitPopup",
"desc": "弹窗处理",
"false": [],
"dealItems": [{
"key": "txt^:开启系统通知|txt:新版本安装包已经准备好-",
"value": {
"type": "click",
"desc": "点击控件",
"class": 1,
"tag": "txt:取消-",
"mode": "2",
"root": "",
"failed": "",
"maxStep": "5",
"descendant": [],
"duration": "500",
"beforeWait": "0",
"afterWait": "1000"
}
}, {
"key": "txt:立即阅读-",
"value": {
"type": "traverse",
"desc": "遍历容器",
"class": "2",
"descendant": [-1],
"startIndex": "0",
"lastIndex": "0",
"randomPick": false,
"clickable": true,
"target": "view",
"children": [{
"type": "click",
"desc": "点击控件",
"class": "2",
"mode": "2",
"descendant": [],
"beforeWait": "0",
"afterWait": "1000",
"target": "item"
}, {
"type": "break",
"desc": "跳出循环"
}]
}
}, {
"key": "txt:你还没有关注文章作者,是否同时关注TA-",
"value": {
"type": "prob",
"desc": "概率",
"prob": "80",
"children": [{
"type": "click",
"desc": "点击控件",
"class": 1,
"tag": "txt:关注作者-",
"mode": "2",
"root": "",
"failed": "",
"maxStep": "5",
"descendant": [],
"duration": "500",
"beforeWait": "0",
"afterWait": "1000"
}],
"false": {
"type": "click",
"desc": "点击控件",
"class": 1,
"tag": "txt:取消-",
"mode": "2",
"root": "",
"failed": "",
"maxStep": "5",
"descendant": [],
"duration": "500",
"beforeWait": "0",
"afterWait": "1000"
}
}
}, {
"key": "txt:以后再说|txt:不用打开|txt:我知道了|txt:知道了|id:com.jianshu.haruki:id/dialog_lucky_prize_close|txt:放弃下载|txt:看视频奖励翻倍-",
"value": {
"type": "click",
"desc": "点击控件",
"class": "2",
"mode": "1",
"descendant": [],
"beforeWait": "0",
"afterWait": "1000",
"target": "view"
}
}]
}, {
"type": "ad",
"desc": "广告处理",
"enterWindowList": ["com.qq.e.ads.RewardvideoPortraitADActivity"],
"enterTags": "",
"breakTags": "txt:恭喜获得奖励-"
}, {
"type": "windowChange"
}, {
"type": "notification",
"children": []
}],
"desc": "根模块"
}
总结
以上几步可以看出制作辅助功能其实很简单,最核心的有几点:
- 熟练掌握自动构建各个模块的用法和参数配置。
- 梳理清楚自己的业务逻辑。
掌握以上两点,其他辅助业务也能很容易搞定😄