feat: init
This commit is contained in:
139
boot/main.js
Normal file
139
boot/main.js
Normal file
@@ -0,0 +1,139 @@
|
||||
auto.waitFor();
|
||||
|
||||
const deviceID = device.getAndroidId()
|
||||
log(`设备号 ${deviceID}`);
|
||||
|
||||
let e = null;
|
||||
let canAutoRun = false;
|
||||
|
||||
let CheckVersion = function () {
|
||||
log("检查更新")
|
||||
let version = "0.0.0"
|
||||
if (files.isFile("version.txt")) {
|
||||
version = files.read("version.txt");
|
||||
version = version.trim()
|
||||
}
|
||||
|
||||
let store = storages.create("_##_@_DY_Proxy");
|
||||
let host = store.get("__host", "")
|
||||
if (host.length == 0) {
|
||||
host = "https://f.jdwan.com"
|
||||
}
|
||||
|
||||
let url = "{host}/api/version"
|
||||
url = url.replace("{host}", host)
|
||||
log("url =", url)
|
||||
|
||||
let headers = {
|
||||
headers: {
|
||||
"Authorization": "Basic cm9nZWVjbjp4aXhpQDAyMDI="
|
||||
}
|
||||
}
|
||||
try {
|
||||
let resp = http.get(url, headers)
|
||||
if (resp.statusCode != 200) {
|
||||
log("更新请求失败, statusCode: ", resp.statusCode)
|
||||
canAutoRun = true
|
||||
return false
|
||||
}
|
||||
|
||||
let body = resp.body.json()
|
||||
if (body == null) {
|
||||
log("没有新的数据")
|
||||
canAutoRun = true
|
||||
return false
|
||||
}
|
||||
|
||||
if (body.version == version) {
|
||||
canAutoRun = true
|
||||
return false
|
||||
}
|
||||
log(`有新版本 ${body.version} 当前版本: ${version}, 开始更新`)
|
||||
|
||||
|
||||
if (e && !e.getEngine().isDestroyed()) {
|
||||
canAutoRun = false
|
||||
e.getEngine().forceStop()
|
||||
}
|
||||
|
||||
body.files.forEach((file, index) => {
|
||||
log("下载文件: ( " + (index + 1) + " / " + body.files.length + ")" + file)
|
||||
let url = "{host}/api/version/file/{file}"
|
||||
url = url.replace("{host}", host).replace("{file}", file)
|
||||
|
||||
let resp = http.get(url, headers)
|
||||
if (resp.statusCode != 200) {
|
||||
log(`下载文件(${file})失败, statusCode: ${resp.statusCode}`)
|
||||
return
|
||||
}
|
||||
|
||||
let path = files.path(file)
|
||||
files.createWithDirs(path)
|
||||
files.writeBytes(path, resp.body.bytes())
|
||||
})
|
||||
} catch (e) {
|
||||
log("更新请求失败, ", e)
|
||||
canAutoRun = true
|
||||
return false
|
||||
}
|
||||
|
||||
canAutoRun = true
|
||||
log("更新完成")
|
||||
return true
|
||||
}
|
||||
|
||||
events.on("exit", function () {
|
||||
log("结束运行");
|
||||
if (e && !e.getEngine().isDestroyed()) {
|
||||
canAutoRun = false
|
||||
e.getEngine().forceStop()
|
||||
}
|
||||
});
|
||||
|
||||
CheckVersion()
|
||||
setInterval(CheckVersion, 60 * 1000)
|
||||
|
||||
setInterval(() => {
|
||||
let activity = currentActivity()
|
||||
if ("com.ss.android.ugc.aweme.update.dialog.ui.UpdateNotifyDialog" == activity) {
|
||||
let btn = text("以后再说").findOne(500)
|
||||
if (btn) {
|
||||
btn.click()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ("com.ss.android.ugc.aweme.account.business.logout.LogoutDialogActivity" == activity) {
|
||||
// todo: 退出登录
|
||||
let btn = text("我知道了").findOne(500)
|
||||
if (btn) {
|
||||
btn.click()
|
||||
}
|
||||
}
|
||||
|
||||
if ("com.bytedance.dux.dialog.alert.DuxAlertDialog" == activity) {
|
||||
let btn = text("拒绝").findOne(500)
|
||||
if (btn) {
|
||||
btn.click()
|
||||
}
|
||||
}
|
||||
|
||||
}, 1000)
|
||||
|
||||
setInterval(() => {
|
||||
if (!canAutoRun) {
|
||||
return
|
||||
}
|
||||
|
||||
if (e && !e.getEngine().isDestroyed()) {
|
||||
return
|
||||
}
|
||||
|
||||
let path = files.path("runner.js");
|
||||
log("runner", path);
|
||||
log("开始执行脚本");
|
||||
e = engines.execScriptFile(path, {
|
||||
loopTimes: 1,
|
||||
path: files.path("./"),
|
||||
});
|
||||
}, 2000)
|
||||
59
boot/project.json
Normal file
59
boot/project.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"abis": [
|
||||
"arm64-v8a",
|
||||
"armeabi-v7a",
|
||||
"x86",
|
||||
"x86_64"
|
||||
],
|
||||
"assets": [
|
||||
{
|
||||
"form": "/storage/emulated/0/脚本/autojs/boot",
|
||||
"to": "/project"
|
||||
}
|
||||
],
|
||||
"buildDir": "build",
|
||||
"build": {
|
||||
"build_id": null,
|
||||
"build_number": 0,
|
||||
"build_time": 0
|
||||
},
|
||||
"useFeatures": [],
|
||||
"icon": "res/logo.png",
|
||||
"ignoredDirs": [
|
||||
"build"
|
||||
],
|
||||
"encrypt-code": false,
|
||||
"launchConfig": {
|
||||
"displaySplash": true,
|
||||
"hideAccessibilityServices": false,
|
||||
"hideLauncher": false,
|
||||
"hideLogs": false,
|
||||
"stableMode": false,
|
||||
"volumeUpcontrol": true,
|
||||
"permissions": [
|
||||
"accessibility_services",
|
||||
"background_start",
|
||||
"draw_overlay"
|
||||
],
|
||||
"serviceDesc": "自动操作",
|
||||
"splashIcon": "res/splashIcon.png",
|
||||
"splashText": "请合理使用"
|
||||
},
|
||||
"libs": [
|
||||
"libjackpal-androidterm5.so",
|
||||
"libjackpal-termexec2.so"
|
||||
],
|
||||
"main": "main.js",
|
||||
"name": "PowerBank",
|
||||
"outputPath": "/storage/emulated/0/脚本/autojs/boot/build",
|
||||
"packageName": "com.power.bank",
|
||||
"projectDirectory": "/storage/emulated/0/脚本/autojs/boot",
|
||||
"scripts": {},
|
||||
"signingConfig": {
|
||||
"alias": null,
|
||||
"keystore": null
|
||||
},
|
||||
"sourcePath": "/storage/emulated/0/脚本/autojs/boot/main.js",
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0.0"
|
||||
}
|
||||
BIN
boot/res/logo.png
Normal file
BIN
boot/res/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
boot/res/splashIcon.png
Normal file
BIN
boot/res/splashIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user