From fa6679b27748a63b867cd1e67fd9c448ff0bbaf7 Mon Sep 17 00:00:00 2001 From: pfc8hp2r6 <2317678682@qq.com> Date: Sat, 2 Nov 2024 18:11:48 +0800 Subject: [PATCH] ADD file via upload --- 自动点赞.js | 173 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 自动点赞.js diff --git a/自动点赞.js b/自动点赞.js new file mode 100644 index 0000000..841037f --- /dev/null +++ b/自动点赞.js @@ -0,0 +1,173 @@ +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( + + + + +