基於AutoJs4實現的陀螺世界輔助

2020-09-28 13:01:03

又一個區塊鏈作品,任務模式為主導,做任務養寵物上下班的路上、中午的食堂、半晚約會的路上哈哈都可以點點。App沒有任何難度屬於0薅的App,每天投入一點時間就可以。還是強調區塊鏈App,大家趕緊薅過去就沒了。也是要求註冊模式。

做了個指令碼實現簽到和看AD領能量,程式碼如下:

auto.waitFor();//判斷和等待開啟無障礙
auto.waitFor();//判斷和等待開啟無障礙
let see_count = 1000;// rawInput('請輸入滑動次數','1000');//手動輸入滑動次數預設是1000次。
let appName = "陀螺世界"
app.launchApp(appName);//只有一個快手極速版所以直接Launch就可以,不用包名
console.show(); //開啟紀錄檔(懸浮窗許可權)
console.info(appName);
probability=10;//概率自動點贊、評論、關注的概率
timesInterval=8;//間隔時間
CurveBrushScreen=false;//是否曲線滑動true取消滑動false直線滑動
sleep(10000);//等待splash時間手機不好長點

adolescentWindows();//關閉青少年視窗

clickControl(text("觀看視訊翻倍"));

sleep(30000)

clickControl(id("tt_video_ad_close_layout"))

sleepRandom1()
if(clickControl(text("我的"))){
    swipeDown()
    clickControl(text("每日簽到"));
    sleepRandom1()
    if(text("已簽到").exists()){
        clickControlBounds(id("dialog_dismiss"))
    }else{
        clickControl(text("簽到"));
        sleepRandom1()
        clickControl(text("確認"));
    }
    

}
if(clickControl(text("收益"))){

    sleepRandom1()

    clickControl(text("更多有趣視訊"))
    
    sleepRandom1()
    
    for (var i = 1; i < see_count; i++) {
        toastInfo("第"+i+"次迴圈")
        clickControlList(text("去觀看"),0)
        sleep(65000)
        back()
        sleepRandom1()
        back()
        sleepRandom3()
        sleepRandom9()
        sleepRandom1()
        if(text("更多有趣視訊").exists() && text("額外算力等您來拿").exists()){
            clickControl(text("更多有趣視訊"))
        }
    }
}

/**
 * 點選螢幕上的座標
 * @param {座標} b 
 */
function clickBounds(b) {
    return clickResult = click(b.centerX(), b.centerY());
}
/**
 * 點選UI上的控制元件
 * @param {UI上的元素} element 
 */
function clickControl(element){
    let clickResult=false;
    try {
        if (element.exists()) {
            toastLog("準備click:"+element.findOnce().getText());
            let clickable=element.findOnce().clickable();//是否可以點選
            if(clickable){
                clickResult=element.findOnce().click();
                sleep(random(1000,1200));
            }else{
                let b = element.findOnce().bounds();
                clickResult=click(b.centerX(),b.centerY());
                sleep(random(1000,1200));
            }
        }
        return clickResult;
    } catch (error) {
        toastError(error)
        return false;
    }
    
}
/**
 * 元素物件
 * @param {ID或name} obj 
 */
function uiSelector(obj){
    let element=null;
    try {
        if(text(""+obj+"").exists()){
            element=text(""+obj+"");
            return element;
        }
        if(desc(""+obj+"").exists()){
            element=desc(""+obj+"");
            return element;
        }
        if(id(""+obj+"").exists()){
            element=id(""+obj+"");
            return element;
        }
    } catch (error) {
        return null;
    }
}
/**
 * 隨機點贊
 * @param {點贊ID}} view_id 
 */
function randomHeart(view_id, probability) {
    index = random(1, parseInt(probability));
    if (index == 1) {
        var target = id(view_id).findOnce();
        if (target == null) {
            return;
        } else {
            target.click();
            sleep(1000);
        }
    }
}
/**
 * 隨機關注
 * @param {控制元件ID} follow_view_id 
 * @param {概率} probability 
 */
function randomFollow(follow_view_id, probability) {
    index = random(1, parseInt(probability));
    if (index == 1) {
        var target = id(follow_view_id).findOnce();
        if (target == null) {
            return;
        } else {
            target.click();
            sleep(1000);
        }
    }
}
function clickCancle(){
    if(text("取消").exists()){
        text("取消").findOnce().click();
    }
}
/**
 * 青少年視窗
 */
function adolescentWindows() {
    if (text("我知道了").exists()) {
        text("我知道了").findOnce().click();
    }
    if (text("知道了").exists()) {
        text("知道了").findOnce().click();
    }
}
/**
 * 直接無視
 */
function closeUpgrageTip() {
    if (text("直接無視").exists()) {
        text("直接無視").findOnce().click();
    }
    if (text("重新整理重試").exists()) {
        text("重新整理重試").findOnce().click();
    }
}
/**隨機點贊並休息一秒 */
function randomHeart() {
    index = random(1, 10);
    if (index == 1) {
        var target = id('ic_like').findOnce();
        if (target == null) {
            return;
        } else {
            target.click();
            sleep(1000);
        }
    }
}
/**
 * 貝塞爾曲線
 * @param {座標點} ScreenPoint 
 * @param {偏移量} Offset 
 */
function bezier_curves(ScreenPoint, Offset) {
    cx = 3.0 * (ScreenPoint[1].x - ScreenPoint[0].x);
    bx = 3.0 * (ScreenPoint[2].x - ScreenPoint[1].x) - cx;
    ax = ScreenPoint[3].x - ScreenPoint[0].x - cx - bx;
    cy = 3.0 * (ScreenPoint[1].y - ScreenPoint[0].y);
    by = 3.0 * (ScreenPoint[2].y - ScreenPoint[1].y) - cy;
    ay = ScreenPoint[3].y - ScreenPoint[0].y - cy - by;
    tSquared =Offset * Offset;
    tCubed = tSquared * Offset;
    result = {
        "x": 0,
        "y": 0
    };
    result.x = (ax * tCubed) + (bx * tSquared) + (cx * Offset) + ScreenPoint[0].x;
    result.y = (ay * tCubed) + (by * tSquared) + (cy * Offset) + ScreenPoint[0].y;
    return result;
}
/**
 * 滑動(預設概率是百分之三十)
 * @param {*} qx 
 * @param {*} qy 
 * @param {*} zx 
 * @param {*} zy 
 * @param {*} time 
 * @param {*} timesInterval 
 */
function slideScreenDown(qx, qy, zx, zy, time, timesInterval,CurveBrushScreen) {
    if (CurveBrushScreen) {
        curveDown(qx, qy, zx, zy, time, timesInterval); //曲線概率
    } else {
        lineDown(qx, qy, zx, zy, time, timesInterval); //直線概率
    }
}
/**
 * 概率0-9 大於3的時候採用曲線概率 小於3的時候直線概率
 */
function randomFunction(){
    return Math.floor(Math.random() * 10);	
}
function curveDown(qx, qy, zx, zy, time,timesInterval){
    toastInfo("曲線滑動");
    var xxy = [time];
    var point = [];
    var dx0 = {
        "x": qx,
        "y": qy
    };
    var dx1 = {
        "x": random(qx - 100, qx + 100),
        "y": random(qy, qy + 50)
    };
    var dx2 = {
        "x": random(zx - 100, zx + 100),
        "y": random(zy, zy + 50),
    };
    var dx3 = {
        "x": zx,
        "y": zy
    };
    for (var i = 0; i < 4; i++) {
        eval("point.push(dx" + i + ")");
    };
    for (let i = 0; i < 1; i += 0.08) {
        let newPoint=bezier_curves(point, i);
        xxyy = [parseInt(newPoint.x), parseInt(newPoint.y)]
        xxy.push(xxyy);
    }
    gesture.apply(null, xxy);

    let randomMin = timesInterval * 1000;
    let randomMax = (parseInt(timesInterval) + 2) * 1000;
    let delayTime = random(randomMin, randomMax);
    sleep(delayTime);
}
/**
 * 螢幕向下滑動並延遲8至12秒
 */
function lineDown(startX, startY, endX, endY, pressTime, timesInterval) {
    toastInfo("螢幕向下滑動");
    swipe(startX, startY, endX, endY, pressTime);
    let randomMin = timesInterval * 1000;
    let randomMax = (parseInt(timesInterval) + 2) * 1000;
    let delayTime = random(randomMin, randomMax);
    sleep(delayTime);
}
/**
 * 按照指定概率隨機上滑
 * @param {*} startX 
 * @param {*} startY 
 * @param {*} endX 
 * @param {*} endY 
 * @param {*} pressTime 
 * @param {*} probability 
 */
function randomUpSildeScreen(startX, startY, endX, endY, pressTime, probability) {
    let randomIndex = random(1, parseInt(probability));
    if (randomIndex == 1) {
        swipe(startX, startY, endX, endY, pressTime);
        delayTime = random(12000, 15000);
        sleep(delayTime);
    }
}
/**
 * 連續下滑對上一個無興趣
 * 其實得和上滑做個排他,既然無興趣不要在上滑
 */
function randomDownSildeScreen(startX, startY, endX, endY, pressTime, timesInterval, probability) {
    let randomIndex = random(1, parseInt(probability));
    if (randomIndex == 1) {
        swipe(startX, startY, endX, endY, pressTime);
        sleep(2000);
        swipe(startX, startY, endX, endY, pressTime);
        sleep(timesInterval);
    }
}
/**
 *點選一下螢幕
 */
function clickScreen() {
    var x = device.width - device.width * 0.26;
    var y = device.height - device.height * 0.26;
    toastLog("點選螢幕" + x + ":" + y);
    let clickResult = click(x, y);
    toastLog(clickResult);
}
/**
 * 輸出Tosat和Info紀錄檔
 * @param {紀錄檔訊息} messagge 
 */
function toastInfo(message) {
    toast(message)
    console.info(message)
}
/**
 * 輸出Tosat和Error紀錄檔
 * @param {紀錄檔訊息} messagge 
 */
function toastError(message) {
    toast(message)
    console.error(message)
}
function toastLog(message) {
    toast(message)
    console.log(message)
}
function toastWarn(message) {
    toast(message)
    console.warn(message)
}
/**
 * 休眠隨機0.1秒至0.5秒
 */
function sleepRandom0() {
    sleep(random(100, 500));
}
/**
 * 休眠隨機1秒至3秒
 */
function sleepRandom1() {
    sleep(random(1000, 3000));
}
/**
 * 休眠隨機3秒至5秒
 */
function sleepRandom3() {
    sleep(random(3000, 5000));
}
/**
 * 休眠隨機5秒至7秒
 */
function sleepRandom5() {
    sleep(random(5000, 7000));
}
/**
 * 休眠隨機7秒至9秒
 */
function sleepRandom7() {
    sleep(random(7000, 9000));
}
/**
 * 休眠隨機11秒至9秒
 */
function sleepRandom9() {
    sleep(random(9000, 11000));
}
/**
 * 顯示控制元件的座標
 * @param {要查詢的元素} element 
 * @index {點選的順序} index 
 */
function clickControlList(element, index) {
    try {
        let controlArray = element.find();
        if (controlArray != null) {
            let controlLength = controlArray.length;
            for (let i = 0; i < controlLength; i++) {
                toastLog(controlArray[i].bounds())
            }
            let b = controlArray[index].bounds()
            return clickBounds(b)
        } else {
            return false
        }
    } catch (error) {
        return false
    }
}
/**
 * 顯示控制元件的座標
 * @param {要查詢的元素} element 
 */
function getControlList(element) {
    try {
        let controlArray = element.find();
        toastInfo(controlArray.length);
        if (controlArray != null) {
            let controlLength = controlArray.length;
            for (let i = 0; i < controlLength; i++) {
                toastLog(controlArray[i].bounds())
            }
        }
    } catch (error) {

    }
}
/**
 * 點選螢幕上的座標
 * @param {座標} b 
 */
function clickControlBounds(element) {
    let clickResult = false;
    if (element == null) {
        return false;
    }
    try {
        if (element.exists()) {
            toastLog("準備click:" + element);
            let b = element.findOnce().bounds();
            clickResult = click(b.centerX(), b.centerY());
            sleep(random(2000, 3200));
        } else {

        }
        return clickResult;
    } catch (error) {
        toastError("clickControlBounds方法出現錯誤:" + error)
        return false;
    }
}
function swipeDown() {
    let x1 = random(device.width * 0.8, device.width * 0.9);
    let y1 = device.height - (device.height * 0.2)
    let x2 = random(device.width * 0.8, device.width * 0.9);
    let y2 = device.height * 0.1
    swipe(x1, y1, x2, y2, 600);
    sleep(3000);

}

主介面是遊戲autojs無法分析就做不了操作自動化了。屬於半自動化吧~

大家有興趣的可以試試。

廣告還挺霸氣的