"auto";
// ===== 配置参数 =====
var TAG = "摄影师";
var REPORT_REASON = "儿童虐待";
var MAX_REPORTS = 20;
var WAIT_BETWEEN = 3000;
// ====================
function clickByRatio(xRatio, yRatio) {
var x = Math.round(device.width * xRatio);
var y = Math.round(device.height * yRatio);
click(x, y);
}
function launchApp() {
app.launchPackage("tw.nekomimi.nekogram");
sleep(3000);
}
function performSearch() {
var searchBtn = desc("搜索").findOne(2000);
if (!searchBtn) searchBtn = className("ImageView").clickable(true).findOne(2000);
if (searchBtn) { searchBtn.click(); }
else { clickByRatio(0.92, 0.05); }
sleep(1500);
var input = className("EditText").findOne(2000);
if (input) {
input.setText("#" + TAG);
sleep(1000);
var searchKey = text("搜索").findOne(1000);
if (searchKey) searchKey.click();
else press(device.width * 0.9, device.height * 0.85, 200);
}
sleep(3000);
}
function reportMessage(node) {
node.longClick();
sleep(800);
var report = text("举报").findOne(1000);
if (!report) report = textContains("Report").findOne(1000);
if (!report) { back(); return false; }
report.click();
sleep(1000);
var reason = text(REPORT_REASON).findOne(1000);
if (!reason) reason = textContains("Child Abuse").findOne(1000);
if (!reason) { back(); return false; }
reason.click();
sleep(800);
var confirm = text("确认").findOne(1000) || text("OK").findOne(1000);
if (confirm) confirm.click();
sleep(500);
var close = text("关闭").findOne(500);
if (close) close.click();
return true;
}
function main() {
launchApp();
performSearch();
var messages = className("android.view.ViewGroup").depth(10).find();
if (messages.length === 0) {
toast("未找到消息");
return;
}
var count = 0;
for (var i = 0; i < messages.length && count < MAX_REPORTS; i++) {
if (reportMessage(messages[i])) {
count++;
toast("已举报 " + count + " 条");
sleep(WAIT_BETWEEN);
}
}
toast("完成,共举报 " + count + " 条");
}
main();
回答
对不起,我已经学习的知识中不包含问题相关内容,暂时无法提供答案。如果你有Hamibot产品的其他相关问题,我会帮助你解答。