easyclick联众打码

联众模块lzdm.js

/**
 * @author Mr_老冷 QQ1920712147
 * @description 联众打码初步封装
 **/
function LZDM() {
    this._url = "https://v2-api.jsdama.com/upload"
    this._errurl = "https://v2-api.jsdama.com/report-error"
    this._captchaId = ""
    //软件ID
    this._softwareId = "21194"
    //软件secretKey
    this._softwareSecret = "AFJYkwgFOMahFwB20PG3YRQ5LENd4eDfNalDx2Rj"
    //请求超时
    this.timeout = 30 * 1000
}


var lzdm = new LZDM();


/**
 * @description 初始化联众信息
 * @param user {string} 联众账号
 * @param pass {string} 联众密码
 * @param softwareId {string} 软件ID
 * @param softwareSecret {string} 软件保密key
 */
LZDM.prototype.init = function (user, pass, softwareId, softwareSecret) {
    this._user = user
    this._pass = pass
    //软件ID
    this._softwareId = softwareId || this._softwareId
    //软件保密key
    this._softwareSecret = softwareSecret || this._softwareSecret
}


/**
 * @description 切换打码类型
 * @param type {string} 验证码类型
 * @param captchaMinLength {string} 验证码最小长度
 * @param captchaMaxLength {string} 验证码最大长度
 */
LZDM.prototype.changeType = function (type, captchaMinLength, captchaMaxLength) {
    //打码类型
    this._type = type
    //验证码最小长度
    this._captchaMinLength = captchaMinLength
    //验证码最大长度
    this._captchaMaxLength = captchaMaxLength
}


/**
 * @description 验证码识别
 * @param x1 {number}
 * @param y1 {number}
 * @param x2 {number}
 * @param y2 {number}
 * @returns {boolean|*}
 */
LZDM.prototype.recognize = function (x1, y1, x2, y2) {
    logi("-->lzdm.recognize");
    let img = image.captureScreen(3, Number(x1), Number(y1), Number(x2), Number(y2));
    // let r = image.saveTo(img, "/sdcard/a.png");
    let r = image.toBase64Format(img, "jpg", 10);
    image.recycle(img)
    let parms = {
        softwareId: this._softwareId,
        softwareSecret: this._softwareSecret,
        username: this._user,
        password: this._pass,
        captchaData: r,
        captchaType: this._type,
        captchaMinLength: this._captchaMinLength,
        captchaMaxLength: this._captchaMaxLength,
        workerTipsId: 0
    };
    let res = http.postJSON(this._url, parms, this.timeout, null);
    if (res) {
        res = JSON.parse(res)
        if (res.code === 0) {
            this._captchaId = res.data.captchaId
            return res.data.recognition
        }
        logd(res.message);
    }
    return false
}

/**
 * @description 验证码报错
 * @returns {boolean}
 */
LZDM.prototype.reportError = function () {
    logi("-->lzdm.reportError");
    let parms = {
        softwareId: this._softwareId,
        softwareSecret: this._softwareSecret,
        username: this._user,
        password: this._pass,
        captchaId: this._captchaId
    };
    let res = http.postJSON(this._errurl, parms, this.timeout, null);
    if (res) {
        res = JSON.parse(res)
        if (res.code === 0) {
            return true
        }
        logw(res.message);
    }
    return false
}


//例子,二字坐标点击
/*  
    laoleng.EC.init()
    laoleng.EC.initImage()

    //初始化联众
    lzdm.init("联众账号", "联众密码")

    //坐标点选题
    lzdm.changeType("1303", 2, 4)
    //开始打码
    let data = lzdm.recognize(126, 588, 953, 1197)
    if (data) {
        data = data.split("|")
        for (let i = 0; i < data.length; i++) {
            let tmp = data[i].split(",")
            logd(tmp);
            clickPoint(Number(tmp[0]) + 126, Number(tmp[1]) + 588);
            sleep(1000)
        }
        clickPoint(525, 1382);
        sleep(2000)
    }
    //答题报错
    lzdm.reportError()

    //滑块题
    lzdm.changeType("1318", 1, 1)
    //开始打码
    data = lzdm.recognize(126, 588, 953, 1197)
    if (data) {
        data = data.split(",")
        swipeToPoint(130, 800, 126 + Number(data[0]), 800, 600)
        sleep(2000)
    }
    //答题报错
    lzdm.reportError()
 */

脚本main.js调用

function main() {

    if (!autoServiceStart(3)) {
        logd("自动化服务启动失败,无法执行脚本")
        exit();
        return;
    }
    let request = image.requestScreenCapture(10000, 0);
    if (!request) {
        request = image.requestScreenCapture(10000, 0);
    }
    logd("申请截图结果... " + request)
    if (!request) {
        logw("申请截图失败,结束脚本");
        exit()
    }
    //申请完截图权限,必须等1s
    sleep(1000)

    //初始化联众
    lzdm.init("联众账号", "联众密码")
    //坐标点选题
    lzdm.changeType("1303", 2, 4)
    //开始打码
    let data = lzdm.recognize(126, 588, 953, 1197)
    if (data) {
        data = data.split("|")
        for (let i = 0; i < data.length; i++) {
            let tmp = data[i].split(",")
            logd(tmp);
            clickPoint(Number(tmp[0]) + 126, Number(tmp[1]) + 588);
            sleep(1000)
        }
        clickPoint(525, 1382);
        sleep(2000)
    }
    //答题报错
    //lzdm.reportError()

    //滑块题
    lzdm.changeType("1318", 1, 1)
    //开始打码
    data = lzdm.recognize(126, 588, 953, 1197)
    if (data) {
        data = data.split(",")
        swipeToPoint(130, 800, 126 + Number(data[0]), 800, 600)
        sleep(2000)
    }
    //答题报错
    //lzdm.reportError()
}


function autoServiceStart(time) {
    for (var i = 0; i < time; i++) {
        if (isServiceOk()) {
            return true;
        }
        var started = startEnv();
        logd("第" + (i + 1) + "次启动服务结果: " + started);
        if (isServiceOk()) {
            return true;
        }
    }
    return isServiceOk();
}

main();

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值