U校园刷时长更新:适配分辨率,添加一个小UI

您所在的位置:网站首页 u校园不能刷新分数 U校园刷时长更新:适配分辨率,添加一个小UI

U校园刷时长更新:适配分辨率,添加一个小UI

2024-03-13 11:42| 来源: 网络整理| 查看: 265

请保持程序在后台运行。

下载链接:https://cloud.189.cn/web/share?code=6vimAbFJ7Bb2(访问码:8m4h)

更新源码如下

"ui";

ui.layout(

   

       

           

       

       

       

           

       

       

   

);

ui.autoService.on("check", function(checked) {

    // 用户勾选无障碍服务的选项时,跳转到页面让用户去开启

    if(checked && auto.service == null) {

        app.startActivity({

            action: "android.settings.ACCESSIBILITY_SETTINGS"

        });

    }

    if(!checked && auto.service != null){

        auto.service.disableSelf();

    }

});

// 当用户回到本界面时,resume事件会被触发

ui.emitter.on("resume", function() {

    // 此时根据无障碍服务的开启情况,同步开关的状态

    ui.autoService.checked = auto.service != null;

});

ui.start.on("click", function(){

    //程序开始运行之前判断无障碍服务

    if(auto.service == null) {

        toast("请先开启无障碍服务!");

        return;

    }

    main();

});

function stop(){

  engines.stopAll();

}

function ace(){

var Width = device.width

var Height = device.height

function killapp(packageName) {

   //关闭应用程序,shell指令关闭,需要root,未root的手机请删除该部分。

   shell('am force-stop ' + packageName, true)

   }//function是定义一个子函数

function refresh(){

    if(className("android.widget.TextView").text("加载错误,点击刷新").exists()){

        className("android.widget.TextView").text("加载错误,点击刷新").findOne().click()

        var c = text("加载错误,点击刷新").findOne().bounds()

        click(c.centerX(), c.centerY())

    }

}//刷新页面

function errorweb(){

    if(className("android.widget.TextView").text("暂无数据").exists()){

        className("android.widget.TextView").text("暂无数据").findOne().click()

        id("iv_unit_detail_finish").findOne().click()

        sleep(3000)

className("android.widget.ListView").findOne().children().forEach(child => {

    var target = child.findOne(className("android.widget.TextView").text("2021.08.25-2022.02.25"));

    target;

    });

    var b = text("2021.08.25-2022.02.25").findOne().bounds()

    click(b.centerX(), b.centerY())//点击视听说3

            refresh()

            sleep(3000)

    }

//    有时候可能会出现页面错误,“暂无程序”,这时候会返回上一级

}

function neterror(){

    if(className("android.widget.TextView").text("当前网络不给力,学习时长可能会记录不全,请检查网络").exists()){

        var b = text("OK").findOne().bounds()

        click(b.centerX(), b.centerY())

  }

}//网络连接失败

function reload(){

    neterror()

    errorweb()

    refresh()

}

function hdzz(){

    let WIDTH = device.width;

    let HEIGHT = device.height;

   

    let kw_name = text("2-10 Unit test");

    let swipe_x = WIDTH * 0.5;

   

    let swipe_start = HEIGHT * 0.9;

    let swipe_end = HEIGHT * 0.1;

    let safe_max_swipe_times = 20;

   

    while (!kw_name.exists() && safe_max_swipe_times--) {

    gesture(500, [swipe_x, swipe_start], [swipe_x, swipe_end])

    sleep(200);

   

    }

    if (safe_max_swipe_times < 0) toast("滑动查找超时");

    var b = text("Long conversation").findOne().bounds()

    click(b.centerX(), b.centerY())

    }//滑动找字

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

for (var j=0;j {

        var target = child.findOne(className("android.widget.TextView").text("2021.08.25-2022.02.25"));

        target;

        });

        var b = text("2021.08.25-2022.02.25").findOne().bounds()

        click(b.centerX(), b.centerY())//点击视听说3

        reload()

        sleep(3000)

   

    className("android.widget.ListView").findOne().children().forEach(child => {

        var target = child.findOne(className("android.widget.TextView").text("Emotions speak louder than words"));

        target;

        });

        var c = text("Emotions speak louder than words").findOne().bounds()

        click(c.centerX(), c.centerY())//点击Unit 2

        reload()

        sleep(3000)

   

    hdzz()

    sleep(3000)

    reload()

    className("android.widget.Button").text("确定").waitFor()//等待按钮

        sleep(2000)

        var e = text("确定").findOne().bounds()

        click(e.centerX(), e.centerY())

        sleep(3000)

   

    swipe((Width)*839.3/1080,(Height)*1084.6/2160,(Width)*11.3/1080,(Height)*1084.6/2160,500)//滑动进入做题

    refresh()

    sleep(3000)

   

    for (var i=0;i {

            var target = child.findOne(className("android.view.View").depth(18).indexInParent(2));

            target;

            });

            var c = depth(18).indexInParent(2).findOne().bounds()

            click(c.centerX(), c.centerY())//点击音频播放按钮

            sleep(189000)

            }

   

//        killapp("cn.unipus.ucampus.student")//停止app运行,需要root,没root的手机可以把这个函数删除,然后将循环播放次数尽量拉满,至于最大循环播放次数是多少,请自行尝试。

}

}

function main() {

    // 这里写脚本的主逻辑

    threads.start(function () {

        toast("开始运行");

        ace();

        sleep(2000);

    });

}



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3