• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

autojs 宇博脚本源码

互联网 diligentman 2周前 (11-18) 9次浏览

"ui";

var myApp ={};

myApp.isRun = false;

myApp.homeActivity = "io.dcloud.PandoraEntryActivity";

myApp.appName = "宇博聚流";

myApp.dyAppPackage = "com.ss.android.ugc.aweme";

myApp.wxHomeActivty = "com.tencent.mm.ui.LauncherUI";

myApp.startXXTime = 0;

myApp.endXXTime = 0;

myApp.taskMinTime = 2;//可接的最少结束任务分钟

myApp.taskEarlyEnd = 2;//默认两分钟

myApp.dzX = device.width-50;

myApp.dzY = device.height/2-50; 

myApp.xqTPX = 200;

myApp.xqTPY = 350;

//tabs 数据

var tabs_data = {

    //tabs 背景

    bg: "#ffffff",

    selectColor: {

        //当前页面选中颜色

        on: "#00ffff",

        //当前页面未选中颜色

        off: "#999999"

    },

    //图标大小

    srcSize: 18,

    //字体大小

    textSize: 12,

    //动画缩放比例 未加入动画效果

    zoom: 1.2,

    //是否显示指示器小横条

    tabs_h: true,

    //tabs 按钮数据

    data: [

        ["设置", "@drawable/ic_settings_black_48dp"],

        ["通用设置", "@drawable/ic_settings_black_48dp"],

        ["日志", "@drawable/ic_assignment_black_48dp"],

 

    ],

}

 

//tabs按钮 布局视图信息

var tabs_view = []

//tabs按钮 当前选中按钮

var selectView = 0;

 

//自定义控件 tabs按钮

var Tabs_btn_layout = function () {

    //继承ui.Widget

    util.extend(Tabs_btn_layout, ui.Widget);

    function Tabs_btn_layout() {

        //调用父类构造函数

        ui.Widget.call(this);

        //自定义属性data ,定义控件的每个参数 传入值为整数

        this.defineAttr("data", (view, attr, value, defineSetter) => {

            //获取当前控件的参数值 tabs_data.data[value] 赋值到arr数组

            arr = tabs_data.data[value]

            //设定 _text控件文本

            view._text.setText(arr[0])

            //设定 _src控件图片

            view._src.attr("src", arr[1])

            //把当前控件信息集合到tabs_view数组里面

            tabs_view[tabs_view.length] = view

            //如果当前控件为初始值 则设定控件颜色为选中颜色 selectView==value==0 

            if (value == selectView) {

                view._src.attr("tint", tabs_data.selectColor.on)

                view._text.setTextColor(colors.parseColor(tabs_data.selectColor.on))

            }

        });

    }

    Tabs_btn_layout.prototype.render = function () {

        return (

            //1.0.0-1 修改 w="*" 参数 屏幕方向发生变化时 宽度自适配

            <vertical id="_bg" w="*" bg="{{tabs_data.bg}}" padding="0 10" gravity="center" >

                <img w="{{tabs_data.srcSize}}" h="{{tabs_data.srcSize}}" id="_src" tint="{{tabs_data.selectColor.off}}" />

                <text w="auto" id="_text" textSize="{{tabs_data.textSize}}" textColor="{{tabs_data.selectColor.off}}" />

            </vertical>

        )

    }

    ui.registerWidget("tabs_btn-layout", Tabs_btn_layout);

    return Tabs_btn_layout;

}()

 

//自定义控件 tabs

var Tabs_layout = function () {

    util.extend(Tabs_layout, ui.Widget);

    function Tabs_layout() {

        ui.Widget.call(this);

        this.defineAttr("data", (view, attr, value, defineSetter) => {

            //遍历 tabs_data.data数组 

            for (var i = 0; i < tabs_data.data.length; i++) {

                time = i

                //1.0.0-1 增加 layout_weight="1"参数 屏幕方向发生变化时 宽度自适配

                ui.inflate(<tabs_btn-layout data="{{time}}" layout_weight="1" />, view._tabs, true)

            }

            //根据tabs_h值设置 _color颜色

            tabs_data.tabs_h ? _color = tabs_data.selectColor.on : _color = "#00000000";

            view.tabs.selectedTabIndicatorColor = colors.parseColor(_color);//设置tabs指示器颜色

        });

    }

    Tabs_layout.prototype.render = function () {

        return (

            <card w="*" h="auto" cardElevation="5" foreground="?selectableItemBackground">

                <horizontal id="_tabs" />

                <tabs id="tabs" />

            </card>

        )

    }

    ui.registerWidget("tabs-layout", Tabs_layout);

    return Tabs_layout;

}()

 

ui.layout(

    <frame>

        <vertical>

            <appbar w="*" h="auto">

                <toolbar id="toolbar" title="{{tabs_data.data[0][0]}}" />

            </appbar>

            <viewpager w="*" id="viewpager" layout_alignParentBottom="true" >

                <frame >

                    <vertical>

                        <Switch id="rootSwith" text="无障碍服务:" checked="{{auto.service != null}}" w="auto" textStyle="bold" />

                        <horizontal> <text text="休息时间:"/>     <input id="startXXTime" text="{{myApp.startXXTime}}"/><text text="~"/>  <input id="endXXTime" text="{{myApp.endXXTime}}"/><text text="(设置0~0表示不休息)"/> </horizontal>

                        <horizontal> <text text="可接的最少(几分钟)结束任务时间:"/>     <input id="taskMinTime" text="{{myApp.taskMinTime}}"/><text text="(结束任务时间太小有可能没完成任务就结束了)"/> </horizontal>

                        <horizontal> <text text="任务提前几分钟结束"/>     <input id="taskEarlyEnd" text="{{myApp.taskEarlyEnd}}"/><text text="(必须小于接收任务时间)"/> </horizontal>

                        <horizontal> <text text="任务点赞位置:"/>     <input id="dzX" text="{{myApp.dzX}}"/><text text=","/>  <input id="dzY" text="{{myApp.dzY}}"/><text text="(默认不行自己设置)"/> </horizontal>

                        <horizontal> <text text="选取图片位置:"/>     <input id="xqTPX" text="{{myApp.xqTPX}}"/><text text=","/>  <input id="xqTPY" text="{{myApp.xqTPY}}"/><text text="(微信打开相册第一张图片的位置)"/> </horizontal>

                        <button id="startRun" text="启动" />

                        <text text="QQ群: 856728443  " />

                        <text text="本程序仅供参考学使用,如若非法使用概不负责"/>

                    </vertical>

                </frame>

                <frame >

                    <vertical>

                     

                    </vertical>

                </frame>

                <frame>

                    <vertical>

                        <text text="日志" />

                        <com.stardust.autojs.core.console.ConsoleView id="console" layout_weight="1" />

                        <text h="50px" w="*" />

                    </vertical>

                </frame>

 

            </viewpager>.

        </vertical>

        <tabs-layout data="" layout_gravity="bottom" />

    </frame>

)

 

ui.tabs.setupWithViewPager(ui.viewpager);//绑定ViewPager到指示器

 

//页面更改侦听器

ui.viewpager.setOnPageChangeListener({

    //已选定页面发生改变时触发

    onPageSelected: function (index) {

        //  log("上次选中" + tabs_view[selectView]._text.text())

        //设置selectView上次页面 图案和字体颜色为未选中颜色 tabs_data.selectColor.off

        tabs_view[selectView]._src.attr("tint", tabs_data.selectColor.off)

        tabs_view[selectView]._text.setTextColor(colors.parseColor(tabs_data.selectColor.off))

        //设置当前页面 图案和字体颜色为选中颜色 tabs_data.selectColor.on

        tabs_view[index]._src.attr("tint", tabs_data.selectColor.on)

        tabs_view[index]._text.setTextColor(colors.parseColor(tabs_data.selectColor.on))

        //更改标题 title 内容

        ui.toolbar.setTitle(tabs_view[index]._text.text())

        //设置当前页面为 index

        selectView = index

    }

})

 

ui.console.setConsole(runtime.console);

// 设置控制台字体颜色

let c = new android.util.SparseArray();

let Log = android.util.Log;

c.put(Log.VERBOSE, new java.lang.Integer(colors.parseColor("#dfc0c0c0")));

c.put(Log.DEBUG, new java.lang.Integer(colors.parseColor("#cc000000")));

c.put(Log.INFO, new java.lang.Integer(colors.parseColor("#ff64dd17")));

c.put(Log.WARN, new java.lang.Integer(colors.parseColor("#ff2962ff")));

c.put(Log.ERROR, new java.lang.Integer(colors.parseColor("#ffd50000")));

c.put(Log.ASSERT, new java.lang.Integer(colors.parseColor("#ffff534e")));

ui.console.setColors(c);

 

/* 禁止返回键退出脚本 */

ui.emitter.on('back_pressed', function (event) {

    event.consumed = true;

});

//无障碍监听

ui.rootSwith.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.rootSwith.checked = auto.service != null;

});

 

threads.start(function(){

    //请求截图

    if (!requestScreenCapture()) {

        ui.run(function(){

            toastLog("请求截图失败!");

        })

        exit();

    }

 

    

    // 屏蔽音量键调节声音

    events.setKeyInterceptionEnabled("volume_up", true);

    //启用按键监听

    events.observeKey();

    //监听音量键按下

    events.onKeyDown("volume_up", () => {

        log('按音量键停止');

        toastLog("停止脚本");

        myApp.isRuning = false;

    

 

        mainThreads.interrupt();

    

      //  exit();   //停止、退出脚本

    });

})

 

var mainThreads = null;

 

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

   // myApp.minHBTime = ui.minHBTime.getText();

    //myApp.maxHBTime = ui.maxHBTime.getText();

    threads.start(function(){

      let   fy= floaty.rawWindow(<vertical alpha="0.6">

        <card w="*" h="32" bg="#333333" gravity="center_vertical"><vertical h="auto" padding="15 0 10 0">

            <text id="qNum" text="抢 0 次" textColor="#FFFFFF"/>

        </vertical>

        <View bg="#F44336" w="5" h="*"/></card>

        <card w="*" h="32" bg="#333333" gravity="center_vertical">

        <vertical h="auto" padding="15 0 10 0">

            <text id="qCNum" text="成 0 次" textColor="#FFFFFF"/>

        </vertical>

        <View bg="#4CAF50" w="5" h="*"/></card>

        <card w="*" h="32" bg="#00aa00" gravity="center_vertical"><vertical h="auto" padding="15 0 10 0">

            <text id="hq" text="获取" textColor="#FFFFFF"  />

        </vertical>

        <View bg="#F44336" w="5" h="*"/></card>

        </vertical>);

    

        fy.setPosition(0,700);

        setInterval(()=>{}, 1000);

 

        fy.hq.click(()=>{

            myApp.isRun = !myApp.isRun;

            myApp.startXXTime = parseInt( ui.startXXTime.getText());

            myApp.endXXTime = parseInt(ui.endXXTime.getText());

            myApp.taskEarlyEnd = parseInt(ui.taskEarlyEnd.getText());

            myApp.taskMinTime = parseInt(ui.taskMinTime.getText());

            myApp.dzX = parseInt(ui.dzX.getText());

            myApp.dzY = parseInt(ui.dzY.getText());

            if(myApp.isRun){

                fy.hq.setText("暂停");

                ui.run(function(){

                    toastLog("开始执行脚本");

                })

             

                mainThreads =  threads.start(function(){

                    start(fy);

                })

            }

            else{

                fy.hq.setText("开始");

                mainThreads.interrupt();

                ui.run(function(){

                    toastLog("暂停执行脚本");

                })

            }

         

        })

    })

 

})

//时间差 ,返回分钟

function timeDeffToSecond(start,end){

    var c = end.getTime()-start.getTime();

    return c/(60*1000);

}

 

function openHome(){

    if(text("首页").exists()){

        let b = text("首页").findOne().bounds();

        if(b.centerX()>0&&b.centerY()>0){

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

            log("打开首页");

            return true;

        }

    }

    return false;

}

 

function sx(){

    log("—>"+text("极速任务列表").visibleToUser().exists());

    let headTabY = 350;

 

    if(text(myApp.appName).exists()){

        if(text(myApp.appName).findOne().bounds().centerY()>0){

            headTabY = text(myApp.appName).findOne().bounds().bottom+100;

        }

    }

 

    while(true){

        if(text("极速任务列表").visibleToUser().exists()){

            let b = text("极速任务列表").findOne().bounds();

            if(b.centerY()>0&&b.centerY()>=(device.height/4)){

                log("不用下来");

                break;

            }

        }

   

        swipe(200,headTabY,230,device.height*0.66,500);

        sleep(1000);

    }

    log("刷新"+headTabY);

    swipe(200,headTabY,230,device.height*0.66,1000);

    ui.run(function(){

        toastLog("刷新列表");

    })

}

//关注直播

function gzZB(){

    if(text("关注").exists()){

        let b = text("关注").findOne().bounds();

        if(b.centerX()>0&&b.centerY()>0){

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

            return true;

        }

    }else if(id("bsy").exists()){

        let b = id("bsy").findOne().bounds();

        if(b.centerX()>0&&b.centerY()>0){

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

            return true;

        }

    }

    return false;

}

//是否关注

function isGZ(){

    if(text("关注").visibleToUser().exists()){

        let b = text("关注").findOne().bounds();

        if(b.centerX()>0&&b.centerY()>0&&b.centerY()<400){

            return false;

        }

    }

    return true;

}

 

function showWXMainPage(){

    //tab 首页图标

    if(className("android.widget.ImageView").id("cnh").exists()){

        let btn = className("android.widget.ImageView").id("cnh").findOne().bounds();

        click(btn.centerX(),btn.centerY());

    }else if(className("android.widget.TextView").id("cns").exists()){

        let btn = className("android.widget.TextView").id("cns").findOne().bounds();

        click(btn.centerX(),btn.centerY());

    }else if(className("android.widget.ImageView").text("微信").exists()){

        let btn = className("android.widget.TextView").text("微信").findOne().bounds();

        click(btn.centerX(),btn.centerY());

    }

}

function isWJCSZS(){

    var  state = 0;

    swipe(300,300,400,600,1000);

    if(className("android.view.View").id("e3x").exists()){

        className("android.view.View").id("e3x").find().forEach(function(currentValue,index){

       

                if(currentValue.getText()=="文件传输助手"){

    

                    state = 1;

                   

                }

        })

    

        return state;

    }else if(text("文件传输助手").exists()){

        return 0;

    }

    return -1;

}

//进入文件传输助手

function onWJCSZS(){

    if(className("android.view.View").id("e3x").exists()){

        className("android.view.View").id("e3x").find().forEach(function(currentValue,index){

         

                if(currentValue.getText()=="文件传输助手"){

                    log("点击文件传输助手");

                    click(currentValue.bounds().centerX(),currentValue.bounds().centerY());

                    sleep(1000);

                }

        })

     

    }else if(text("文件传输助手").exists()){

        let btn = text("文件传输助手").findOne().bounds();

        log("点击文件传输助手");

        click(btn.centerX(),btn.centerY());

        sleep(1000);

    }

}

function fsTP(){

    waitForActivity(myApp.wxHomeActivty);

    showWXMainPage();

    if(isWJCSZS()>0){

            

        onWJCSZS();

        

        if(id("aks").exists()){

 

            let b = id("aks").findOne().bounds();

 

            if(b.centerX()>0&&b.centerY()>0){

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

                sleep(2000);

                if(text("相册").exists()){

                    let bxc = text("相册").findOne().bounds();

                    if(bxc.centerX()>0&&bxc.centerY()>0){

                        click(bxc.centerX(),bxc.centerY());

                        sleep(2000);

                        click(myApp.xqTPX,myApp.xqTPY);

                        sleep(1000);

                        if(textStartsWith("发送").visibleToUser().exists()){

                            let fsb = textStartsWith("发送").findOne().bounds();

                            if(fsb.centerX()>0&&fsb.centerY()>0){

                                click(fsb.centerX(),fsb.centerY());

                                sleep(2000);

                                back();

                                back();

                            }

                        }

                    }

 

                }

            }

        }

 

    }else{

        log("请把文件传输助手置顶");

        ui.run(function(){

            toastLog("请把文件传输助手置顶");

        })

    }

 

}

//结束任务

function endTask(){

    ui.run(function(){

        toastLog("结束任务,开始分享抖音码");

    })

    if(desc("更多").visibleToUser().exists()){

        let b = desc("更多").findOne().bounds();

        if(b.centerX()>0&&b.centerY()>0){

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

            sleep(1500);

            if(text("分享").visibleToUser().exists()){

                let bf = text("分享").findOne().bounds();

                if(bf.centerX()>0&&bf.centerY()>0){

                    click(bf.centerX(),bf.centerY());

                    sleep(2000);

                    if(text("抖音码").visibleToUser().exists()){

                        let bm = text("抖音码").findOne().bounds();

                        if(bm.centerX()>0&&bm.centerY()>0){

                            click(bm.centerX(),bm.centerY());

                            sleep(2000);

                            for(let i = 0;i<30;i++){

                                if(text("分享到").visibleToUser().exists()){

                                    if(text("微信好友").visibleToUser().exists()){

                                        let bzf = text("微信好友").findOne().bounds();

                                        if(bzf.centerX()>0&&bzf.centerY()>0){

                                            click(bzf.centerX(),bzf.centerY());

                                            sleep(2000);

                                            if(text("去微信好友分享").visibleToUser().exists()){

                                                let fxb = text("去微信好友分享").findOne().bounds();

                                                if(fxb.centerX()>0&&fxb.centerY()>0){

                                                    click(fxb.centerX(),fxb.centerY());

                                                    ui.run(function(){

                                                        toastLog("分享到微信");

                                                    })

                                                    sleep(5000);

                                                }

                                            }

                                        }

                                    }

                                }

                            }

                        }

                    }

                }

            }

        }

    }

}

 

//任务中

function taskRuning(endTime){

    let startTime = new Date();

    let endT = endTime – myApp.taskEarlyEnd;

    if(endT<=0){

        console.error("脑壳有包包,你接的时候小于你提前结束的时间!!你看个什么?");

    }

    while(timeDeffToSecond(startTime,new Date())<= endT){

        sleep(random(2000,10000));

        for(var i=0;i<4;i++){

            click(myApp.dzX,myApp.dzY);

            sleep(random(300,550));

        }

    }

}

 

function openZB(){

    sleep(5000);

    //waitForPackage(myApp.dyAppPackage);

    log(currentPackage());

    if(currentPackage()==myApp.dyAppPackage){

        log("———");

        sleep(2000);

        if(text("去看看").exists()){

            let b = text("去看看").findOne().bounds();

            if(b.centerX()>0&&b.centerY()>0){

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

                sleep(2000);

            }

        }else if(text("打开看看").exists()){

            let b = text("打开看看").findOne().bounds();

            if(b.centerX()>0&&b.centerY()>0){

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

                sleep(2000);

            }

        }

        //已关注

        if(isGZ()){

            log("已经关注");

            ui.run(function(){

                toastLog("已经关注");

            });

            //点击头像

            if(id("c75").exists()){

                ui.run(function(){

                    toastLog("点击头像");

                });

                let bh = id("c75").findOne().bounds();

                if(bh.centerX()>0&&bh.centerY()>0){

                    click(bh.centerX(),bh.centerY());

                    sleep(1000);

                    if(text("已关注").exists()){

                        let by = text("已关注").findOne().bounds();

                        if(by.centerX()>0&&by.centerY()>0){

                            click(by.centerX(),by.centerY());

                        }

                    }else{

                        click(100, device.height-150);

                    }

              

                    sleep(random(1500,2000));

                    if( textStartsWith("确定不再关注此人").exists()){

                        if(text("确定").exists()){

                            let bq= text("确定").findOne().bounds();

                            if(bq.centerX()>0&&bq.centerY()>0){

                                click(bq.centerX(),bq.centerY());

                                sleep(1000);

                                click(device.width-50,(device.height/2-50));

                                click(1000);

                                if(!gzZB()){

                                    sleep(1000);

                                    gzZB()

                                }

                            }

                        }

                    }

                }

            }

        }

        if(!gzZB()){

            sleep(1000);

            gzZB()

        }

        // 已经关注 ;

        // if(id("d0b").exists()){

        //     click();

        // }

        

    }

 

    //不再关注 text("确定不再关注此人").exists() ->text("确定").exists();

 

}

 

//查找任务

function findTask(){

        let  currentYXTask = 0;

        let list = text("未满").find();

        log("有任务:"+list.length);

   

        while(true){

            if(list.length>0){

                if(list[0].bounds().bottom>=(device.height*0.7)){

                    log("—>上滑动");

                    swipe(300,device.height*0.8,330,300,500);

                    list = text("未满").find();

                }else{

                    break;

                }

              

            }else{

                break;

            }

        }

        log("任务数:"+list.length);

        if(list.length>0){

            

 

            ui.run(function(){

                toastLog("有任务");

            })

            let allList = textStartsWith("任务倒计时").find();

            log("所有任务:"+allList.length);

            for(let i = 0;i<allList.length;i++){

                for(let j = 0;j<list.length;j++){

                

                    if(list[j].bounds().bottom<allList[i].bounds().top&&(list[j].bounds().bottom+100)>=allList[i].bounds().top){

                        log("位置::"+list[j].bounds().bottom);

                        log("任务所剩时间:"+allList[i].text());

 

                        let time = 0;

                        try{

                            time = allList[i].text().replace("任务倒计时","").split(":")[0];

                        }catch(err){

                            ui.run(function(){

                                toastLog("获取任务时间出现错误!");

                            });

                            continue;

                        }

                        log("任务时间:"+time);

                   

                        if(time>=myApp.taskMinTime){

                     

                            if(list[j].bounds().centerX()>0&&list[j].bounds().centerY()){

                                log("点击");

    

                               click(list[j].bounds().centerX(),list[j].bounds().centerY());

                                sleep(2000);

                                log("–>"+text("继续接单").exists());

                                if(text("继续接单").exists()){

                                    log("继续接单");

                                    let qxb = text("继续接单").findOne().bounds();

                                    if(qxb.centerX()>0&&qxb.centerY()>0){

                                        click(qxb.centerX(),qxb.centerY());

                                

                                        openZB();

                                        log("11111111111");

                                        taskRuning(time);

                                        log("11111111111");

                                        endTask();

                                        log("11111111111");

                                        fsTP();

                                        ui.run(function(){

                                            toastLog("打开直播");

                                        })

                                    }

                        

                                }if(text("领取其他任务").exists()){

                                    let lb = text("领取其他任务").findOne().bounds();

                                    if(lb.centerX()>0&&lb.centerY()>0){

                                        click(lb.centerX(),lb.centerY());

                                        sleep(2000);

                                    }

                                    continue;

                                }else{

                                    openZB();

                                    log("22222222222222");

                                    taskRuning(time);

                                    log("22222222222222");

                                    endTask();

                                    log("22222222222222");

                                    fsTP();

                                }

                                break;

                               

                            }

                        }else{

                            ui.run(function(){

                                toastLog("任务时间太短,不接了");

                            })

                            currentYXTask++;

                            if(currentYXTask>j){

                                break;

                            }

                            while(true){

                                if(list.length>currentYXTask){

                                    if(list[currentYXTask].bounds().bottom>=(device.height*0.7)){

                                        log("—>上滑动");

                                        swipe(300,device.height*0.8,330,300,500);

                                        list = text("未满").find();

                                    }else{

                                        break;

                                    }

                                  

                                }else{

                                    break;

                                }

                            }

                        }

             

                    }

                }

            }

        }

        sx();

}

 

var jsrwTabY = 0;

function start(fy){

 

    let app = launchApp(myApp.appName);

    sleep(3000);

    if(app){

        log(currentActivity());

        waitForActivity(myApp.homeActivity);

        openHome();

        

        sleep(1000);

        

        while(true){

          //  log("刷新第"+i);

            sx();

            sleep(1500);

            findTask();

            ui.run(function(){

                toastLog("休息10秒");

            })

            sleep(10000);

            ui.run(function(){

                toastLog("重新获取任务");

            })

        }

 

    }

}


喜欢 (0)