高级配方
约 226 字小于 1 分钟
高级配方
HTTP 调试入口
httpServer.start({
port: 18765,
allowLan: false,
token: "demo-token"
});
httpServer.get("/state", req => {
return {
status: 200,
mimeType: "application/json; charset=utf-8",
body: JSON.stringify({
packageName: req.packageName,
processName: req.processName,
activity: String(activity)
})
};
});
DexKit 查类
const bridge = openDexKit("/sdcard/Download/base.apk");
const result = bridge.findClass(
FindClass.create().matcher(
ClassMatcher.create().className("Login", StringMatchType.Contains)
)
);
log(JSON.stringify(result));
ImGui 调试面板
const state = imgui.reactive({ enabled: true });
const panel = imgui.window("debug-panel", {
title: "ScriptX Debug",
width: 360,
height: 520,
displayMode: "in_app",
collapsible: true,
secure: false
});
panel.text("包名: " + lpparam.packageName);
panel.text("进程: " + lpparam.processName);
panel.checkbox("启用调试", imgui.bind(state, "enabled"));
panel.button("打印 Activity 字段", function () {
printFields(activity, "\n");
});
panel.show();
文件与存储
const store = storages.create("demo");
const logPath = files.join(files.cwd(), "logs/runtime.txt");
files.ensureDir(files.join(files.cwd(), "logs/"));
files.append(logPath, `${Date.now()} boot\n`);
store.put("lastLogPath", logPath);
设备信息与唤醒
log(`${device.brand} ${device.model} sdk=${device.sdkInt}`);
if (!device.isScreenOn()) {
device.wakeUp();
}
device.vibrate(60);
MCP Tool
mcpServer.start({
port: 5698,
endpoint: "/mcp",
token: "secret-token"
});
mcpServer.tool("current_context", {
title: "Current Context",
description: "Return package and process info",
inputSchema: {
type: "object",
properties: {}
}
}, () => {
return {
content: [
{
type: "text",
text: JSON.stringify({
packageName: lpparam.packageName,
processName: lpparam.processName
})
}
]
};
});
这些配方更适合当“调试脚手架”,先跑起来,再逐步替换成你自己的业务逻辑。
