|
|
const appPackageName = "com.xingin.xhs"; // 小红书的包名
|
|
|
|
|
|
// 点赞频率控制变量
|
|
|
let likeInterval = 1000; // 默认点赞间隔时间为1000毫秒(1秒)
|
|
|
let likeCount = 0; // 记录点赞次数
|
|
|
let running = true; // 控制点赞的开关
|
|
|
|
|
|
// 自动打开小红书APP
|
|
|
function openXiaohongshu() {
|
|
|
console.log("正在检查小红书是否已经打开...");
|
|
|
if (currentPackage() != appPackageName) {
|
|
|
console.log("小红书未打开,正在启动小红书...");
|
|
|
launch(appPackageName);
|
|
|
sleep(3000); // 增加等待加载时间
|
|
|
} else {
|
|
|
console.log("小红书已打开,继续操作...");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 进入直播间并自动点赞
|
|
|
function enterAndLikeLiveRoom() {
|
|
|
console.log("准备进入直播页面...");
|
|
|
openXiaohongshu();
|
|
|
sleep(3000);
|
|
|
|
|
|
if (clickLiveTab()) {
|
|
|
console.log("进入直播页面,等待加载...");
|
|
|
sleep(3000); // 增加等待时间,确保直播页面加载完成
|
|
|
|
|
|
// 假设屏幕尺寸为 2K (1440x2560)
|
|
|
let screenWidth = 1440;
|
|
|
let screenHeight = 2560;
|
|
|
|
|
|
// 进入一个直播间
|
|
|
let clickX = screenWidth * 2 / 3;
|
|
|
let clickY = screenHeight * 2 / 4;
|
|
|
click(clickX, clickY);
|
|
|
console.log("点击了屏幕下半部分,进入直播间");
|
|
|
|
|
|
// 执行点赞
|
|
|
likeLiveRoom(screenWidth, screenHeight);
|
|
|
} else {
|
|
|
console.log("无法进入直播页面");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 点赞函数
|
|
|
function likeLiveRoom(screenWidth, screenHeight) {
|
|
|
console.log("开始自动点赞...");
|
|
|
|
|
|
function performLike() {
|
|
|
if (!running) return; // 停止点赞时退出
|
|
|
|
|
|
// 双击屏幕中央实现点赞
|
|
|
let centerX = screenWidth / 2;
|
|
|
let centerY = screenHeight / 2;
|
|
|
|
|
|
// 第一次点击
|
|
|
click(centerX, centerY);
|
|
|
sleep(50); // 短暂延迟,模拟双击
|
|
|
// 第二次点击
|
|
|
click(centerX, centerY);
|
|
|
|
|
|
likeCount++; // 点赞计数
|
|
|
console.log("已点赞当前直播间,点赞次数:" + likeCount);
|
|
|
|
|
|
// 动态检查点赞间隔
|
|
|
setTimeout(performLike, likeInterval);
|
|
|
console.log("当前点赞间隔时间:" + likeInterval + " 毫秒");
|
|
|
}
|
|
|
|
|
|
// 开始首次点赞
|
|
|
performLike();
|
|
|
}
|
|
|
|
|
|
// 动态调整点赞速度
|
|
|
function adjustLikeSpeed(newInterval) {
|
|
|
likeInterval = newInterval;
|
|
|
console.log("点赞速度已更新,新的点赞间隔时间为:" + likeInterval + " 毫秒");
|
|
|
}
|
|
|
|
|
|
// 尝试找到直播按钮并点击
|
|
|
function clickLiveTab() {
|
|
|
try {
|
|
|
console.log("尝试找到直播按钮...");
|
|
|
let liveButton = id("ims").className("android.view.ViewGroup").desc("直播").findOne(3000);
|
|
|
if (liveButton) {
|
|
|
liveButton.parent().click();
|
|
|
console.log("点击了直播按钮");
|
|
|
return true;
|
|
|
} else {
|
|
|
console.log("未找到直播按钮");
|
|
|
return false;
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.error("点击直播按钮时出错: " + e);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 更新延迟显示
|
|
|
function updateDelayDisplay(window) {
|
|
|
window.speed.setText(likeInterval + " ms");
|
|
|
}
|
|
|
|
|
|
// 创建悬浮窗来调整点赞速度
|
|
|
function createControlWindow() {
|
|
|
ui.run(() => {
|
|
|
let window = floaty.window(
|
|
|
<frame bg="#99000000" w="260" h="180" padding="10" cornerRadius="15dp">
|
|
|
<vertical gravity="center">
|
|
|
<text text="点赞频率控制" textSize="18sp" textColor="#FFFFFF" gravity="center" />
|
|
|
<horizontal gravity="center" padding="5">
|
|
|
<button id="decrease" text="-" w="40" h="40" textColor="#FFFFFF" bg="#FF4081" />
|
|
|
<text id="speed" text="{{likeInterval}} ms" textSize="16sp" textColor="#FFFFFF" w="auto" gravity="center" margin="10"/>
|
|
|
<button id="increase" text="+" w="40" h="40" textColor="#FFFFFF" bg="#FF4081" />
|
|
|
</horizontal>
|
|
|
<button id="setDelay" text="设置延迟" w="100" h="40" bg="#4CAF50" textColor="#FFFFFF" marginTop="5dp"/>
|
|
|
<button id="stop" text="停止点赞" w="100" h="40" bg="#F44336" textColor="#FFFFFF" marginTop="5dp"/>
|
|
|
</vertical>
|
|
|
</frame>
|
|
|
);
|
|
|
|
|
|
// 增加按钮点击事件
|
|
|
window.increase.click(() => {
|
|
|
likeInterval = Math.max(100, likeInterval - 100); // 增加点赞速度
|
|
|
updateDelayDisplay(window);
|
|
|
console.log("增加点赞速度:" + likeInterval);
|
|
|
});
|
|
|
|
|
|
// 减少按钮点击事件
|
|
|
window.decrease.click(() => {
|
|
|
likeInterval += 100; // 减少点赞速度
|
|
|
updateDelayDisplay(window);
|
|
|
console.log("减少点赞速度:" + likeInterval);
|
|
|
});
|
|
|
|
|
|
// 设置延迟按钮点击事件(使用对话框)
|
|
|
window.setDelay.click(() => {
|
|
|
dialogs.input("输入新的点赞间隔(ms):", likeInterval.toString()).then(input => {
|
|
|
if (input != null) {
|
|
|
console.log("用户输入的延迟值:" + input);
|
|
|
if (!isNaN(input) && parseInt(input) >= 100) {
|
|
|
likeInterval = parseInt(input);
|
|
|
updateDelayDisplay(window);
|
|
|
console.log("设置了新的点赞延迟:" + likeInterval + " 毫秒");
|
|
|
} else {
|
|
|
console.log("输入无效或小于100,未更新点赞间隔");
|
|
|
}
|
|
|
} else {
|
|
|
console.log("用户取消了输入,未更改点赞间隔");
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
console.error("对话框输入出错:" + error);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 停止点赞按钮事件
|
|
|
window.stop.click(() => {
|
|
|
running = false;
|
|
|
console.log("点赞已停止");
|
|
|
window.close(); // 关闭悬浮窗
|
|
|
});
|
|
|
|
|
|
window.setPosition(100, 200); // 设置悬浮窗位置
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 启动悬浮窗和点赞功能
|
|
|
createControlWindow();
|
|
|
console.log("开始执行进入随机直播间并点赞功能...");
|
|
|
enterAndLikeLiveRoom();
|
|
|
console.log("脚本执行完毕");
|