JD 2020 Double Twelve Event is finally here, the script will help you get the end of the year

Write in front

After all the calls came out, JD.com finally joined the double twelfth battle of this year. I have to say that JD.com is indeed a bit late this year. However, as a loyal user of JD.com, the author stayed up all night and wrote the script for the first time. Everyone learn to use

Follow the WeChat public account " Pocket Reader Assistant ", backstage reply " JD Double Twelve ", get the script/APK file (the script file will be open source at the end of the article, everyone can rest assured)

Use tutorial

Open the Jing Twelve icon on the desktop

If it is the first time to run, you will apply for permission, please allow

Then the page also jumps to the page where the accessibility is turned on, and the accessibility mode is manually turned on. The specific operation is shown in the figure below

After opening, re-run Beijing XII, the system will prompt for the permission of floating window

Here you need to manually open the floating window permission. Since different mobile phones have different opening methods, you can Baidu by yourself. The author uses the Xiaomi 8 MIUI12 system. The opening interface is as follows

Just turn it on

At this point, all the places that need to be set are over, and you can directly run the Jing12 APP

However, during the running process, you will apply for the opening of the Jingdong application. Please remember to click on the permission

The following is the running GIF, but when I debug the code here, the running is over. Let’s take a look.

Running effect GIF

 

Script code

auto.waitFor();
var height = device.height;
var width = device.width;
toast("开启2020京东双十二")
setScreenMetrics(width, height);
// toastLog(isActPage())

start()

function gotoAct() {
    log('准备启动京东APP')
    launch('com.jingdong.app.mall')
    log('京东APP打开成功')
    MySleep(4, 5);
    log('准备进入京东双十二活动页面,如果页面有其他弹窗,请手动关闭下')
    let actWid = descContains('浮层活动').clickable(true).findOne(500);
    click(actWid.bounds().centerX(), actWid.bounds().centerY());
    MySleep(4, 5);
    if (!isActPage()) {
        actWid = descContains('浮层活动').clickable(true).findOne(500);
        click(actWid.bounds().centerX(), actWid.bounds().centerY());
        MySleep(4, 5);
    }
}

function gotoActFromIndex() {
    let actWid = descContains('浮层活动').clickable(true).findOne(500);
    click(actWid.bounds().centerX(), actWid.bounds().centerY());
    MySleep(4, 5);
}

function isIndexPage() {
    let actWid = descContains('浮层活动').clickable(true).findOne(500);
    if (actWid) {
        return true;
    } else {
        return false;
    }
}

function start() {
    console.show();
    log('运行脚本请先将京东商城APP从后台杀掉,保证运行过程中出现错误较少')
    MySleep(4, 6);
    gotoAct();
    while (!isActPage()) {
        log('程序未正确进入活动页面,请手动进入')
        MySleep(2, 3);
    }
    if (isActPage()) {
        log('进入活动页面成功')
    }

    finishTask();
    lingHB();
    alert("任务已完成", "所有任务貌似都做完啦!\n若仍有任务请重新运行噢!");
}



function lingHB() {
    if (isActPage()) {
        let kaihongbao = text('开红包').depth(14).clickable(true).findOne(1000);
        while (kaihongbao) {
            kaihongbao.click();
            MySleep(2, 3);
            let shouxia = text('开心收下').findOne(1000);
            click(shouxia.bounds().centerX(), shouxia.bounds().centerY())
            MySleep(2, 3);
            kaihongbao = text('开红包').depth(14).clickable(true).findOne(1000);
        }
    }
}

function finishTask() {
    let taskBS = ['去完成', '去浏览']
    for (let i = 0; i < taskBS.length; i++) {
        lingHB();
        let task = taskBS[i];
        let taskWid = text(task).depth(14).clickable(true).findOne(1000);

        while (taskWid) {
            let textWid = className('android.view.View').indexInParent(taskWid.indexInParent() - 2).depth(14).findOne(500);
            taskWid.click();
            log('去完成:' + textWid.text())
            MySleep(2, 3)
            let count = 0;
            while (count++ < 5) {
                MySwipe();
                MySleep(0.5, 2);
            }
            back();
            MySleep(2, 3);
            if (isIndexPage()) {
                gotoActFromIndex();
            }
            while (!isActPage()) {
                back();
                MySleep(2, 3);
            }
            taskWid = text(task).depth(14).clickable(true).findOne(1000);
            MySleep(2, 3);
        }
    }
}

function isActPage() {
    let actPage = textContains('db0b3143293bbbb7').depth(14).findOne(500);
    if (actPage) {
        return true;
    } else {
        return false;
    }
}


function random(min, max) {
    return Math.round(Math.random() * (max - min)) + min;
}

function MySwipe() {
    var sX = random(100, width - 100);
    var sY = random(height / 2 + 100, height - 100);
    var eY = random(100, height / 2 - 100);
    swipe(sX, sY, sX, eY, random(100, 120));
}

function MySleep(Min, Max) {
    sleep(random(Min * 1000, Max * 1000));
}

 

Guess you like

Origin blog.csdn.net/xchl123/article/details/110790340