auto.waitFor()
setScreenMetrics(1080, 2160);
main();
function main() {
while (true) {
var comment = id('commentContent').untilFindOne();
console.log("开始删除评论:" + comment.text());
//点击评论
while (true) {
if (comment.visibleToUser() == true) {
click(comment.centerX(), comment.centerY());
console.log("点击评论:" + comment.centerX() + "," + comment.centerY());
break;
}
console.log("评论不可见");
swipe(comment.centerX(), comment.parent().bounds().bottom, comment.centerX(), comment.parent().bounds().top, 300);
comment = id('commentContent').untilFindOne();
}
sleep(1000);
let mode = showup_delete_btn(comment.text());
sleep(1000);
delete_btn(mode);
sleep(1500);
back();
sleep(1000);
console.log(comment.parent().bounds().bottom);
swipe(comment.centerX(), comment.parent().bounds().bottom, comment.centerX(), comment.parent().bounds().top, 300);
sleep(1500);
}
}
function showup_delete_btn(content) {
// 长按唤出删除按钮
var flag = true;
while (true) {
if (content) {
var c = textContains(content).untilFindOne();
sleep(300);
console.log(c.visibleToUser());
// 检查控件位置是否在屏幕内
var bounds = c.bounds();
// var actually_y = id("editBlock").untilFindOne().bounds().top;
let actually_y=1895;
console.log("实际y坐标:" + actually_y);
if (bounds.top >= 0 && bounds.bottom <= actually_y && bounds.left >= 0 && bounds.right <= device.width) {
if (c.visibleToUser() == true) {
console.log("找到评论或回复,准备删除");
let x = get_delete_mode();
console.log(c.centerX(), c.centerY());
press(c.centerX(), c.centerY(), 1000);
// flag = true;
return x;
} else {
console.log("控件位置不在屏幕内");
console.log("flag:" + flag);
if (flag) {
// 滑动至顶部
swipe(540, 500, 540, 1500, 300);
flag = false;
} else {
// 下滑
swipe(540, 900, 540, 500, 200);
}
}
} else {
console.log("控件位置不在屏幕内");
console.log("flag:" + flag);
if (flag) {
// 滑动至顶部
swipe(540, 500, 540, 1500, 300);
flag = false;
} else {
// 下滑
swipe(540, 900, 540, 500, 200);
}
}
} else {
var target = text("当前评论").findOnce() || text("当前回复").findOnce();
if (target) {
console.log("找到评论或回复,准备删除");
press(target.centerX(), target.centerY() + 200, 1000);
return 0;
}
}
sleep(1000);
}
}
function get_delete_mode() {
// 如果没有当前评论或当前回复,则删除按钮的位置会偏移
var t = text("当前评论").findOnce() || text("当前回复").findOnce();
if (t) {
return 0;
} else {
return 1;
}
}
function delete_btn(mode) {
// 点击删除按钮
var delete_btn = text("删除").untilFindOne();
var x;
if (mode == 0) {
x = delete_btn.centerX();
} else if (mode == 1) {
x = delete_btn.centerX() + 150;
// x = delete_btn.centerX();
}
console.log(x, delete_btn.centerY());
click(x, delete_btn.centerY());
sleep(400);
}
function back() {
// 返回
console.log("返回");
// desc('转到上一层级').untilFindOne().click();
click(82,137);
}
清除网易云历史评论
最新推荐文章于 2025-09-07 14:04:51 发布
810

被折叠的 条评论
为什么被折叠?



