├── README.md ├── bp.png ├── qg.png ├── wx.png ├── zrw_jdrw.js ├── zrw_tmhc.js └── zrw_tmrw.js /README.md: -------------------------------------------------------------------------------- 1 | - 你的 `Star` 是长期更新的动力 2 | 3 | # 618任务自动助手 4 | 自动完成天猫和京东618任务,领取奖励! 5 | 怕麻烦的,直接下载打包版:https://wwhu.lanzouf.com/b01cfbrbi 6 | 想使用源码的,手机安装AutoJS Pro,然后在AutoJS Pro上运行zrw_tmhc.js和zrw_jdrw.js文件 7 | 8 | # 🧧实时线报 9 | 🧧实时线报聚合:[点击链接](https://wndh.net/h/) 10 | |更新时间|活动线报|参与方式| 11 | | :------------: | :------------: | :------------: | 12 | |5月26日|话费充值 `91折`|[点击链接](https://u.jd.com/kIQBS0B)| 13 | |5月1日|高德打车 `100元打车券`|[点击链接](https://cache.amap.com/activity/2020TaxiGetNew/index.html?gd_from=4k1Su5Z6RjQ&pid=mm_1391100045_2275350156_111487350042)| 14 | 15 | ### 线报群 16 | 实时线报QQ群:[点击加入](https://jq.qq.com/?_wv=1027&k=wXNzwxRL "点击加入") 17 | 微信群,扫码添加微信邀请加入,备注:线报 18 | ![](https://github.com/omxmo/xb/blob/main/wx.png) 19 | 20 | ### 线报聚合APP 21 | 活动太多,为了方便大家随时随地获取最新新报,做成了一个聚合APP,点击下载:[点击链接](https://sj.qq.com/appdetail/com.miaohui.xin) 22 | |主流电商|外卖点餐|出行|充值| 23 | | :------------: | :------------: | :------------: | :------------: | 24 | |淘宝 `领券返现`|饿了么/美团外卖 `66元红包`|高德打车 `100元打车券`|话费 `93元充100元`| 25 | |天猫 `领券返现`|肯德基 `低至5折`|花小猪 `100元券包`|电费 `低至91折`| 26 | |京东 `领券返现`|麦当劳 `低至5折`|滴滴打车 `100元券包`|| 27 | |拼多多 `领券返现`|华莱士 `低至5折`|滴滴代驾 `立减13元`|| 28 | |唯品会 `领券返现`|汉堡王 `低至5折`|滴滴货运 `低至3折`|| 29 | |苏宁易购 `领券返现`|必胜客 `低至7折`|滴滴加油 `40元礼包`|| 30 | |考拉海购 `领券返现`|星巴克 `低至8折`|滴滴租车 `1000元礼包`|| 31 | |抖音电商 `下单返现`|瑞幸咖啡 `低至4.9折`||| 32 | |快手电商 `下单返现`|喜茶 `低至9.5折`||| 33 | |美团电商 `下单返现`|奈雪的茶 `低至9折`|||| 34 | 35 | # 📱抢购助手 36 | 抢购助手是一款基于安卓系统的辅助脚本工具,模拟人工在手机屏幕上点击,实现自动化操作。方便、快捷、安全、无毒。支持淘宝/天猫、京东、拼多多等多个平台和聚划算、百亿补贴等多种活动,提供页面、购物车、BP链接和捡漏等抢购模式! 37 | 38 | |淘宝|京东|拼多多|其他|大促活动| 39 | | :------------: | :------------: | :------------: | :------------: | :------------: | 40 | |淘特 `抢购模式`|收藏模式|收藏模式|淘金币助手|618任务助手| 41 | |BP模式|页面模式||苏宁易购 `页面模式+购物车模式`|双11任务助手| 42 | |收藏模式|购物车模式||抖音 `橱窗+直播+刷屏`|双12任务助手| 43 | |页面模式|捡漏模式||小米商城|年货节任务助手| 44 | |购物车模式|刷屏||华为商城|| 45 | |点击模式|||考拉海购|| 46 | |百亿补贴模式|||酒仙网|| 47 | |直播|||多点|| 48 | |刷屏|||华润|| 49 | 50 | ### 软件界面 51 | ![](https://github.com/omxmo/xb/blob/main/qg.png) 52 | ![](https://github.com/omxmo/xb/blob/main/bp.png) 53 | 54 | # ❗提示 55 | 仅用于对视觉障碍人士辅助操作的测试和学习交流,严禁用于任何违法违规商业行为!!! 56 | -------------------------------------------------------------------------------- /bp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/omxmo/xb/ecbe294f4a340fd462622a838e6b070ea6e4149e/bp.png -------------------------------------------------------------------------------- /qg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/omxmo/xb/ecbe294f4a340fd462622a838e6b070ea6e4149e/qg.png -------------------------------------------------------------------------------- /wx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/omxmo/xb/ecbe294f4a340fd462622a838e6b070ea6e4149e/wx.png -------------------------------------------------------------------------------- /zrw_jdrw.js: -------------------------------------------------------------------------------- 1 | if (!auto.service) { 2 | toast('无障碍服务未启动!退出!') 3 | exit() 4 | } 5 | 6 | console.show() 7 | 8 | function getSetting() { 9 | let indices = [] 10 | autoOpen && indices.push(0) 11 | autoMute && indices.push(1) 12 | autoJoin && indices.push(2) 13 | indices.push(3) 14 | 15 | let settings = dialogs.multiChoice('任务设置', ['自动打开京东进入活动。多开或任务列表无法自动打开时取消勾选', '自动调整媒体音量为0。以免直播任务发出声音,首次选择需要修改系统设置权限', '自动完成入会任务。京东将授权手机号给商家,日后可能会收到推广短信', '此选项用于保证选择的处理,勿动!'], indices) 16 | 17 | if (settings.length == 0) { 18 | toast('取消选择,任务停止') 19 | exit() 20 | } 21 | 22 | if (settings.indexOf(0) != -1) { 23 | storage.put('autoOpen', true) 24 | autoOpen = true 25 | } else { 26 | storage.put('autoOpen', false) 27 | autoOpen = false 28 | } 29 | if (settings.indexOf(1) != -1) { 30 | storage.put('autoMute', true) 31 | autoMute = true 32 | } else { 33 | storage.put('autoMute', false) 34 | autoMute = false 35 | } 36 | if (settings.indexOf(2) != -1) { 37 | storage.put('autoJoin', true) 38 | autoJoin = true 39 | } else { 40 | storage.put('autoJoin', false) 41 | autoJoin = false 42 | } 43 | } 44 | 45 | let storage = storages.create("jd_task"); 46 | let autoOpen = storage.get('autoOpen', true) 47 | let autoMute = storage.get('autoMute', true) 48 | let autoJoin = storage.get('autoJoin', true) 49 | getSetting() 50 | 51 | if (autoMute) { 52 | try { 53 | device.setMusicVolume(0) 54 | toast('成功设置媒体音量为0') 55 | } catch (err) { 56 | alert('首先需要开启修复音量权限,请开启后再次运行脚本') 57 | exit() 58 | } 59 | } 60 | 61 | console.log('开始完成京东任务...') 62 | console.log('按音量下键停止') 63 | 64 | device.keepScreenDim(30 * 60 * 1000) // 防止息屏30分钟 65 | 66 | // 自定义取消亮屏的退出方法 67 | function quit() { 68 | device.cancelKeepingAwake() 69 | exit() 70 | } 71 | 72 | // 监听音量下键 73 | function registerKey() { 74 | try { 75 | events.observeKey() 76 | } catch (err) { 77 | console.log('监听音量键停止失败,应该是无障碍权限出错,请关闭软件后台任务重新运行。') 78 | console.log('如果还是不行可以重启手机尝试。') 79 | quit() 80 | } 81 | events.onKeyDown('volume_down', function (event) { 82 | console.log('京东任务脚本停止了') 83 | console.log('请手动切换回主页面') 84 | startCoin && console.log('本次任务开始时有' + startCoin + '快递箱') 85 | quit() 86 | }) 87 | } 88 | threads.start(registerKey) 89 | 90 | // 自定义一个findTextDescMatchesTimeout 91 | function findTextDescMatchesTimeout(reg, timeout) { 92 | let c = 0 93 | while (c < timeout / 50) { 94 | let result = textMatches(reg).findOnce() || descMatches(reg).findOnce() 95 | if (result) return result 96 | sleep(50) 97 | c++ 98 | } 99 | return null 100 | } 101 | 102 | // 打开京东进入活动 103 | function openAndInto() { 104 | console.log('正在打开京东App...') 105 | if (!launch('com.jingdong.app.mall')) { 106 | console.log('可能未安装京东App') 107 | } else { 108 | console.log('等待京东打开') 109 | for (let i = 0; i < 20; i++) { 110 | if (currentPackage() == 'com.jingdong.app.mall') break 111 | sleep(400) 112 | } 113 | if (currentPackage() != 'com.jingdong.app.mall') { 114 | console.log('程序检测京东app打开失败,请注意') 115 | } 116 | } 117 | 118 | sleep(2000) 119 | console.log('进入活动页面') 120 | 121 | app.startActivity({ 122 | action: "VIEW", 123 | data: 'openApp.jdMobile://virtual?params={"category":"jump","action":"to","des":"m","sourceValue":"JSHOP_SOURCE_VALUE","sourceType":"JSHOP_SOURCE_TYPE","url":"https://u.jd.com/OqSxYpx","M_sourceFrom":"mxz","msf_type":"auto"}' 124 | }) 125 | } 126 | 127 | // 获取快递箱数量 128 | function getCoin() { 129 | let anchor = text('累计已拆').findOne(5000) 130 | if (!anchor) { 131 | console.log('找不到累计控件') 132 | return false 133 | } 134 | let coin = anchor.parent().child(1).text() 135 | if (coin) { 136 | return parseInt(coin) 137 | } else { 138 | return false 139 | } 140 | } 141 | 142 | // 打开任务列表 143 | function openTaskList() { 144 | console.log('打开任务列表') 145 | let taskListButton = text('拆快递').findOne(20000) 146 | 147 | if (!taskListButton) { 148 | console.log('无法找到任务列表控件,请参照软件内的说明更换web内核。') 149 | quit() 150 | } 151 | taskListButton.click() 152 | console.log('等待任务列表') 153 | if (!findTextDescMatchesTimeout(/.*每做一次任务.*/, 5000)) { 154 | console.log('似乎没能打开任务列表,重试') 155 | taskListButton.click() 156 | } 157 | 158 | if (!findTextDescMatchesTimeout(/.*每做一次任务.*/, 10000)) { 159 | console.log('似乎没能打开任务列表,退出!') 160 | console.log('如果已经打开而未检测到,请参照软件内的说明更换web内核。') 161 | quit() 162 | } 163 | } 164 | 165 | // 关闭任务列表 166 | function closeTaskList() { 167 | console.log('关闭任务列表') 168 | let anchor = findTextDescMatchesTimeout(/.*每做一次任务.*/, 5000) 169 | if (!anchor) { 170 | console.log('无法找到任务奖励标识') 171 | return false 172 | } 173 | 174 | anchor = anchor.parent() 175 | 176 | let closeBtn = anchor.child(anchor.childCount() - 2) // tbs 177 | if (!closeBtn.clickable()) { 178 | closeBtn = anchor.child(anchor.childCount() - 1) // webview 179 | } 180 | 181 | return closeBtn.click() 182 | } 183 | 184 | // 重新打开任务列表 185 | function reopenTaskList() { 186 | sleep(3000) 187 | closeTaskList() 188 | sleep(3000) 189 | openTaskList() 190 | sleep(5000) 191 | } 192 | 193 | // 获取未完成任务,根据数字标识,返回任务按钮、任务介绍、任务数量(数组) 194 | function getTaskByText() { 195 | let tButton = null, 196 | tText = null, 197 | tCount = 0, 198 | tTitle = null 199 | console.log('寻找未完成任务...') 200 | let anchor = textMatches(/^(去完成|去打卡)$/).findOnce() 201 | if (anchor) { // 如果找不到任务,直接返回 202 | let tasks = anchor.parent().parent().parent().children() 203 | tasks.pop() 204 | 205 | for (let i = 0; i < tasks.length - 2; i += 5) { 206 | let task = tasks.slice(i, i + 5) 207 | try { 208 | tTitle = task[1].text() 209 | 210 | let r = task[2].text().match(/(\d*)\/(\d*)/) 211 | if (!r) continue 212 | tCount = (r[2] - r[1]) 213 | 214 | console.log(tTitle, tCount) 215 | 216 | button = task[4] 217 | if (!button.child(0).child(0).text().match(/去完成|去领取|去打卡/)) continue 218 | // log(tasks) 219 | 220 | if (tCount) { // 如果数字相减不为0,证明没完成 221 | tText = task[3].text() 222 | if (!autoJoin && tText.match(/成功入会/)) continue 223 | if (tTitle.match(/下单|小程序|裂变|白条|小游戏/) || tText.match(/绑卡/)) continue 224 | tButton = button 225 | break 226 | } 227 | } catch (err) { 228 | console.log(err) 229 | } 230 | } 231 | } else { 232 | console.log('任务提示未找到') 233 | } 234 | return [tButton, tText, tCount, tTitle] 235 | } 236 | 237 | // 返回任务列表并检查是否成功,不成功重试一次,带有延时 238 | function backToList() { 239 | sleep(500) 240 | back() 241 | for (let i = 0; i < 5; i++) { // 尝试返回3次 242 | if (!findTextDescMatchesTimeout(/.*每做一次任务.*/, 5000)) { 243 | console.log('返回失败,重试返回') 244 | sleep(2000) 245 | back() 246 | continue 247 | } else { 248 | break 249 | } 250 | } 251 | sleep(3000) 252 | } 253 | 254 | // 浏览n秒的任务 255 | function timeTask() { 256 | console.log('等待浏览任务完成...') 257 | let c = 0 258 | while (c < 40) { // 0.5 * 40 = 20 秒,防止死循环 259 | if ((textMatches(/获得.*?快递箱/).exists() || descMatches(/获得.*?快递箱/).exists())) // 等待已完成出现 260 | break 261 | if ((textMatches(/已.*?浏.*?览/).exists() || descMatches(/已.*?浏.*?览/).exists())) { // 失败 262 | console.log('上限,返回刷新任务列表') 263 | return false 264 | } 265 | if ((textMatches(/出.*?错.*?了/).exists() || descMatches(/出.*?错.*?了/).exists())) { 266 | console.log('任务出错,返回刷新任务列表') 267 | return false 268 | } 269 | if (textMatches(/.*滑动浏览.*[^可]得.*/).exists()) { 270 | console.log('进行模拟滑动') 271 | swipe_flag = 1 272 | swipe(device.width / 2, device.height - 200, device.width / 2 + 20, device.height - 500, 500) 273 | c++ 274 | } 275 | 276 | // 弹窗处理 277 | let pop = text('升级开卡会员领好礼') 278 | if (pop.exists()) { 279 | pop.findOnce().parent().parent().child(2).click() 280 | console.log('关闭会员弹窗') 281 | } 282 | 283 | sleep(500) 284 | c++ 285 | } 286 | if (c > 39) { 287 | console.log('未检测到任务完成标识。') 288 | return false 289 | } 290 | console.log('已完成,准备返回') 291 | return true 292 | } 293 | 294 | // 入会任务 295 | function joinTask() { 296 | let check = textMatches(/.*确认授权即同意.*|.*我的特权.*|.*立即开卡.*|.*解锁全部会员福利.*/).findOne(8000) 297 | if (!check) { 298 | console.log('无法找到入会按钮,判定为已经入会') 299 | return true 300 | } else if (check.text().match(/我的特权/)) { 301 | console.log('已经入会,返回') 302 | return true 303 | } else { 304 | sleep(2000) 305 | if (check.text().match(/.*立即开卡.*|.*解锁全部会员福利.*|授权解锁/)) { 306 | if (check.text() == '授权信息,解锁全部会员福利') { 307 | check = text('去升级').findOnce() 308 | if (!check) { 309 | console.log('此类型无法找到升级按钮,入会失败') 310 | return false 311 | } 312 | } 313 | 314 | let btn = check.bounds() 315 | console.log('即将点击开卡/解锁福利/升级,自动隐藏控制台') 316 | sleep(500) 317 | console.hide() 318 | sleep(500) 319 | click(btn.centerX(), btn.centerY()) 320 | sleep(500) 321 | console.show() 322 | sleep(5000) 323 | check = textMatches(/.*确认授权即同意.*/).boundsInside(0, 0, device.width, device.height).findOne(8000) 324 | } 325 | 326 | if (!check) { 327 | console.log('无法找到入会按钮弹窗,加载失败') 328 | return false 329 | } 330 | 331 | 332 | if (check.indexInParent() == 2) { 333 | check = check.parent().child(1) 334 | } else { 335 | let anchor = textContains('*****').findOnce() 336 | check = anchor.parent().child(anchor.indexInParent() + 2) 337 | if (!check.bounds().top >= anchor.bounds().bottom) { 338 | console.log('使用第二种方法获取控件') 339 | let check1 = anchor.parent().children().findOne(filter(function (w) { 340 | if (w.className().match(/ImageView/) && w.bounds().top >= anchor.bounds().bottom) { 341 | return true 342 | } else { 343 | return false 344 | } 345 | })) 346 | if (!check1) { 347 | console.log('第二种方法也无法确认授权勾选框,失败。返回。') 348 | return false 349 | } else { 350 | check = check1 351 | console.log('成功,继续') 352 | } 353 | } 354 | } 355 | 356 | console.log("最终[确认授权]前面选项框坐标为:", check.bounds()); 357 | let x = check.bounds().centerX() 358 | let y = check.bounds().centerY() 359 | 360 | console.log('检测是否有遮挡') 361 | let float = className('android.widget.ImageView') 362 | .filter(function (w) { 363 | let b = w.bounds() 364 | return b.left <= x && b.right >= x && b.top <= y && b.bottom >= y && b.centerX() != x && b.centerY() != y 365 | }).findOnce() 366 | 367 | if (float) { 368 | console.log('有浮窗遮挡,尝试移除') 369 | if (device.sdkInt >= 24) { 370 | gesture(1000, [float.bounds().centerX(), float.bounds().centerY()], [float.bounds().centerX(), y + float.bounds().height()]) 371 | console.log('已经进行移开操作,如果失败请反馈') 372 | } else { 373 | console.log('安卓版本低,无法自动移开浮窗,入会任务失败。至少需要安卓7.0。') 374 | return false 375 | } 376 | } else { 377 | console.log('未发现遮挡的浮窗,继续勾选') 378 | } 379 | 380 | console.log('即将勾选授权,自动隐藏控制台') 381 | sleep(500) 382 | console.hide() 383 | sleep(1000) 384 | click(x, y) 385 | sleep(500) 386 | console.show() 387 | 388 | console.log('准备点击入会按钮') 389 | let j = textMatches(/^确认授权(并加入店铺会员)*$|.*立即开通.*/).findOne(5000) 390 | if (!j) { 391 | console.log('无法找到入会按钮,失败') 392 | return false 393 | } 394 | click(j.bounds().centerX(), j.bounds().centerY()) 395 | sleep(1000) 396 | console.log('入会完成,返回') 397 | return true 398 | } 399 | } 400 | 401 | // 浏览商品和加购的任务,cart参数为是否加购的flag 402 | function itemTask(cart) { 403 | console.log('等待进入商品列表...') 404 | let anchor = textContains('当前页').findOne(20000) 405 | if (!anchor) { 406 | console.log('未能进入商品列表。') 407 | return false 408 | } 409 | sleep(2000) 410 | 411 | if (anchor.parent().childCount()==4) { 412 | console.log('任务重复完成,返回') 413 | return false 414 | } 415 | 416 | let items = textContains('.jpg!q70').find() 417 | for (let i = 0; i < items.length; i++) { 418 | console.log('浏览') 419 | let tmp = items[i].parent().parent() 420 | tmp.child(tmp.childCount() - 1).click() 421 | 422 | sleep(5000) 423 | console.log('返回') 424 | back() 425 | sleep(5000) 426 | let r = textContains('当前页').findOnce() 427 | if (!r) { 428 | back() 429 | sleep(5000) 430 | } 431 | if (i >= 4 - 1) { 432 | break 433 | } 434 | } 435 | return true 436 | } 437 | 438 | // 逛店任务 TODO: 618版本 439 | function shopTask() { 440 | console.log('等待进入店铺列表...') 441 | let banner = textContains('喜欢').findOne(10000) 442 | if (!banner) { 443 | console.log('未能进入店铺列表。返回。') 444 | return false 445 | } 446 | let c = banner.text().match(/(\d)\/(\d*)/) 447 | if (!c) { 448 | c = 4 // 进行4次 449 | } else { 450 | c = c[2] - c[1] 451 | } 452 | sleep(2000) 453 | console.log('进行', c, '次') 454 | let like = text('喜欢').boundsInside(1, 0, device.width, device.height).findOnce() 455 | if (!like) { 456 | console.log('未能找到喜欢按钮。返回。') 457 | return false 458 | } 459 | let bound = [like.bounds().centerX(), like.bounds().centerY()] 460 | console.log('喜欢按钮位于', bound) 461 | for (let i = 0; i < c; i++) { 462 | click(bound[0], bound[1]) 463 | console.log('浏览店铺页') 464 | sleep(8000) 465 | console.log('返回') 466 | back() 467 | sleep(5000) 468 | let r = textContains('喜欢').findOnce() 469 | if (!r) { 470 | back() 471 | sleep(5000) 472 | } 473 | } 474 | return true 475 | } 476 | 477 | // 参观任务 478 | function viewTask() { 479 | console.log('进行参观任务') 480 | sleep(5000) 481 | console.log('参观任务直接返回') 482 | return true 483 | } 484 | 485 | // 品牌墙任务 TODO: 618版本 486 | function wallTask() { 487 | console.log('进行品牌墙任务') 488 | sleep(3000) 489 | for (let i of [2, 3, 4, 5, 6]) { // 选5个 490 | console.log('打开一个') 491 | textContains('!q70').boundsInside(100, 100, device.width, device.height).findOnce(i).click() 492 | sleep(5000) 493 | console.log('直接返回') 494 | back() 495 | let r = textContains('!q70').findOne(8000) 496 | if (!r) back() 497 | sleep(3000) 498 | } 499 | // console.log('返回顶部') 500 | // let root = textContains('到底了').findOnce().parent().parent() 501 | // root.child(root.childCount() - 2).click() 502 | console.log('品牌墙完成后重新打开任务列表') 503 | sleep(3000) 504 | openTaskList() 505 | return true 506 | } 507 | 508 | // 单个任务的function,自动进入任务、自动返回任务列表,返回boolean 509 | // TODO: 618 510 | function doTask(tButton, tText, tTitle) { 511 | let clickFlag = tButton.click() 512 | let tFlag 513 | 514 | if (tButton.text() == '去领取') { 515 | tFlag = clickFlag // 打卡点击一次即可 516 | return tFlag 517 | } 518 | 519 | if (tText.match(/品牌墙/) || tTitle.match(/品牌墙/)) { 520 | if (tTitle.match(/浏览更多权益/)) { 521 | console.log('简单品牌墙任务,等待10s') 522 | sleep(10000) 523 | return true 524 | } 525 | tFlag = wallTask() 526 | return tFlag // 品牌墙无需backToList,提前返回 527 | } else if (tText.match(/浏览并关注.*s|浏览.*s/)) { 528 | console.log('进行', tText) 529 | tFlag = timeTask() 530 | } else if (tText.match(/累计浏览/)) { 531 | console.log('进行累计浏览任务') 532 | if (tText.match(/加购/)) { 533 | tFlag = itemTask(true) 534 | } else { 535 | tFlag = itemTask(false) 536 | } 537 | } else if (tText.match(/入会/)) { 538 | console.log('进行入会任务') 539 | tFlag = joinTask() 540 | } else if (tText.match(/浏览可得|浏览可获得|浏览并关注|晚会|参与/)) { 541 | if (tTitle.match(/种草城/)) { 542 | tFlag = shopTask() 543 | } else { 544 | tFlag = viewTask() 545 | } 546 | } else if (tText.match(/打卡|首页/)) { 547 | tFlag = clickFlag // 打卡点击一次即可 548 | return tFlag 549 | } else if (tText.match(/组队/)) { 550 | console.log('等待组队任务') 551 | sleep(3000) 552 | if (findTextDescMatchesTimeout(/.*每做一次任务.*/, 1000)) { 553 | console.log('当前仍在任务列表,说明已经完成任务且领取奖励,返回') 554 | return true 555 | } else { 556 | if (textContains('队伍快递箱').findOne(10000)) { 557 | console.log('进入到组队页面,返回') 558 | backToList() 559 | console.log('等待领取奖励') 560 | sleep(2000) 561 | tFlag = tButton.click() 562 | sleep(2000) 563 | return tFlag 564 | } else { 565 | console.log('未能进入组队') 566 | if (findTextDescMatchesTimeout(/.*每做一次任务.*/, 1000)) { 567 | console.log('当前仍在任务列表,返回') 568 | return true 569 | } else { 570 | console.log('组队任务未检测到页面标识,视为已完成') 571 | tFlag = false 572 | } 573 | } 574 | } 575 | } else { 576 | console.log('未知任务类型,默认为浏览任务', tText) 577 | tFlag = timeTask() 578 | } 579 | backToList() 580 | return tFlag 581 | } 582 | 583 | function signTask() { 584 | console.log('尝试关闭弹窗') 585 | 586 | let anchor = textMatches(/\+\d*快递箱/).findOnce(); 587 | 588 | for (let i = 0; i < 5 && anchor; i++) { 589 | try { 590 | let tmp = anchor.parent().parent().child(0) 591 | if (!tmp.clickable()) { 592 | tmp = anchor.parent().parent().parent().child(0) 593 | } 594 | tmp.click() 595 | console.log('关闭') 596 | sleep(1000) 597 | anchor = textMatches(/\+\d*快递箱/).findOnce() 598 | } catch (err) { 599 | pass 600 | } 601 | } 602 | 603 | anchor = text('记录').findOne(5000) 604 | if (!anchor) { 605 | console.log('未能定位,签到失败') 606 | quit() 607 | } 608 | let sign 609 | if (anchor.indexInParent() < 3) { 610 | anchor = anchor.parent() 611 | } 612 | 613 | sign = anchor.parent().child(10) 614 | 615 | if (!sign.clickable()) { 616 | sign = anchor.parent().child(11) 617 | } 618 | 619 | sign.click() 620 | sleep(3000) 621 | 622 | anchor = text('提醒我每天签到').findOne(5000) 623 | 624 | if (!anchor) { 625 | console.log('未找到签到按钮') 626 | return false 627 | } 628 | 629 | anchor = anchor.parent().parent() 630 | 631 | sign = anchor.child(anchor.childCount() - 2) 632 | 633 | console.log('点击签到') 634 | return sign.click() 635 | } 636 | 637 | // 领取快递箱 638 | function havestCoin() { 639 | console.log('准备领取自动积累的快递箱') 640 | let h = textMatches(/.*点击领取.*|.*后存满.*/).findOne(5000) 641 | if (h) { 642 | h.click() 643 | console.log('领取成功') 644 | sleep(8000) 645 | } else { console.log('未找到快递箱控件,领取失败') } 646 | } 647 | 648 | // 关闭主页的弹窗 649 | function closePop() { 650 | let anchor = text('已放入首页>记录').findOnce() 651 | if (!anchor) { 652 | console.log('寻找关闭弹窗按钮失败') 653 | return false 654 | } 655 | anchor = anchor.parent() 656 | return anchor.child(anchor.childCount()-2).click() 657 | } 658 | 659 | let startCoin = null // 音量键需要 660 | 661 | // 全局try catch,应对无法显示报错 662 | try { 663 | if (autoOpen) { 664 | openAndInto() 665 | console.log('等待活动页面加载') 666 | if (!findTextDescMatchesTimeout(/.*快递箱.*/, 8000)) { 667 | console.log('未能进入活动,请重新运行!') 668 | quit() 669 | } 670 | console.log('成功进入活动,向下滑动一段以保证控件全部出现') 671 | sleep(2000) 672 | scrollDown(); 673 | 674 | openTaskList(); 675 | } else { 676 | alert('请关闭弹窗后立刻手动打开京东App进入活动页面,并打开任务列表', '限时30秒') 677 | console.log('请手动打开京东App进入活动页面,并打开任务列表') 678 | if (!findTextDescMatchesTimeout(/.*每做一次任务.*|攻略/, 30000)) { 679 | console.log('未能进入活动,请重新运行!') 680 | quit() 681 | } 682 | console.log('成功进入活动') 683 | } 684 | 685 | sleep(5000) 686 | 687 | try { 688 | console.log('获取初始快递箱数量') 689 | startCoin = getCoin() 690 | console.log('当前共有' + startCoin + '快递箱') 691 | } catch (err) { 692 | console.log('获取快递箱失败,跳过', err) 693 | } 694 | 695 | // havestCoin() 696 | 697 | // 完成所有任务的循环 698 | while (true) { 699 | let [taskButton, taskText, taskCount, taskTitle] = getTaskByText() 700 | 701 | if (!taskButton) { 702 | 703 | // console.log('领取累计奖励') 704 | // textContains('去领取').find().forEach(function (e, i) { 705 | // console.log('领取第' + (i + 1) + '个累计奖励') 706 | // e.click() 707 | // sleep(2000) 708 | // }) 709 | 710 | // havestCoin() 711 | 712 | // console.log('最后进行签到任务') 713 | // let signT = signTask() 714 | 715 | let endCoin = null 716 | try { 717 | console.log('获取结束快递箱数量') 718 | endCoin = getCoin() 719 | console.log('当前共有' + endCoin + '快递箱') 720 | } catch (err) { 721 | console.log('获取快递箱失败,跳过', err) 722 | } 723 | 724 | console.log('没有可自动完成的任务了,退出。') 725 | console.log('互动任务、下单任务需要手动完成。') 726 | if (startCoin && endCoin) { 727 | console.log('本次运行获得' + (endCoin - startCoin) + '快递箱') 728 | } else { 729 | console.log('本次运行获得快递箱无法计算,具体原因请翻阅日志。') 730 | } 731 | 732 | alert('任务已完成', '别忘了在脚本主页领取618红包!') 733 | 734 | // if (!signT) { 735 | // alert('本次签到失败', '请手动签到避免漏签(活动页右上角)') 736 | // } 737 | 738 | // alert('任务已完成', '互动任务手动完成之后还会有新任务,建议做完互动二次运行脚本') 739 | quit() 740 | } 741 | 742 | if (taskText.match(/品牌墙/) || taskTitle.match(/种草城/)) { // 品牌墙0/3只需要一次完成 743 | taskCount = 1 744 | } 745 | 746 | // 根据taskCount进行任务,一类任务一起完成,完成后刷新任务列表 747 | console.log('进行' + taskCount + '次“' + taskText + '”类任务') 748 | for (let i = 0; i < taskCount; i++) { 749 | console.log('第' + (i + 1) + '次') 750 | let taskFlag = doTask(taskButton, taskText, taskTitle) 751 | if (text('已放入首页>记录').exists()) { 752 | console.log('关闭奖励弹窗') 753 | closePop() 754 | sleep(3000) 755 | } 756 | if (taskFlag) { 757 | console.log('完成,进行下一个任务') 758 | } else { 759 | console.log('任务失败,尝试重新打开任务列表获取任务') 760 | break // 直接退出,无需在此调用reopen 761 | } 762 | } 763 | console.log('重新打开任务列表获取任务') 764 | reopenTaskList() 765 | } 766 | } catch (err) { 767 | device.cancelKeepingAwake() 768 | if (err.toString() != 'JavaException: com.stardust.autojs.runtime.exception.ScriptInterruptedException: null') { 769 | console.error(err) 770 | startCoin && console.log('本次任务开始时有' + startCoin + '快递箱') 771 | } 772 | } 773 | -------------------------------------------------------------------------------- /zrw_tmhc.js: -------------------------------------------------------------------------------- 1 | if (!auto.service) { 2 | toast('无障碍服务未启动!退出!') 3 | exit() 4 | } 5 | 6 | // alert('请把手机放稳,不要摇晃!', '不然有时候会跳出合伙赢喵币,导致任务阻塞') 7 | 8 | function getSetting() { 9 | let indices = [] 10 | autoOpen && indices.push(0) 11 | autoMute && indices.push(1) 12 | indices.push(2) 13 | 14 | let settings = dialogs.multiChoice('任务设置', ['自动打开淘宝进入活动。多开或任务列表无法自动打开时取消勾选(注意,分身运行淘宝大概率导致任务收益变为100)', '自动调整媒体音量为0。以免直播任务发出声音,首次选择需要修改系统设置权限', '此选项用于保证选择的处理,勿动!'], indices) 15 | 16 | if (settings.length == 0) { 17 | toast('取消选择,任务停止') 18 | exit() 19 | } 20 | 21 | if (settings.indexOf(0) != -1) { 22 | storage.put('autoOpen', true) 23 | autoOpen = true 24 | } else { 25 | storage.put('autoOpen', false) 26 | autoOpen = false 27 | } 28 | if (settings.indexOf(1) != -1) { 29 | storage.put('autoMute', true) 30 | autoMute = true 31 | } else { 32 | storage.put('autoMute', false) 33 | autoMute = false 34 | } 35 | } 36 | 37 | let storage = storages.create("tb_task"); 38 | let autoOpen = storage.get('autoOpen', true) 39 | let autoMute = storage.get('autoMute', true) 40 | getSetting() 41 | 42 | if (autoMute) { 43 | try { 44 | device.setMusicVolume(0) 45 | toast('成功设置媒体音量为0') 46 | } catch (err) { 47 | alert('首先需要开启权限,请开启后再次运行脚本') 48 | exit() 49 | } 50 | } 51 | 52 | console.show() 53 | console.log('开始完成能量任务...') 54 | console.log('按音量下键停止') 55 | 56 | device.keepScreenDim(60 * 60 * 1000) 57 | 58 | function registerKey() { 59 | try { 60 | events.observeKey() 61 | } catch (err) { 62 | console.log('监听音量键停止失败,应该是无障碍权限出错,请关闭软件后台任务重新运行。') 63 | console.log('如果还是不行可以重启手机尝试。') 64 | quit() 65 | } 66 | events.onKeyDown('volume_down', function (event) { 67 | console.log('喵币任务脚本停止了') 68 | console.log('请手动切换回主页面') 69 | device.cancelKeepingAwake() 70 | exit() 71 | }) 72 | } 73 | threads.start(registerKey) 74 | 75 | // 全局try catch,应对无法显示报错 76 | try { 77 | 78 | // 自定义去取消亮屏的退出方法 79 | function quit() { 80 | device.cancelKeepingAwake() 81 | exit() 82 | } 83 | 84 | // 自定义一个findTimeout,find_f是原本的查询器 text('sss').find() 85 | function findTimeout(findF, timeout) { 86 | let c = 0 87 | while (c < timeout / 50) { 88 | let result = findF.find() 89 | if (result.nonEmpty()) return result 90 | sleep(50) 91 | c++ 92 | } 93 | return null 94 | } 95 | 96 | // 自定义一个findTextDescMatchesTimeout 97 | function findTextDescMatchesTimeout(reg, timeout) { 98 | let c = 0 99 | while (c < timeout / 50) { 100 | let result = textMatches(reg).findOnce() || descMatches(reg).findOnce() 101 | if (result) return result 102 | sleep(50) 103 | c++ 104 | } 105 | return null 106 | } 107 | 108 | // 打开任务列表 109 | function openTaskList() { 110 | let c = textContains('KEYBWc').findOne(5000) 111 | if (c) { 112 | console.log('使用默认方法尝试打开任务列表') 113 | c.click() 114 | } else { 115 | throw '无法找到任务列表入口' 116 | } 117 | if (!textContains('task_detail').findOne(8000)) { 118 | console.log('默认方式打开失败,二次尝试') 119 | console.log('首先检测弹窗') 120 | for (let i = 0; i < 2 && text('关闭').findOne(2000); i++) { // 关闭弹窗 121 | console.log('检测到弹窗,关闭') 122 | click('关闭') 123 | sleep(2000) 124 | } 125 | console.log('出现未能自动关闭的弹窗请手动关闭') 126 | sleep(2000) 127 | // let right = c.bounds().right 128 | // let left = c.bounds().left 129 | // let top = c.bounds().top 130 | // let bottom = c.bounds().bottom 131 | // click(random(right,left), random(top, bottom)) 132 | click(c.bounds().centerX(), c.bounds().centerY()) 133 | console.log('已点击,等待任务列表出现') 134 | if (!textContains('KEYBWc').findOne(8000)) { 135 | throw '无法打开任务列表' 136 | } 137 | } 138 | } 139 | 140 | // 查找任务按钮 141 | function findTask() { 142 | var jumpButtonFind = textMatches(/去浏览|去完成/) // 找进入任务的按钮,10秒 143 | var jumpButtons = findTimeout(jumpButtonFind, 10000) 144 | 145 | if (!jumpButtons) { 146 | return null 147 | } 148 | 149 | for (var i = 0; i < jumpButtons.length; i++) { 150 | var taskName, content 151 | try { 152 | taskName = jumpButtons[i].parent().child(1).text() 153 | content = jumpButtons[i].parent().child(2).child(0).text() 154 | } catch (err) { 155 | console.log(err) 156 | continue 157 | } 158 | if (taskName) { 159 | // if (taskName.match(/签到领/)) { 160 | // console.log('进行签到任务') 161 | // sleep(1000) 162 | // jumpButtons[i].click() 163 | // sleep(8000) 164 | // return findTask() 165 | // } 166 | // if (!(taskName.match(/淘金币|提醒|话费|斗地主|消消乐|流浪猫|开88|扔喵糖|占领|邀请|登录|组队|参与|施肥|浇水|特价版|小鸡|消除|穿搭|森林|点淘|人生|我的淘宝|庄园/) || content.match(/小互动/))) { 167 | // return [taskName, jumpButtons[i]] 168 | // } 169 | return [taskName, jumpButtons[i]] 170 | } 171 | } 172 | return null 173 | } 174 | 175 | function liulan() { 176 | // if (textMatches(/.*浏览.*/).findOne(10000)) { // 等待浏览出现 177 | // let v = className('android.support.v7.widget.RecyclerView').findOnce() // 滑动 178 | // if (v) { 179 | // sleep(1000) 180 | // v.scrollForward() 181 | // } 182 | // } 183 | 184 | // textMatches(/.*浏览得奖励.*/).findOne(15000) // 等待开始 185 | let finish_c = 0 186 | while (finish_c < 50) { // 0.5 * 50 = 25 秒,防止死循环 187 | if (textMatches(/.*下拉浏览.*/).exists()) { 188 | console.log('进行模拟滑动') 189 | swipe(device.width / 2, device.height - 200, device.width / 2 + 20, device.height - 500, 2000) 190 | } 191 | let finish_reg = /.*任务已完成[\s\S]*|.*失败.*|.*上限.*|.*开小差.*/ 192 | if (textMatches(finish_reg).exists() || descMatches(finish_reg).exists()) { // 等待已完成出现,有可能失败 193 | break 194 | } 195 | if (textMatches(/.*4ZSN0.*/).exists() && !textMatches(/.*已浏览.*/).exists()) { // 标识加载且已浏览消失代表完成 196 | break 197 | } 198 | if (textMatches(/.*休息会呗.*/).exists()) { 199 | alert('触发淘宝验证', '请手动验证后返回淘宝首页,重新执行任务') 200 | console.log('异常退出。') 201 | quit() 202 | } 203 | if (textContains('互动奖励').exists() || 204 | descContains('互动奖励').exists()) { 205 | console.log('跳过互动任务') 206 | break 207 | } 208 | sleep(500) 209 | finish_c++ 210 | } 211 | 212 | if (finish_c > 49) { 213 | console.log('未检测到任务完成标识。返回。') 214 | // console.log('如果你认为这是一个bug请截图反馈。') 215 | // console.log('一般情况下,二次运行脚本即可。') 216 | // console.log('请手动切换回主页面') 217 | // device.cancelKeepingAwake() 218 | // quit() 219 | back() 220 | sleep(1000) 221 | // TODO: 返回检测 222 | if (!textContains('KEYBWc').findOne(5000)) { 223 | console.log('似乎没有返回,二次尝试') 224 | back() 225 | } 226 | return 227 | } 228 | 229 | console.log('任务完成,返回') 230 | 231 | sleep(1000) 232 | back() 233 | sleep(1000) 234 | if (!textContains('KEYBWc').findOne(5000)) { 235 | console.log('似乎没有返回,二次尝试') 236 | back() 237 | } 238 | } 239 | 240 | if (autoOpen) { 241 | // 打开淘宝活动页面 242 | console.log('正在打开淘宝...') 243 | var url = 's.click.taobao.com/x8b8MGu' 244 | 245 | app.startActivity({ 246 | action: "VIEW", 247 | data: "taobao://" + url 248 | }) 249 | sleep(2000) 250 | 251 | console.log('等待页面加载...') 252 | } else { 253 | console.log('请在30秒内打开淘宝做任务赢红包活动页,29¥ CZ3457 JYZOdLQpXlT¥ https://m.tb.cn/h.UExRYz2') 254 | } 255 | if (!textContains('KEYBWc').findOne(30000)) { 256 | console.log('未能检测到任务页,退出') 257 | quit() 258 | } 259 | 260 | console.log('已打开活动,准备搜索任务') 261 | sleep(5000) 262 | 263 | while (true) { 264 | console.log('准备打开任务列表') 265 | sleep(2000) 266 | openTaskList() 267 | console.log('寻找任务入口...') 268 | var jumpButton = findTask() 269 | 270 | if (jumpButton == null) { 271 | console.log('没找到合适的任务。也许任务已经全部做完了。退出。互动任务不会自动完成。') 272 | console.log('请手动切换回主页面') 273 | alert('任务已完成', '别忘了在脚本主页领取双11红包!互动任务需要手动完成。') 274 | quit() 275 | } 276 | 277 | console.log('进行' + jumpButton[0] + '任务') 278 | sleep(2000) 279 | 280 | if (jumpButton[0].match(/精选/)) { 281 | jumpButton[1].click() 282 | liulan() 283 | } else if (jumpButton[0].match(/浏览点击/)) { 284 | jumpButton[1].click() 285 | sleep(2000) 286 | let count = jumpButton[0].match(/点击(\d*)个/)[1] 287 | try { 288 | let anchor = textContains('已浏览商品').findOne(5000).parent().child(1).children() 289 | count -= parseInt(anchor[1].text()) 290 | } catch(err) { 291 | console.log('获取数量失败,使用默认值', err) 292 | } 293 | 294 | console.log('点击', count, '个商品') 295 | let buttons = textMatches(/.*马上抢.*|.*付定随机.*|.*立付.*/).find() 296 | if (!buttons) { 297 | throw '无法找到马上抢按钮,任务失败' 298 | } 299 | 300 | for (let i = 0; i < 10 && count > buttons.length; i++) { 301 | console.log('商品数量不足,向下翻页', buttons.length) 302 | scrollDown() 303 | sleep(2000) 304 | scrollDown() 305 | sleep(2000) 306 | buttons = textMatches(/.*马上抢.*|.*付定随机.*|.*立付.*/).find() 307 | console.log(buttons.length) 308 | } 309 | if (count > buttons.length) { 310 | console.log('商品数量不足,分次完成') 311 | count = buttons.length 312 | } 313 | 314 | for (let i = 0; i < count; i++) { 315 | console.log('点击第', i + 1, '个') 316 | sleep(2000) 317 | buttons[i].click() 318 | console.log('等待加载') 319 | if (text('加入购物车').findOne(10000) || currentActivity() == 'com.taobao.android.detail.wrapper.activity.DetailActivity') { 320 | console.log('商品打开成功,返回') 321 | back() 322 | if (!textContains('KEYBWc').findOne(10000)) { 323 | console.log('似乎没有返回,二次尝试') 324 | back() 325 | } 326 | } else { 327 | throw '商品页未能加载' 328 | } 329 | } 330 | } else { 331 | throw '未知任务类型' + jumpButton[0] + '请反馈!' 332 | } 333 | 334 | console.log('等待页面刷新...') 335 | sleep(2000) 336 | } 337 | } catch (err) { 338 | device.cancelKeepingAwake() 339 | if (err.toString() != 'JavaException: com.stardust.autojs.runtime.exception.ScriptInterruptedException: null') { 340 | console.error(err) 341 | } 342 | } 343 | -------------------------------------------------------------------------------- /zrw_tmrw.js: -------------------------------------------------------------------------------- 1 | if (!auto.service) { 2 | toast('无障碍服务未启动!退出!') 3 | exit() 4 | } 5 | 6 | // alert('请把手机放稳,不要摇晃!', '不然有时候会跳出合伙赢喵果,导致任务阻塞') 7 | 8 | function getSetting() { 9 | let indices = [] 10 | autoOpen && indices.push(0) 11 | autoMute && indices.push(1) 12 | indices.push(2) 13 | 14 | let settings = dialogs.multiChoice('任务设置', ['自动打开淘宝进入活动。多开或任务列表无法自动打开时取消勾选(注意,分身运行淘宝大概率导致任务收益变为100)', '自动调整媒体音量为0。以免直播任务发出声音,首次选择需要修改系统设置权限', '此选项用于保证选择的处理,勿动!'], indices) 15 | 16 | if (settings.length == 0) { 17 | toast('取消选择,任务停止') 18 | exit() 19 | } 20 | 21 | if (settings.indexOf(0) != -1) { 22 | storage.put('autoOpen', true) 23 | autoOpen = true 24 | } else { 25 | storage.put('autoOpen', false) 26 | autoOpen = false 27 | } 28 | if (settings.indexOf(1) != -1) { 29 | storage.put('autoMute', true) 30 | autoMute = true 31 | } else { 32 | storage.put('autoMute', false) 33 | autoMute = false 34 | } 35 | } 36 | 37 | let storage = storages.create("tb_task"); 38 | let autoOpen = storage.get('autoOpen', true) 39 | let autoMute = storage.get('autoMute', true) 40 | getSetting() 41 | 42 | if (autoMute) { 43 | try { 44 | device.setMusicVolume(0) 45 | toast('成功设置媒体音量为0') 46 | } catch (err) { 47 | alert('首先需要开启权限,请开启后再次运行脚本') 48 | exit() 49 | } 50 | } 51 | 52 | console.show() 53 | console.log('开始完成喵果任务...') 54 | console.log('按音量下键停止') 55 | 56 | device.keepScreenDim(60 * 60 * 1000) 57 | 58 | let startCoin; 59 | 60 | function registerKey() { 61 | try { 62 | events.observeKey() 63 | } catch (err) { 64 | console.log('监听音量键停止失败,应该是无障碍权限出错,请关闭软件后台任务重新运行。') 65 | console.log('如果还是不行可以重启手机尝试。') 66 | quit() 67 | } 68 | events.onKeyDown('volume_down', function (event) { 69 | console.log('喵果任务脚本停止了') 70 | console.log('请手动切换回主页面') 71 | if (startCoin) { 72 | console.log('本次任务开始时有', startCoin, '喵果') 73 | } 74 | device.cancelKeepingAwake() 75 | exit() 76 | }) 77 | } 78 | threads.start(registerKey) 79 | 80 | // 全局try catch,应对无法显示报错 81 | try { 82 | 83 | // 自定义去取消亮屏的退出方法 84 | function quit() { 85 | device.cancelKeepingAwake() 86 | exit() 87 | } 88 | 89 | // 自定义一个findTimeout,find_f是原本的查询器 text('sss').find() 90 | function findTimeout(findF, timeout) { 91 | let c = 0 92 | while (c < timeout / 50) { 93 | let result = findF.find() 94 | if (result.nonEmpty()) return result 95 | sleep(50) 96 | c++ 97 | } 98 | return null 99 | } 100 | 101 | // 自定义一个findTextDescMatchesTimeout 102 | function findTextDescMatchesTimeout(reg, timeout) { 103 | let c = 0 104 | while (c < timeout / 50) { 105 | let result = textMatches(reg).findOnce() || descMatches(reg).findOnce() 106 | if (result) return result 107 | sleep(50) 108 | c++ 109 | } 110 | return null 111 | } 112 | 113 | // 查找任务按钮 114 | function findTask() { 115 | var jumpButtonFind = textMatches(/去浏览|去搜索|去完成|去签到|逛一逛|去逛逛|去观看|去参赛/) // 找进入任务的按钮,10秒 116 | var jumpButtons = findTimeout(jumpButtonFind, 10000) 117 | 118 | if (!jumpButtons) { 119 | return null 120 | } 121 | 122 | for (var i = 0; i < jumpButtons.length; i++) { 123 | var taskName, content 124 | try { 125 | taskName = jumpButtons[i].parent().child(0).child(0).text() 126 | content = jumpButtons[i].parent().child(0).child(1).child(0).text() 127 | } catch (err) { 128 | console.log(err) 129 | console.log('使用第二种方法尝试') 130 | try { 131 | content = jumpButtons[i].parent().child(0).child(1).text() 132 | console.log('成功,继续任务') 133 | } 134 | catch (err) { 135 | continue 136 | } 137 | } 138 | if (taskName) { 139 | if (taskName.match(/签到/)) { 140 | console.log('进行签到任务') 141 | sleep(1000) 142 | jumpButtons[i].click() 143 | sleep(8000) 144 | return findTask() 145 | } 146 | if (!(taskName.match(/淘金币|提醒|开通|续费|乐园|话费|斗地主|消消乐|流浪猫|开88|扔喵果|占领|邀请|登录|组队|参与|施肥|浇水|特价版|小鸡|消除|穿搭|森林|点淘|人生|我的淘宝|庄园|支付宝|点击人物|省钱卡/) || content.match(/小互动|开通/))) { 147 | return [taskName, jumpButtons[i]] 148 | } 149 | } 150 | } 151 | return null 152 | } 153 | 154 | function liulan() { 155 | // if (textMatches(/.*浏览.*/).findOne(10000)) { // 等待浏览出现 156 | // let v = className('android.support.v7.widget.RecyclerView').findOnce() // 滑动 157 | // if (v) { 158 | // sleep(1000) 159 | // v.scrollForward() 160 | // } 161 | // } 162 | 163 | // textMatches(/.*浏览得奖励.*/).findOne(15000) // 等待开始 164 | let finish_c = 0 165 | let countdown = 0 166 | console.log('开始检测任务完成,部分控件无法检测,会在30秒后自动返回,请耐心等待。') 167 | while (finish_c < 250) { // 0.1 * 250 = 25 秒,防止死循环 168 | if (textMatches(/.*下拉浏览.*/).exists()) { 169 | console.log('进行模拟滑动') 170 | swipe(device.width / 2, device.height - 200, device.width / 2 + 20, device.height - 500, 2000) 171 | finish_c = finish_c + 10 172 | } 173 | let finish_reg = /.*任务.*?完成[\s\S]*?|.*失败.*|.*上限.*|.*开小差.*|.*喵果已发放[\s\S]*|.*下单可获得[\s\S]*|任务已经/ 174 | if (textMatches(finish_reg).exists() || descMatches(finish_reg).exists()) { // 等待已完成出现,有可能失败 175 | break 176 | } 177 | if (countdown == 0 && idContains('countdown').exists()) { 178 | countdown = 1 179 | break 180 | } 181 | if (textMatches(/.*休息会呗.*/).exists()) { 182 | alert('触发淘宝验证', '请手动验证后返回淘宝首页,重新执行任务') 183 | console.log('异常退出。') 184 | quit() 185 | } 186 | if (textContains('互动奖励').exists() || 187 | descContains('互动奖励').exists()) { 188 | console.log('跳过互动任务') 189 | break 190 | } 191 | if (text('手机淘宝触屏版').exists()) { 192 | console.log('页面未加载,返回') 193 | break 194 | } 195 | if (text('宝贝口袋').exists()) { 196 | let cart = text('购物车').findOnce() 197 | let x = cart.bounds().right 198 | let y = cart.bounds().top 199 | console.log('关闭直播购物车') 200 | click(x, y - 100) 201 | } 202 | if (text('立即关注得喵果').exists()) { 203 | console.log('关注直播间任务,点击关注按钮') 204 | text('立即关注得喵果').click() 205 | sleep(1000) 206 | break 207 | } 208 | if (finish_c > 100 && finish_c % 50 == 0) { 209 | console.log('滑动防止页面卡顿') 210 | swipe( device.width / 2, device.height - 400, device.width / 2 + 20, device.height - 500, 500) 211 | finish_c = finish_c + 5 212 | } 213 | sleep(100) 214 | finish_c++ 215 | } 216 | 217 | if (countdown) { 218 | console.log('出现图片类型标识,使用新方法完成,18秒后视为任务完成,自动返回') 219 | sleep(18000) 220 | } 221 | 222 | if (finish_c > 249) { 223 | console.log('未检测到任务完成标识。返回。') 224 | // console.log('如果你认为这是一个bug请截图反馈。') 225 | // console.log('一般情况下,二次运行脚本即可。') 226 | // console.log('请手动切换回主页面') 227 | // device.cancelKeepingAwake() 228 | // quit() 229 | if (textContains('果仓等级').exists()) { 230 | console.log('店铺已主动返回,继续任务') 231 | return 232 | } 233 | back() 234 | sleep(1000) 235 | // TODO: 返回检测 236 | if (!textContains('果仓等级').findOne(8000)) { 237 | console.log('似乎没有返回,二次尝试') 238 | back() 239 | } 240 | return 241 | } 242 | 243 | console.log('任务结束,返回') 244 | 245 | back() 246 | sleep(1000) 247 | if (!textContains('果仓等级').findOne(5000)) { 248 | if (currentActivity() == 'com.taobao.tao.TBMainActivity') { 249 | console.log('返回到了主页,尝试重新进入任务') 250 | id('com.taobao.taobao:id/rv_main_container').findOnce().child(3).child(0).click() 251 | } else { 252 | console.log('似乎没有返回,二次尝试') 253 | back() 254 | } 255 | } 256 | } 257 | 258 | // 喵果数量 259 | function getCoin() { 260 | console.log('获取喵果数量') 261 | try { 262 | let e = textContains('当前喵果').findOnce() 263 | let num = e.text().match(/当前喵果(\d*)/)[1] 264 | console.log('当前共有', num, '喵果') 265 | return num 266 | } catch (err) { 267 | console.log(err) 268 | console.log('获取喵果数量错误,不影响脚本运行') 269 | return null 270 | } 271 | } 272 | 273 | try { 274 | if (autoOpen) { 275 | // 打开淘宝活动页面 276 | console.log('正在打开淘宝...') 277 | var url = 'pages.tmall.com/wow/z/hdwk/2022d11/singlegame?disableNav=YES&qd_from=tbsybutton&ali_trackid=2:mm_1391100045_2014900139_110830750257' 278 | 279 | app.startActivity({ 280 | action: "VIEW", 281 | data: "taobao://" + url 282 | }) 283 | sleep(2000) 284 | 285 | console.log('等待页面加载...') 286 | textContains('去赚能量').findOne(20000) 287 | console.log('准备打开任务列表,第一次启动页面等待10秒加载') 288 | sleep(10000) 289 | 290 | let c = textContains('去赚能量').findOne(1000) 291 | if (c) { 292 | console.log('使用默认方法尝试打开任务列表') 293 | c.click() 294 | sleep(1000) 295 | c.click() 296 | console.log('已点击,未能打开建议手动点击一下任务列表。此问题并非bug,和网络以及设备性能有关。') 297 | console.log('检测任务列表,准备进行二次尝试') 298 | } else { 299 | throw '无法找到任务列表入口' 300 | } 301 | if (!textContains('果仓等级').findOne(8000)) { 302 | console.log('默认方式打开失败,二次尝试') 303 | console.log('首先检测弹窗') 304 | for (let i = 0; i < 2 && text('关闭').findOne(2000); i++) { // 关闭弹窗 305 | console.log('检测到弹窗,关闭') 306 | click('关闭') 307 | sleep(2000) 308 | } 309 | console.log('已试图自动关闭弹窗。有未能自动关闭的弹窗请手动关闭') 310 | sleep(5000) 311 | // let right = c.bounds().right 312 | // let left = c.bounds().left 313 | // let top = c.bounds().top 314 | // let bottom = c.bounds().bottom 315 | // click(random(right,left), random(top, bottom)) 316 | click(c.bounds().centerX(), c.bounds().centerY()) 317 | console.log('已点击,等待任务列表出现') 318 | if (!textContains('果仓等级').findOne(8000)) { 319 | throw '无法打开任务列表' 320 | } 321 | } 322 | } else { 323 | console.log('请在30秒内打开淘宝活动页,并打开任务列表') 324 | if (textContains('果仓等级').findOne(30000)) { 325 | console.log('已打开,继续任务') 326 | } else { 327 | console.log('未能检测到任务列表,退出') 328 | quit() 329 | } 330 | } 331 | console.log('准备搜索任务') 332 | sleep(2000) 333 | } catch (err) { 334 | console.log(err) 335 | console.log('无法进入任务列表,如果你认为这是bug,请截图反馈。注意!1级没法做任务,请先升到2级!') 336 | quit() 337 | } 338 | 339 | startCoin = getCoin() 340 | 341 | while (true) { 342 | console.log('寻找任务入口...') 343 | var jumpButton = findTask() 344 | 345 | if (jumpButton == null) { 346 | // 没有任务之后领取奖励 347 | var awardButtonFind = textMatches(/立即领取|领取奖励/) 348 | var awardButtons = findTimeout(awardButtonFind, 10000) 349 | 350 | if (awardButtons) { 351 | for (var i = 0; i < awardButtons.length; i++) { 352 | console.log('领取累计任务奖励') 353 | awardButtons[i].click() 354 | console.log('等待5秒再次领取...') 355 | sleep(5000) 356 | } 357 | } 358 | 359 | const endCoin = getCoin() 360 | 361 | console.log('没找到合适的任务。也许任务已经全部做完了。退出。互动任务不会自动完成。') 362 | console.log('请手动切换回主页面') 363 | if (startCoin && endCoin) { 364 | console.log('本次任务共获得', (endCoin - startCoin), '喵果') 365 | } 366 | alert('任务已完成', '别忘了在脚本主页领取双十一红包!互动任务需要手动完成。') 367 | quit() 368 | } 369 | 370 | if (jumpButton[0].match('去浏览店铺领能量')) { 371 | console.log('进行浏览店铺任务') 372 | jumpButton[1].click() 373 | while (!textContains('任务完成').exists()) { 374 | console.log('进入店铺浏览') 375 | text('逛店最多').findOne(15000).parent().click() 376 | liulan() 377 | sleep(2000) 378 | } 379 | back() 380 | } else if (jumpButton[0].match(/.*玩游戏.*|.*浏览餐饮卡券.*|.*加油赛.*|.*赚星星.*/)) { 381 | console.log('进行' + jumpButton[0] + '任务,10秒后返回') 382 | jumpButton[1].click() 383 | sleep(10000) 384 | back() 385 | } else if (jumpButton[0].match(/领现金/)) { 386 | console.log('进行' + jumpButton[0] + '任务') 387 | jumpButton[1].click() 388 | let into = text('打开链接').findOne(10000) 389 | if (!into) { 390 | console.log('无法找到进入领现金的按钮!') 391 | quit() 392 | } 393 | into.click() 394 | liulan() 395 | } else { 396 | console.log('进行' + jumpButton[0] + '任务') 397 | jumpButton[1].click() 398 | liulan() 399 | } 400 | 401 | console.log('等待页面刷新...') 402 | sleep(2000) 403 | } 404 | } catch (err) { 405 | device.cancelKeepingAwake() 406 | if (err.toString() != 'JavaException: com.stardust.autojs.runtime.exception.ScriptInterruptedException: null') { 407 | console.error(err) 408 | } 409 | } 410 | --------------------------------------------------------------------------------