[wm_blue]无偿分享。自行分析。有偿骚扰[/wm_blue]
"ui";
importClass(android.text.TextWatcher)
let ViewIdListRegisterListener = require('./ViewIdListRegisterListener')
let viewHeight = '150px'
let textSize = '20sp'
ui.layout(
    <vertical>
        <appbar>
            <toolbar gravity="center_horizontal" title="赫兹" textSize="15" />
        </appbar>
        <Switch id="autoService" text="无障碍服务" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="10sp" />
        <horizontal>
            <text text="回复间隔:" textSize="10" textColor="#00868B" />
            <input id="jg" textSize="10" />
        </horizontal>
        <text text="回复话术:" textSize="10" textColor="#00868B" />
        <input id="one" textSize="10" />
        <input id="two" textSize="10" />
        <input id="the" textSize="10" />
        <button id="OK" bg="#4682B4" text="启动功能" textSize="20" textStyle="bold" textColor="#EE0000" />
        <text text="xxxx" textSize="15" textColor="#EE0000" />
    </vertical>
)

let storage = storages.create('UIConfigInfo')
let 需要备份和还原的控件id列表集合 = [
    ['one', 'two', 'the', 'jg',],
    ['autoService',],
]
需要备份和还原的控件id列表集合.map((viewIdList) => {
    let inputViewIdListRegisterListener = new ViewIdListRegisterListener(viewIdList, storage)
    inputViewIdListRegisterListener.registerlistener()
    inputViewIdListRegisterListener.restore()
})
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.OK.on("click", () => {
    var info = ("启动成功");
    alert(info)
    threads.start(悬浮窗)
});
function 悬浮窗() {
    var window = floaty.window(
        <vertical>
            <button id="OK" bg="#F8F8FF" textSize="15" margin="10" textColor="red" >开始运行</button>
        </vertical>
    )
    window.setPosition(5, 354)
    var thread = null;
    var setIntervalId = null
    window.OK.click(() => {
        var 开始 = window.OK.getText()
        var A = "停止运行"
        var B = "开始运行"
        if (开始 == B) {
            ui.run(function () {
                window.OK.setText("停止运行")
            });
            thread = threads.start(function () {
                try {
                    脚本()
                } catch (e) {
                    log(e)
                }
            })
        }
        else {
            if (thread) {
                thread.interrupt();
            } else {
            }
            if (setIntervalId) {
                clearInterval(setIntervalId);
                c = 0
            }
            window.OK.setText('开始运行');
            console.clear()
            console.hide()
        }
    })
    setInterval(() => { }, 3000);
}
function 脚本() {
    console.show()
    console.setPosition(160, 30)
    console.setSize(device.width / 2, device.height / 4);
    console.log("开始运行");
    t = ui.jg.getText();
    T = parseInt(t * 1000);
    msg = id("home_tab_msg").findOne(5000);
    if (msg != null) {
        log("进入消息");
        id("home_tab_msg").findOne(5000).click();
    };
    waitForActivity("com.immomo.vchat.activity.HomeActivity");
    var i = 0
    while (true) {
        log(i);
        sleep(1500);
        log("开始回复");
        number = id("session_user_name").find().length;
        log(number);
        while (true) {
            sleep(1500);
            se = id("session_user_name").findOne(5000);
            if (se != null) {
                log("开始进入");
                id("session_user_name").findOnce(i).parent().parent().parent().click();
            };
            mic = id("iv_chat_mic").findOne(2000);
            if (mic != null) {
                name = id("tv_chat_name").findOne(5000).text();
                log("开始回复" + name);
                文件 = "/sdcard/发送信息数量/" + name + ".txt";
                log(文件);
                存在否 = files.exists(文件)
                log(存在否);
                if (存在否 == false) {
                    log("创建文本")
                    files.write(文件, "1");
                };
                sleep(1500);
                var x = files.read(文件)
                sleep(1500)
                log(x);
                if (x == 1) {
                    log("第一次回复");
                    log("休息" + t + "秒")
                    sleep(T);
                    文字回复();
                    files.write(文件, "2");
                };
                if (x == 2) {
                    log("已经回复过" + name);
                    back = id("iv_common_back").findOne(5000);
                    if (back != null) {
                        log("返回");
                        sleep(800);
                        id("iv_common_back").findOne(5000).click();
                    };
                };
            } else {
                log("返回");
                back = id("iv_common_back").findOne(5000);
                if (back != null) {
                    log("返回");
                    sleep(800);
                    id("iv_common_back").findOne(5000).click();
                };
            };
            i++;
            if (i == number) {
                i = 0
                log("开始下翻");
                sleep(1000);
                D = scrollDown();
                break;
            };
        };
    };
};
function 文字回复() {
    var 一 = ui.one.getText();
    var 二 = ui.two.getText();
    var 三 = ui.the.getText();
    var 数组 = new Array(一, 二, 三);
    随机 = random(0, 数组.length - 1);
    log(数组[随机])
    sleep(1000);
    setText(数组[随机]);
    id("tv_room_send").waitFor();
    send = id("tv_room_send").findOne(5000);
    if (send != null) {
        log("发送");
        sleep(600);
        id("tv_room_send").findOne(5000).click();
    };
    back = id("iv_common_back").findOne(5000);
    if (back != null) {
        log("返回");
        sleep(800);
        id("iv_common_back").findOne(5000).click();
    };
};

发表评论

后才能评论