891277361 发表于 2019-12-1 12:17

双十二淘宝自动浏览autojs脚本源码

今天淘宝更新了双12的活动
双十一时候用的脚本「去逛店」 「去浏览」 按钮获取不到了
改成了通过textContain「浏览」获取,并用正则表达式判断任务是否完成还是否需要重复浏览
在能量中心开始运行,运行完毕需要自行停止脚本
第一次发自己写的东西,大家给加加分吧_(:3 」∠)_


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(10000);      
            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(10000);      
            swipe(width / 2, height - 500, width / 2, 0, 500);      
            sleep(8000);      
            back();      
            sleep(1500);
      }
    })   
}   
toast("请在能量中心开始运行,需要自行开始和停止脚本");

liukaidy 发表于 2019-12-1 12:18

6666666666

wsxxsw 发表于 2019-12-1 13:04

好的,非常感谢

故里为安 发表于 2019-12-1 13:57

谢谢大佬

啊啊啊啊啊 发表于 2019-12-1 14:55

谢谢分享
页: [1]
查看完整版本: 双十二淘宝自动浏览autojs脚本源码