今天淘宝更新了双12的活动
双十一时候用的脚本「去逛店」 「去浏览」 按钮获取不到了
改成了通过textContain获取,并用正则表达式判断任务是否完成还是否需要重复浏览
在能量中心开始运行
我看有说不到15秒就返回了的。我自己测试是ok的。
可能因为我把动画全关了所以我这边需要的时间更少一点。我已经把时间又延长了一点
修改sleep()最大的那两个时间可以自行加快或者减慢。里面数值的单位是毫秒
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | var height = device.height; var width = device.width; if (text("签到").exists()) { text("签到").findOne().click(); sleep(1600); toast("签到成功") } sleep(1500); while (textContains("去浏览").exists()) { toast("存在去浏览"); textContains("去浏览").find().forEach(function(o) { text_str = o.text() text_str = text_str.match(/\d+\/\d+/g).join() click_cnt = parseInt(text_str.match(/\d+/g)); goal_cnt = parseInt(text_str.match(/\/\d+/g).join().replace("/", "")); log(click_cnt, goal_cnt) if (click_cnt != goal_cnt) { toast("找到了"); o.click(); sleep(1500); swipe(width / 2, height - 500, width / 2, 0, 500); sleep(2500); swipe(width / 2, height - 500, width / 2, 0, 500); sleep(15000); swipe(width / 2, height - 500, width / 2, 0, 500); sleep(8000); back(); sleep(1500); } }) } while (textContains("去搜索").exists()) { toast("存在去搜索"); textContains("去搜索").find().forEach(function(o) { text_str = o.text() text_str = text_str.match(/\d+\/\d+/g).join() click_cnt = parseInt(text_str.match(/\d+/g)); goal_cnt = parseInt(text_str.match(/\/\d+/g).join().replace("/", "")); log(click_cnt, goal_cnt) if (click_cnt != goal_cnt) { toast("找到了"); o.click(); sleep(1500); swipe(width / 2, height - 500, width / 2, 0, 500); sleep(2500); swipe(width / 2, height - 500, width / 2, 0, 500); sleep(15000); swipe(width / 2, height - 500, width / 2, 0, 500); sleep(8000); back(); sleep(1500); } }) } toast("请在能量中心开始运行,需要自行开始和停止脚本"); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | auto.waitFor(); var height = device.height; var width = device.width; toast("\n设备宽" + width + "\n" + "设备高" + height + "\n" + "手机型号" + device.model + "\n安卓版本" + device.release); setScreenMetrics(width, height); var click_num = dialogs.rawInput("请输入点击红包的次数(留空为取消)", ""); if (isNaN(click_num)) { toast("输入有误,不执行点击红包!"); click_num = ""; } click(300, 300); if (textContains("赚翻倍豆").exists()) { toast('开始赚翻倍豆'); textContains("赚翻倍豆").click(); var task_num = 0; textContains("做任务赚翻倍豆").waitFor(); var wait_num = 1; while (true) { if (textEndsWith("+1000").exists()) { task_click(); task_num++; toast("第" + task_num + "个"); continue; } wait_num++; if (wait_num > 5) { break; } else { swipe(width / 2, height / 2 + 300, width / 2, height / 2, 500); } } back_try(); toast("做任务赚翻倍豆结束"); toast("此次共赚" + task_num * 1000 + "个翻倍豆"); click(1000, 725); if (click_num != null && click_num != "" && click_num != 0) { if (textContains("赚翻倍豆").exists()) { red_packet(click_num); } else { toast("位置异常,未能点击红包!"); } } } else { toast("请回到活动首页再折行脚本!"); } toast("脚本结束"); function task_click() { if (text("再玩玩").exists()) { text("再玩玩").findOne().click(); } textEndsWith("+1000").findOne().click(); var time = random(3000, 5000); sleep(time); back_try(); } function red_packet(click_num) { toast('开始点击红包'); var i = 0; while (true) { if (i >= click_num) { break; } press(556, 922, random(3000, 5000)); sleep(1000); textContains("继续玩").waitFor(); sleep(1000); textContains("继续玩").click(); i++; toast("第" + i + "次"); } toast('结束点击红包'); } function back_try() { var wait_num = 0; while (!textContains("做任务赚翻倍豆").exists() && !textContains("赚翻倍豆").exists()) { if (wait_num > 10) { break; } if (text("再玩玩").exists()) { text("再玩玩").findOne().click(); } if (text("拒绝").exists()) { text("拒绝").findOne().click(); } if (text("取消").exists()) { text("取消").findOne().click(); } back(); sleep(1000); wait_num++; } } |