抖音引流脚本autojs免root怎么获取用户关注控件

/*
修改日期:20200601
起始页面:个人资料页
备注说明:
返回值:字符串型
@视频对照教学:www.loveps.vip/121.html
*/
log(APP_关注用户())

function APP_关注用户() {
    var isFollow = false
    let object = text("关注").depth(18).findOne(1000)
    if (object != null) {
        if (object.clickable()) {
            object.click(); //点击关注按钮
            sleep(random(1000, 3000))  //随机延时
            if (findNode("text", "取消关注")) {
                log("关注成功")
                isFollow = true
            } else if (findNode("text", "已请求")) {
                log("已请求关注,关注失败.这是私密账号")
            } else {
                log("关注失败")
            }
        } else {
            log("关注节点不可点击")
        }

    } else if (findNode("text", "取消关注")) {
        log("已关注,无需执行关注")
    } else if (findNode("text", "已请求")) {
        log("已请求关注,无需执行关注.这是私密账号")
    } else {
        log("未找到关注按钮,可能已关注或APP版本不符合")
    }
    return isFollow
};



// -------------------------------------------------------------------------------------------------------------

/*
寻找节点
@way:查找方式: text/desc/id/className
@str:節點文本
@timeOut:查找超时的时间,默认1000毫秒。可空
*/
function findNode(way, str, timeOut) {
    if (!timeOut) { timeOut = 1000 }
    let result = false   //点击结果
    let objectAge;
    if (way == "text") {
        objectAge = text(str).findOne(timeOut);
    } else if (way == "desc") {
        objectAge = desc(str).findOne(timeOut);
    } else if (way == "id") {
        objectAge = id(str).findOne(timeOut);
    } else if (way == "className") {
        objectAge = className(str).findOne(timeOut);
    } else {
        log("Error:findNode-way参数不正确")
    }

    if (objectAge != null) {
        result = true
    } else {
        // log("Error:findNode-组件不存在/没找到")
    }

    return result;
};

/*
点击节点中心点坐标
@way:查找方式
@str:節點文本
@sleepTime:点击成功后的延时,默认1000毫秒。可空
*/
function clickNodeR(way, str, sleepTime) {
    if (!sleepTime) { sleepTime = 1000 }
    let result = false   //点击结果
    let objectAge;
    if (way == "text") {
        objectAge = text(str).findOne(1000);
    } else if (way == "desc") {
        objectAge = desc(str).findOne(1000);
    } else if (way == "id") {
        objectAge = id(str).findOne(1000);
    } else if (way == "className") {
        objectAge = className(str).findOne(1000);
    } else {
        log("Error:clickNodeR-way参数不正确")
    }

    if (objectAge != null) {
        let x = objectAge.bounds().centerX();
        let y = objectAge.bounds().centerY();
        log(x, y)
        if (x > 0 && y > 0) {
            result = click(parseInt(x), parseInt(y));
        } else {
            log("Error:clickNodeR-中心点坐标不在可视区")
        }
        result && sleep(sleepTime);
    } else {
        log("Error:clickNodeR-组件不存在/没找到")
    }
    return result;
};


/*
点击节点
@way:查找方式
@str:節點文本
@sleepTime:点击成功后的延时,默认1000毫秒。可空
*/
function clickNode(way, str, sleepTime) {
    if (!sleepTime) { sleepTime = 1000 }
    let result = false   //点击结果
    let objectAge;
    if (way == "text") {
        objectAge = text(str).findOne(1000);
    } else if (way == "desc") {
        objectAge = desc(str).findOne(1000);
    } else if (way == "id") {
        objectAge = id(str).findOne(1000);
    } else if (way == "className") {
        objectAge = className(str).findOne(1000);
    } else {
        log("Error:clickNode-way参数不正确")
    }

    if (objectAge != null) {
        if (objectAge.clickable()) {
            result = objectAge.click();
            result && sleep(sleepTime);

            // if (result) {
            //     sleep(sleepTime);
            // }
        } else {
            log("Error:clickNode-组件不可点击")
        }
    } else {
        log("Error:clickNode-组件不存在/没找到")
    }

    return result;
};

你可能感兴趣的:(vscode)