AutoJs實戰教程---刷寶短視頻

😏 填我邀請碼【ADS75P9】
 

每天6666coin就可以多了容易...你們都懂

今天主要和大家分享一下刷刷刷過程中提示直播的窗體關閉問題,

我的手機判斷一下android.widget.RelativeLayout控件的數量。9個是正常的超過了就是有直播提醒。當然不同的手機可能不一樣,大家自己修改一下吧!

 let liveVideo=className ("android.widget.RelativeLayout").find();
    if(liveVideo.length>9){
        clickScreen();
    }

其實還有一個思路:就是每一次都點擊一下屏幕。

總體代碼:

auto.waitFor();
let see_count = 1000;// rawInput('請輸入滑動次數',"3000");
app.launchApp('刷寶短視頻');
sleep(4000);
console.show(); //開啓日誌(懸浮窗權限)
authorityCancleTip();//點擊權限取消按鈕
for (var i = 1; i < see_count; i++) {
    toast("刷寶短視頻滑動" + i + '次');
    console.log("刷寶短視頻滑動" + i + '次' + "總計:" + see_count + "次");
    shuabaoCloseAD();
    randomDownSildeScreen();
    randomHeart();
    randomFollow();
    slideScreenDown(device.width / 2, device.height * 0.8, device.width / 2, device.height * 0.1, 400);
}
//退到主頁面
home();
/**
 * 刷寶關閉廣告
 */
function shuabaoCloseAD() {
    let liveVideo=className ("android.widget.RelativeLayout").find();
    if(liveVideo.length>9){
        clickScreen();
    }
    if (id("hotspot_imgdismiss").exists()) {
        id("hotspot_imgdismiss").findOnce().click();
    }
}
/**
 * 屏幕向下滑動並延遲8至12秒
 */
function slideScreenDown(startX, startY, endX, endY, pressTime) {
    swipe(startX, startY, endX, endY, pressTime);
    delayTime = random(8000, 10000);
    sleep(delayTime);//模仿人類隨機時間
}
/**
 *點擊一下屏幕
 */
function clickScreen() {
    var x = device.width - device.width * 0.2;
    var y = device.height - device.height * 0.2;
    toastLog("點擊屏幕" + x + ":" + y);
    let clickResult = click(x, y);
    toastLog(clickResult);
}
function authorityCancleTip() {
    if(text("取消").exists()){
        text("取消").findOnce().click();
    }
    if (id("cancel").exists()) {
        id("cancel").findOnce().click();
    }
}
/**
 * 隨機上滑(防止被判定是機器)上滑後停留時間至少是10S,造成假象表示是對內容感興趣
 * 點贊和關注先不搞。
 */
function randomUpSildeScreen() {
    let randomIndex = random(1, 40);
    if (randomIndex == 1) {
        console.log("隨機上滑被執行了");
        pressTime = random(200, 500);
        swipe(device.width / 2, 500, device.width / 2, device.height - 200, 700);
        delayTime = random(8000, 10000);
        sleep(delayTime);
    }
}
/**
 * 連續下滑對上一個無興趣
 * 其實得和上滑做個排他,既然無興趣不要在上滑
 */
function randomDownSildeScreen() {
    let randomIndex = random(1, 20);
    if (randomIndex == 1) {
        console.log("連續下滑被執行了");
        swipe(device.width / 2, device.height * 0.8, device.width / 2, device.height * 0.1, 400);
        sleep(2000);
        swipe(device.width / 2, device.height * 0.8, device.width / 2, device.height * 0.1, 400);
        delayTime = random(8000, 10000);
        sleep(delayTime);

    }
}
/**隨機點贊並休息一秒 */
function randomHeart() {
    index = random(1, 10);
    if (index == 6) {
        if(id("praise").exists()){
            id("praise").findOnce().click();
        }
    }
}
function randomFollow() {
    index = random(1, 10);
    if (index == 6) {
        if(id('tv_ad_attention').exists()){
            id("tv_ad_attention").findOnce().click();
        }else{
            if(text("關注").exists()){
                text("關注").findOnce().click();
            }
        }
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章