前兩篇介紹的理論比較多,不會編程如何制作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": "根模塊"
}
總結
以上幾步可以看出制作輔助功能其實很簡單,最核心的有幾點:
- 熟練掌握自動構建各個模塊的用法和引數配置,
- 梳理清楚自己的業務邏輯,
掌握以上兩點,其他輔助業務也能很容易搞定😄
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/403995.html
標籤:其他
