|
|
|
|
var window = floaty.window(
|
|
|
|
|
<frame bg="#88000000" w="80" h="300">
|
|
|
|
|
<vertical padding="1">
|
|
|
|
|
<button id="ok1" text="随机进入一个直播间" textSize="8" h="40" />
|
|
|
|
|
<button id="ok3" text="自动切换直播间,点赞关注" textSize="8" h="40" />
|
|
|
|
|
<button id="ok4" text="设置点赞数量和速度" textSize="8" h="40" />
|
|
|
|
|
<button id="ok5" text="实现静态评论" textSize="8" h="40" />
|
|
|
|
|
<button id="ok6" text="实现动态评论" textSize="8" h="40" />
|
|
|
|
|
<button id="ok2" text="自动发帖" textSize="8" h="40" />
|
|
|
|
|
<button id="closee" text="关闭" textSize="8" h="40" />
|
|
|
|
|
</vertical>
|
|
|
|
|
</frame>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.setPosition(800, 150);
|
|
|
|
|
window.closee.click(()=>{
|
|
|
|
|
window.close();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 随机进入直播间
|
|
|
|
|
function enterRandomLive() {
|
|
|
|
|
sleep(2000);
|
|
|
|
|
swipe(500, 1200, 500, 1320, 700); // 从下往上滑动
|
|
|
|
|
var zhibo = desc("直播").findOne(); // 使用 findOne 方法查找控件
|
|
|
|
|
bounds = zhibo.bounds();
|
|
|
|
|
click(bounds.left + 50, bounds.top + 50);
|
|
|
|
|
sleep(3000);
|
|
|
|
|
click(337, 800);
|
|
|
|
|
sleep(2000);
|
|
|
|
|
toast("打开直播间");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动滑屏点赞关注
|
|
|
|
|
function autoLikeAndFollow() {
|
|
|
|
|
function doubleClick(x, y) {
|
|
|
|
|
click(x, y);
|
|
|
|
|
sleep(20);
|
|
|
|
|
click(x, y);
|
|
|
|
|
sleep(20);
|
|
|
|
|
click(x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var q = 3;
|
|
|
|
|
for (var i = 0; i < q; i++) {
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
|
doubleClick(500, 1300);
|
|
|
|
|
sleep(100);
|
|
|
|
|
}
|
|
|
|
|
sleep(1000);
|
|
|
|
|
|
|
|
|
|
var guanzhu = id("c8z").findOne();
|
|
|
|
|
// 获取关注按钮的边界
|
|
|
|
|
var bounds = guanzhu.bounds();
|
|
|
|
|
// 点击关注按钮的中心点
|
|
|
|
|
click(bounds.right + 70, bounds.top + 30);
|
|
|
|
|
console.log("关注成功");
|
|
|
|
|
|
|
|
|
|
// 等待1秒
|
|
|
|
|
sleep(1000);
|
|
|
|
|
// 向上滑动屏幕
|
|
|
|
|
swipe(500, 1700, 500, 400, 400);
|
|
|
|
|
// 等待4秒
|
|
|
|
|
sleep(4000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置点赞数量和速度
|
|
|
|
|
function setLike() {
|
|
|
|
|
// 确保无障碍服务已开启
|
|
|
|
|
auto.waitFor();
|
|
|
|
|
|
|
|
|
|
// 定义小红书包名
|
|
|
|
|
var packageName = "com.xingin.xhs";
|
|
|
|
|
|
|
|
|
|
// 创建悬浮窗
|
|
|
|
|
var window = floaty.window(
|
|
|
|
|
<frame gravity="center" bg="#88000000">
|
|
|
|
|
<vertical padding="10">
|
|
|
|
|
<text text="直播点赞控制" textColor="#ffffff" textSize="16sp" />
|
|
|
|
|
<input id="countInput" hint="点赞次数(默认无上限)" textColor="#ffffff" textSize="14sp" focusable="true" />
|
|
|
|
|
<input id="speedInput" hint="点赞间隔ms(默认200)" textColor="#ffffff" textSize="14sp" focusable="true" />
|
|
|
|
|
<horizontal>
|
|
|
|
|
<button id="start" text="开始" w="80" h="40" />
|
|
|
|
|
<button id="pause" text="暂停" w="80" h="40" />
|
|
|
|
|
<button id="ok" text="确定" w="80" h="40" />
|
|
|
|
|
<button id="exit" text="退出" w="80" h="40" />
|
|
|
|
|
</horizontal>
|
|
|
|
|
<text id="status" text="状态:等待开始" textColor="#ffffff" textSize="14sp" />
|
|
|
|
|
<text id="counter" text="已点赞:0" textColor="#ffffff" textSize="14sp" />
|
|
|
|
|
</vertical>
|
|
|
|
|
</frame>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 设置悬浮窗位置
|
|
|
|
|
window.setPosition(50, 100);
|
|
|
|
|
|
|
|
|
|
// 初始化变量
|
|
|
|
|
var isRunning = false;
|
|
|
|
|
var isPaused = false;
|
|
|
|
|
var clickCount = 0;
|
|
|
|
|
var targetCount = 1000;
|
|
|
|
|
var clickInterval = 200;
|
|
|
|
|
var clickThread = null;
|
|
|
|
|
var dd = 0;
|
|
|
|
|
|
|
|
|
|
// 输入框事件处理
|
|
|
|
|
function setupInput(windowInput) {
|
|
|
|
|
windowInput.on("key", function (keyCode, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_DOWN && keyCode == keys.back) {
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
event.consumed = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
windowInput.on("touch_down", () => {
|
|
|
|
|
window.requestFocus();
|
|
|
|
|
windowInput.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setupInput(window.countInput);
|
|
|
|
|
setupInput(window.speedInput);
|
|
|
|
|
|
|
|
|
|
// 确定按钮事件
|
|
|
|
|
window.ok.on("click", () => {
|
|
|
|
|
let input1Content = window.countInput.getText();
|
|
|
|
|
let input2Content = window.speedInput.getText();
|
|
|
|
|
if (input1Content == "") input1Content = 1000;
|
|
|
|
|
if (input2Content == "") input2Content = 200;
|
|
|
|
|
targetCount = parseInt(input1Content);
|
|
|
|
|
clickInterval = parseInt(input2Content);
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
|
|
|
|
|
dd = (dd == 0 ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
log("点赞次数: " + targetCount);
|
|
|
|
|
log("点赞间隔: " + clickInterval);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 双击函数
|
|
|
|
|
function doubleClick(x, y) {
|
|
|
|
|
click(x, y);
|
|
|
|
|
sleep(20);
|
|
|
|
|
click(x, y);
|
|
|
|
|
sleep(20);
|
|
|
|
|
click(x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 开始按钮事件
|
|
|
|
|
window.start.click(() => {
|
|
|
|
|
if (!isRunning) {
|
|
|
|
|
isRunning = true;
|
|
|
|
|
isPaused = false;
|
|
|
|
|
window.start.setText("停止");
|
|
|
|
|
|
|
|
|
|
// 启动点赞线程
|
|
|
|
|
clickThread = threads.start(function () {
|
|
|
|
|
while (isRunning) {
|
|
|
|
|
if (!isPaused) {
|
|
|
|
|
try {
|
|
|
|
|
// 执行点赞
|
|
|
|
|
doubleClick(500, 1300);
|
|
|
|
|
clickCount++;
|
|
|
|
|
|
|
|
|
|
// 更新计数器
|
|
|
|
|
ui.run(() => {
|
|
|
|
|
window.counter.setText("已点赞:" + clickCount);
|
|
|
|
|
window.status.setText("状态:正在点赞");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 控制点赞间隔
|
|
|
|
|
sleep(clickInterval);
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
toast("错误: " + e);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sleep(100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// 停止点赞
|
|
|
|
|
isRunning = false;
|
|
|
|
|
window.start.setText("开始");
|
|
|
|
|
window.status.setText("状态:已停止");
|
|
|
|
|
if (clickThread != null) {
|
|
|
|
|
clickThread.interrupt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 暂停按钮事件
|
|
|
|
|
window.pause.click(() => {
|
|
|
|
|
if (isRunning) {
|
|
|
|
|
isPaused = !isPaused;
|
|
|
|
|
window.pause.setText(isPaused ? "继续" : "暂停");
|
|
|
|
|
window.status.setText("状态:" + (isPaused ? "已暂停" : "正在点赞"));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 退出按钮事件
|
|
|
|
|
window.exit.on("click", () => {
|
|
|
|
|
window.close();
|
|
|
|
|
//exit(); // 退出脚本
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 启动小红书并进入直播间
|
|
|
|
|
function startXiaohongshu() {
|
|
|
|
|
app.launchPackage(packageName);
|
|
|
|
|
toast("小红书已打开");
|
|
|
|
|
|
|
|
|
|
sleep(3000);
|
|
|
|
|
swipe(500, 1200, 500, 1320, 700);
|
|
|
|
|
|
|
|
|
|
let zhibo = desc("直播").findOne();
|
|
|
|
|
if (zhibo) {
|
|
|
|
|
let bounds = zhibo.bounds();
|
|
|
|
|
click(bounds.left + 50, bounds.top + 50);
|
|
|
|
|
sleep(3000);
|
|
|
|
|
click(337, 800);
|
|
|
|
|
sleep(2000);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 启动应用
|
|
|
|
|
if (startXiaohongshu()) {
|
|
|
|
|
toast("已进入直播间,请调整点赞参数");
|
|
|
|
|
} else {
|
|
|
|
|
toast("进入直播间失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保持脚本运行
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
if (!auto.service) {
|
|
|
|
|
toast("无障碍服务已关闭!");
|
|
|
|
|
isRunning = false;
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 实现静态评论
|
|
|
|
|
function StaticComments() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 请求无障碍权限
|
|
|
|
|
auto.waitFor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义静态评论数组
|
|
|
|
|
const staticComments = [
|
|
|
|
|
"主播好专业,讲解很细致",
|
|
|
|
|
"分享很实用,收获满满",
|
|
|
|
|
"主播声音真好听",
|
|
|
|
|
"今天的直播太精彩了",
|
|
|
|
|
"支持你,继续加油",
|
|
|
|
|
"这个观点说得太对了",
|
|
|
|
|
"学到了很多,谢谢分享",
|
|
|
|
|
"主播真是太有耐心了",
|
|
|
|
|
"这个内容很有价值",
|
|
|
|
|
"讲解很通俗易懂",
|
|
|
|
|
"主播气质真好",
|
|
|
|
|
"解答得很专业",
|
|
|
|
|
"知识点很干货",
|
|
|
|
|
"终于等到你的直播了",
|
|
|
|
|
"每次看直播都有收获",
|
|
|
|
|
"主播太用心了",
|
|
|
|
|
"点赞主播的敬业精神",
|
|
|
|
|
"这个主题很有意思",
|
|
|
|
|
"希望能多做这样的分享",
|
|
|
|
|
"感谢主播的分享"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 动态评论生成函数
|
|
|
|
|
function generateDynamicComment() {
|
|
|
|
|
const templates = [
|
|
|
|
|
"现在是%s,直播真精彩",
|
|
|
|
|
"打卡第%d次,继续支持",
|
|
|
|
|
"已经看了%d分钟,太棒了",
|
|
|
|
|
"第%d次来看直播,越来越好"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const template = templates[Math.floor(Math.random() * templates.length)];
|
|
|
|
|
const now = new Date();
|
|
|
|
|
const timeStr = now.getHours() + ':' + now.getMinutes();
|
|
|
|
|
const count = Math.floor(Math.random() * 100) + 1;
|
|
|
|
|
|
|
|
|
|
return template.replace(/%s/, timeStr).replace(/%d/, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let usedComments = new Set();
|
|
|
|
|
|
|
|
|
|
// 获取未使用过的随机评论
|
|
|
|
|
function getUniqueComment() {
|
|
|
|
|
// 如果所有评论都已使用过,则重置记录
|
|
|
|
|
if (usedComments.size >= staticComments.length) {
|
|
|
|
|
usedComments.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取未使用过的评论
|
|
|
|
|
let availableComments = staticComments.filter(comment => !usedComments.has(comment));
|
|
|
|
|
let selectedComment = availableComments[Math.floor(Math.random() * availableComments.length)];
|
|
|
|
|
|
|
|
|
|
// 记录已使用的评论
|
|
|
|
|
usedComments.add(selectedComment);
|
|
|
|
|
return selectedComment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function findCommentBox() {
|
|
|
|
|
// 方法1: 通过ID查找
|
|
|
|
|
let commentBox = id("comment_input_container").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法2: 通过文本内容查找
|
|
|
|
|
commentBox = textContains("说点什么").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法3: 通过描述查找
|
|
|
|
|
commentBox = desc("评论输入框").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法4: 通过类名查找底部评论区域
|
|
|
|
|
commentBox = className("android.widget.EditText").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法5: 尝试查找底部评论图标
|
|
|
|
|
let commentIcon = desc("评论").findOne(1000) || text("评论").findOne(1000);
|
|
|
|
|
if (commentIcon) {
|
|
|
|
|
commentIcon.click();
|
|
|
|
|
sleep(1000);
|
|
|
|
|
return className("android.widget.EditText").findOne(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查找发送按钮的多种方法
|
|
|
|
|
function findSendButton() {
|
|
|
|
|
// 方法1: 通过文本查找
|
|
|
|
|
let sendBtn = text("发送").findOne(1000);
|
|
|
|
|
if (sendBtn) return sendBtn;
|
|
|
|
|
|
|
|
|
|
// 方法2: 通过描述查找
|
|
|
|
|
sendBtn = desc("发送").findOne(1000);
|
|
|
|
|
if (sendBtn) return sendBtn;
|
|
|
|
|
|
|
|
|
|
// 方法3: 通过ID查找
|
|
|
|
|
sendBtn = id("send_button").findOne(1000);
|
|
|
|
|
if (sendBtn) return sendBtn;
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 主功能函数
|
|
|
|
|
function autoComment() {
|
|
|
|
|
// 等待进入直播间
|
|
|
|
|
sleep(5000);
|
|
|
|
|
|
|
|
|
|
// 循环发送评论
|
|
|
|
|
for(let i=0;i<5; i++){
|
|
|
|
|
try {
|
|
|
|
|
// 获取一条未使用过的评论
|
|
|
|
|
let comment = getUniqueComment();
|
|
|
|
|
// 查找评论框
|
|
|
|
|
let commentBox = findCommentBox();
|
|
|
|
|
if (!commentBox) {
|
|
|
|
|
toast("未找到评论框,重试中...");
|
|
|
|
|
sleep(2000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
console.log("找到评论框");
|
|
|
|
|
toast("找到评论框");
|
|
|
|
|
// 点击评论框
|
|
|
|
|
commentBox.click();
|
|
|
|
|
sleep(500);
|
|
|
|
|
|
|
|
|
|
// 输入评论
|
|
|
|
|
setText(comment);
|
|
|
|
|
sleep(500);
|
|
|
|
|
|
|
|
|
|
// 点击发送按钮
|
|
|
|
|
let sendBtn = findSendButton();
|
|
|
|
|
if (sendBtn) {
|
|
|
|
|
sendBtn.click();
|
|
|
|
|
toast("评论发送成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
toast("未找到发送按钮");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 随机等待1-2秒
|
|
|
|
|
sleep(random(1000, 2000));
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("评论发送失败:" + e);
|
|
|
|
|
sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 安全退出函数
|
|
|
|
|
function exitScript() {
|
|
|
|
|
toast("脚本已停止运行");
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置退出监听
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
// 监听音量下键停止脚本
|
|
|
|
|
events.observeKey();
|
|
|
|
|
events.onKeyDown("volume_down", function (event) {
|
|
|
|
|
exitScript();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 主程序
|
|
|
|
|
try {
|
|
|
|
|
toast('Hello, AutoX.js');
|
|
|
|
|
// 等待打开小红书
|
|
|
|
|
app.launchApp("小红书");
|
|
|
|
|
sleep(5000);
|
|
|
|
|
|
|
|
|
|
// 等待进入直播间
|
|
|
|
|
toast("请手动进入任意直播间,然后脚本会自动开始发送评论");
|
|
|
|
|
toast("按音量下键可停止脚本运行");
|
|
|
|
|
|
|
|
|
|
// 开始自动评论
|
|
|
|
|
autoComment();
|
|
|
|
|
|
|
|
|
|
toast('end, AutoX.js');
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("脚本运行错误:" + e);
|
|
|
|
|
exitScript();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 实现动态评论
|
|
|
|
|
function FeedComments() {
|
|
|
|
|
|
|
|
|
|
//2 点赞悬浮窗
|
|
|
|
|
var window = floaty.window(
|
|
|
|
|
<vertical>
|
|
|
|
|
<input id="input3" hint="请输入评论" textSize="16sp" focusable="true" />
|
|
|
|
|
<input id="input4" hint="评论次数" textSize="16sp" focusable="true" />
|
|
|
|
|
<button id="remarkBtn" text="开始评论" />
|
|
|
|
|
<button id="closeBtn" text="关闭悬浮窗" />
|
|
|
|
|
</vertical>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var dd = 0;
|
|
|
|
|
var state = 0;
|
|
|
|
|
var Static = 0;
|
|
|
|
|
var screenWidth = device.width;
|
|
|
|
|
var screenHeight = device.height;
|
|
|
|
|
var centerX = screenWidth / 2;
|
|
|
|
|
var centerY = screenHeight / 2;
|
|
|
|
|
var commentText = "";
|
|
|
|
|
var remarkCounter = 0;
|
|
|
|
|
|
|
|
|
|
// 设置悬浮窗位置
|
|
|
|
|
window.setPosition(device.width / 2 + 50, 50);
|
|
|
|
|
|
|
|
|
|
// 设置悬浮窗可调整位置
|
|
|
|
|
window.setAdjustEnabled(true);
|
|
|
|
|
|
|
|
|
|
toast("长按可调整悬浮窗位置");
|
|
|
|
|
|
|
|
|
|
// 处理输入框焦点,使键盘可以弹出
|
|
|
|
|
window.input3.on("touch_down", () => {
|
|
|
|
|
window.requestFocus();
|
|
|
|
|
window.input3.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.input4.on("touch_down", () => {
|
|
|
|
|
window.requestFocus();
|
|
|
|
|
window.input4.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 点击开始评论按钮
|
|
|
|
|
window.remarkBtn.on("click", () => {
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
commentText = window.input3.getText() + "";
|
|
|
|
|
remarkCounter = parseInt(window.input4.getText());
|
|
|
|
|
|
|
|
|
|
if (commentText == "") {
|
|
|
|
|
commentText = "666";
|
|
|
|
|
}
|
|
|
|
|
if (isNaN(remarkCounter) || remarkCounter < 1) {
|
|
|
|
|
remarkCounter = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log("评论内容: " + commentText);
|
|
|
|
|
log("评论次数: " + remarkCounter);
|
|
|
|
|
state = 1;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 关闭悬浮窗
|
|
|
|
|
window.closeBtn.on("click", () => {
|
|
|
|
|
window.close();
|
|
|
|
|
//exit();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 查找评论框的多种方法
|
|
|
|
|
function findCommentBox() {
|
|
|
|
|
// 方法1: 通过ID查找
|
|
|
|
|
let commentBox = id("comment_input_container").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法2: 通过文本内容查找
|
|
|
|
|
commentBox = textContains("说点什么").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法3: 通过描述查找
|
|
|
|
|
commentBox = desc("评论输入框").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法4: 通过类名查找底部评论区域
|
|
|
|
|
commentBox = className("android.widget.EditText").findOne(1000);
|
|
|
|
|
if (commentBox) return commentBox;
|
|
|
|
|
|
|
|
|
|
// 方法5: 尝试查找底部评论图标
|
|
|
|
|
let commentIcon = desc("评论").findOne(1000) || text("评论").findOne(1000);
|
|
|
|
|
if (commentIcon) {
|
|
|
|
|
commentIcon.click();
|
|
|
|
|
sleep(1000);
|
|
|
|
|
return className("android.widget.EditText").findOne(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查找发送按钮的多种方法
|
|
|
|
|
function findSendButton() {
|
|
|
|
|
// 方法1: 通过文本查找
|
|
|
|
|
let sendBtn = text("发送").findOne(1000);
|
|
|
|
|
if (sendBtn) return sendBtn;
|
|
|
|
|
|
|
|
|
|
// 方法2: 通过描述查找
|
|
|
|
|
sendBtn = desc("发送").findOne(1000);
|
|
|
|
|
if (sendBtn) return sendBtn;
|
|
|
|
|
|
|
|
|
|
// 方法3: 通过ID查找
|
|
|
|
|
sendBtn = id("send_button").findOne(1000);
|
|
|
|
|
if (sendBtn) return sendBtn;
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 自动评论主循环
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
if (state == 1) {
|
|
|
|
|
let commentBox = findCommentBox();
|
|
|
|
|
if (commentBox) {
|
|
|
|
|
commentBox.click();
|
|
|
|
|
state = 2;
|
|
|
|
|
} else {
|
|
|
|
|
toast("未找到评论框,重试中...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (state == 2) {
|
|
|
|
|
setText(commentText);
|
|
|
|
|
state = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (state == 3) {
|
|
|
|
|
let sendBtn = findSendButton();
|
|
|
|
|
if (sendBtn) {
|
|
|
|
|
sendBtn.click();
|
|
|
|
|
toast("评论发送成功");
|
|
|
|
|
remarkCounter--;
|
|
|
|
|
if (remarkCounter <= 0) {
|
|
|
|
|
state = 0;
|
|
|
|
|
} else {
|
|
|
|
|
state = 1;
|
|
|
|
|
sleep(5000); // 评论间隔5秒
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
toast("未找到发送按钮");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
toast('脚本已启动');
|
|
|
|
|
// 等待打开小红书
|
|
|
|
|
app.launchApp("小红书");
|
|
|
|
|
sleep(5000);
|
|
|
|
|
|
|
|
|
|
// 等待进入直播间
|
|
|
|
|
toast("请手动进入直播间,然后在悬浮窗输入评论内容和次数");
|
|
|
|
|
toast("点击开始评论按钮开始自动评论");
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("脚本运行错误:" + e);
|
|
|
|
|
window.close();
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function autoSendPost() {
|
|
|
|
|
// 在这里添加自动发送帖子的代码
|
|
|
|
|
// 定义自动输入文字的函数
|
|
|
|
|
function autoInputText() {
|
|
|
|
|
let postContent = "这是一个自动发帖的内容,由脚本自动生成。";
|
|
|
|
|
let editText = className("android.widget.EditText").findOne(10000);
|
|
|
|
|
if (editText) {
|
|
|
|
|
editText.setText(postContent);
|
|
|
|
|
sleep(1000);
|
|
|
|
|
log("自动输入文字成功");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到文本输入框");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//定义手动输入文字的函数
|
|
|
|
|
function manualInputText() {
|
|
|
|
|
let postContent = rawInput("请输入您的文本", "您可以自定义文本");
|
|
|
|
|
let editText = className("android.widget.EditText").findOne(10000);
|
|
|
|
|
if (editText) {
|
|
|
|
|
log("请手动输入文字,并在完成后点击确定");
|
|
|
|
|
// waitForConfirm(); // 等待用户确认
|
|
|
|
|
editText.setText(postContent);
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到文本输入框");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击加号按钮
|
|
|
|
|
function clickAddButton() {
|
|
|
|
|
let addButton = id("dzq").findOne(1000);
|
|
|
|
|
if (addButton) {
|
|
|
|
|
// 获取addButton的父元素,并触发点击事件
|
|
|
|
|
addButton.click();
|
|
|
|
|
sleep(3000);
|
|
|
|
|
log("加号按钮点击成功");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到加号按钮");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击“文字”选项
|
|
|
|
|
function clickTextOption() {
|
|
|
|
|
let textOption = id("bgf").className("android.widget.TextView").text("文字").findOne(1000).parent();
|
|
|
|
|
if (textOption) {
|
|
|
|
|
textOption.click();
|
|
|
|
|
sleep(2000);
|
|
|
|
|
log("文字选项点击成功");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到文字选项");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击“发文字笔记讨论”
|
|
|
|
|
function clickTextNoteDiscussion() {
|
|
|
|
|
let textNoteDiscussion = id("cd0").className("android.view.View").findOne();
|
|
|
|
|
if (textNoteDiscussion) {
|
|
|
|
|
textNoteDiscussion.click();
|
|
|
|
|
sleep(2000);
|
|
|
|
|
log("发文字笔记讨论选项点击成功");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到发文字笔记讨论选项");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 输入文字并点击“下一步”
|
|
|
|
|
function inputTextAndProceed1() {
|
|
|
|
|
let nextButton = id("bga").className("android.widget.TextView").text("下一步").findOne(1000);
|
|
|
|
|
if (nextButton) {
|
|
|
|
|
nextButton.click();
|
|
|
|
|
sleep(3000);
|
|
|
|
|
log("点击下一步");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到下一步按钮");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function inputTextAndProceed2() {
|
|
|
|
|
let nextButton = id("g_f").className("android.widget.TextView").text("下一步").findOne(1000);
|
|
|
|
|
if (nextButton) {
|
|
|
|
|
nextButton.click();
|
|
|
|
|
sleep(3000);
|
|
|
|
|
log("点击下一步");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到下一步按钮");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 点击“发布笔记”
|
|
|
|
|
function publishNote() {
|
|
|
|
|
let publishButton = id("an7").className("android.widget.Button").text("发布笔记").findOne(1000);
|
|
|
|
|
if (publishButton) {
|
|
|
|
|
publishButton.click();
|
|
|
|
|
log("帖子已发布");
|
|
|
|
|
} else {
|
|
|
|
|
log("未找到发布笔记按钮");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 主函数
|
|
|
|
|
function main() {
|
|
|
|
|
auto();
|
|
|
|
|
// 定义小红书包名
|
|
|
|
|
var packageName = "com.xingin.xhs";
|
|
|
|
|
|
|
|
|
|
// 尝试打开小红书 APP
|
|
|
|
|
if (app.launchPackage(packageName)) {
|
|
|
|
|
toast("小红书已打开");
|
|
|
|
|
} else {
|
|
|
|
|
toast("无法打开小红书");
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 等待首页加载完成
|
|
|
|
|
sleep(5000);
|
|
|
|
|
|
|
|
|
|
let inputMethod = dialogs.select("选择输入方式", ["自动输入", "手动输入"]);
|
|
|
|
|
//home();
|
|
|
|
|
//app.launchApp("小红书");
|
|
|
|
|
clickAddButton();
|
|
|
|
|
clickTextOption();
|
|
|
|
|
clickTextNoteDiscussion();
|
|
|
|
|
|
|
|
|
|
// 直接执行自动输入
|
|
|
|
|
if (inputMethod == 0) { // 自动输入
|
|
|
|
|
autoInputText();
|
|
|
|
|
} else if (inputMethod == 1) { // 手动输入
|
|
|
|
|
manualInputText();
|
|
|
|
|
} else {
|
|
|
|
|
log("未选择输入方式");
|
|
|
|
|
alert("未选择输入方式");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setScreenMetrics(720,1600);
|
|
|
|
|
// click(600,100);
|
|
|
|
|
//home();
|
|
|
|
|
//app.launchApp("小红书");
|
|
|
|
|
inputTextAndProceed1(); // 第一次点击“下一步”
|
|
|
|
|
sleep(5000);
|
|
|
|
|
inputTextAndProceed2(); // 第二次点击“下一步”
|
|
|
|
|
publishNote();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 按钮点击事件
|
|
|
|
|
window.ok1.click(() => {
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
enterRandomLive();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.ok2.click(() => {
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
autoSendPost();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.ok3.click(() => {
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
autoLikeAndFollow();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.ok4.click(() => {
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
setLike();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.ok5.click(() => {
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
StaticComments();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.ok6.click(() => {
|
|
|
|
|
threads.start(function () {
|
|
|
|
|
FeedComments();// 动态评论功能代码
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
auto();
|
|
|
|
|
var packageName = "com.xingin.xhs";
|
|
|
|
|
app.launchPackage(packageName);
|
|
|
|
|
toast("正在打开小红书");
|
|
|
|
|
|
|
|
|
|
// 保持脚本运行
|
|
|
|
|
setInterval(() => { }, 1000);
|