waterTo = "孙华";      // 给谁浇水

//插入代码
toastLog("此脚本用于支付宝小号浇水打赏");
work()
//启动支付宝
shell("am start com.eg.android.AlipayGphone/.AlipayLogin",true)

//////函数部分
function work() {
    console.show()
    console.setPosition(0,device.height/2);
    syn_steps_accounts();
    app.startActivity("console");
}

function syn_steps_accounts() {
    var Accounts =[]
    var Passwords=[]
    Accounts[0]=""
    Passwords[0]=""

    Accounts[1]=""
    Passwords[1]=""

    Accounts[2]=""
    Passwords[2]=""

    for (let k = 0; k <Accounts.length; k++) {
        account = Accounts[k]
        password = Passwords[k]
        if(account){
            switchAccount(account, password);
        }else{
            console.error("当前账号为空,已跳过")
            log("------------------")
            sleep(200)
            continue         
        }
        log("= = = = = = = = = =")
        accountOrder=k+1
        log("当前为第" + accountOrder +"//总" + Accounts.length +"个账号")
        log("= = = = = = = = = =")
        log("当前账号:" + account + "")
        log("当前密码:" + password + "")
        log("- - - - - - - - -")
        sleep(3000)
        if (text("首页").exists()){
            log("登录成功,进入蚂蚁森林…")
            log("- - - - - - - - - -")
            sleep(500)
        }else{
            console.error("账号登不上,切换")
            log("- - - - - - - - - -")
            sleep(2000)
            continue
        }
        syncToAlipay();
    }
}


function syncToAlipay() {
    //添加打赏部分脚本
    text("首页").findOne(2000)
    go_forest()
    for (var i = 0; i < 2; i++) {//重试2次,可以写到配置交互里面去,待定!
        desc("周排行榜").findOne()
            //980,1385 是打赏坐标
            setScreenMetrics(1080,1920)
            sleep(1000)
            click(890,290)//关闭可能弹出的活动页面
            sleep(500)
            click(540,1685)//关闭可能弹出的活动页面
            sleep(500)
            click(540,1620)//关闭可能弹出的活动页面
            sleep(500)
            click(880,300)//关闭可能弹出的活动页面
            sleep(3500)//4秒等待加载出来“帮你收取”控件
            log("尝试打赏..")
            click(980,1385)
            sleep(1000)
            log("已经尝试,返回重试..")
            sleep(800)
            log("- - - - - - - - - -")
            back();
            sleep(500)
            text("首页").findOne(2000)
            sleep(500)
            go_forest()
        }
        back()

        //添加浇水部分脚本
        go_forest()
        desc("周排行榜").findOne(4000)
        //let waterTo = config_syn_steps.waterTo
        log("当前浇水对象是:"+waterTo)
        var water = descContains(waterTo).findOnce()
            if (water) {
                log("找到好友"+waterTo)
                water.click()
                sleep(1000)
                //980,1500 是浇水坐标
                setScreenMetrics(1080,1920)
                sleep(1000)
                click(540,1620)//关闭可能弹出的活动页面
                sleep(500)
                click(540,1695)//关闭可能弹出的活动页面
                sleep(500)
                click(980,1500)
                sleep(1000)
                click(950,1520)
                sleep(1000)
                click(560,1820)
                log("1次浇水成功")
                log("- - - - - - - - - -")
                sleep(2500)
                click(540,1620)//关闭可能弹出的活动页面
                sleep(500)
                click(540,1695)//关闭可能弹出的活动页面
                sleep(500)
                click(980,1500)
                sleep(1000)
                click(950,1520)
                sleep(1000)
                click(560,1820)          
                log("2次浇水成功")
                log("- - - - - - - - - -")
                sleep(2500)
                click(540,1620)//关闭可能弹出的活动页面
                sleep(500)
                click(540,1695)//关闭可能弹出的活动页面
                sleep(500)
                click(980,1500)
                sleep(1000)
                click(950,1520)
                sleep(1000)
                click(560,1820)
                log("3次浇水成功")
                log("- - - - - - - - - -")
                sleep(2500)
                back()
            }else{
                log(waterTo+"不是好友,不能浇水,即将切换下个账号..")
                sleep(500)
                back()
            }
    sleep(500)
    back()
}

//打开森林
function go_forest(){
    shell("am start alipayqr://platformapi/startapp?saId=60000002",true)
    sleep(1000)
}

function switchAccount(account, key) {
    this.logIn = function (account, key) {
        idContains("loginButton").waitFor()
        setText(0, account);
        sleep(100);
        setText(1, key);
        sleep(100);
        setText(0, account);
        idContains("loginButton").findOne().click()
        textMatches(/首页|关闭/).findOne(3000) //如果登陆被限制,会卡在这里,所以注释掉,或者加时间限制
    }
    //切换账号
    shell("am start alipayqr://platformapi/startapp?appId=20000008",true)
    threads.start(function () {
        obj = textMatches("换个账号|换个验证方式|密码登录|换个方式登录").findOne(2000)
        click("换个账号")
        click("换个验证方式")
        click("密码登录")
        click("换个方式登录")
    })
    this.logIn(account, key)
    log("- - -开始登陆- - -")
}
Last modification:January 16th, 2020 at 09:48 pm
如果觉得我的文章对你有用,请随意赞赏