From 69c9be759493f26d68c346a2e7e83fc0b3247519 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E7=8E=B2?= <1971708054@qq.com>
Date: Sun, 3 Nov 2024 21:44:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
all.js | 431 ++++++++++++++++++++
中等题目/直播间自动点赞.js | 128 ++++++
中等题目/自动滑屏切换直播间.js | 86 ++++
基础题目/直播间进入.js | 42 ++
基础题目/自动发帖.js | 47 +++
进阶题目/自动发评论.js | 186 +++++++++
6 files changed, 920 insertions(+)
create mode 100644 all.js
create mode 100644 中等题目/直播间自动点赞.js
create mode 100644 中等题目/自动滑屏切换直播间.js
create mode 100644 基础题目/直播间进入.js
create mode 100644 基础题目/自动发帖.js
create mode 100644 进阶题目/自动发评论.js
diff --git a/all.js b/all.js
new file mode 100644
index 0000000..96a77d3
--- /dev/null
+++ b/all.js
@@ -0,0 +1,431 @@
+// // 创建悬浮窗
+// var window = floaty.window(
+//
+//
+//
+//
+//
+//
+
+//
+// );
+
+// window.setPosition(100, 100);
+
+// // 布尔值用来跟踪任务的运行状态
+// var isTask1Running = false;
+// var isTask2Running = false;
+// var isTask3Running = false;
+// var isTask4Running = false;
+// var isTask5Running = false;
+var taskThread1, taskThread2, taskThread3, taskThread4, taskThread5;
+var isTask1Running = false, isTask2Running = false, isTask3Running = false, isTask4Running = false, isTask5Running = false;
+
+// 创建悬浮窗
+var window = floaty.window(
+
+
+
+
+
+
+
+);
+
+window.setPosition(100, 100);
+
+// 用于中断所有正在运行的任务
+function stopAllTasks() {
+ if (taskThread1 && taskThread1.isAlive()) taskThread1.interrupt();
+ if (taskThread2 && taskThread2.isAlive()) taskThread2.interrupt();
+ if (taskThread3 && taskThread3.isAlive()) taskThread3.interrupt();
+ if (taskThread4 && taskThread4.isAlive()) taskThread4.interrupt();
+ if (taskThread5 && taskThread5.isAlive()) taskThread5.interrupt();
+
+ isTask1Running = isTask2Running = isTask3Running = isTask4Running = isTask5Running = false;
+}
+
+// 任务1:启动并操作小红书应用
+function task1() {
+ while (!threads.currentThread().isInterrupted()) {
+ var packageName = "com.xingin.xhs";
+ // 启动小红书应用
+ if (app.getAppName(packageName)) {
+ toast("启动小红书...");
+ app.launch(packageName);
+ log("Package launched: " + packageName);
+ sleep(3000); // 等待应用启动
+ } else {
+ toast("找不到小红书应用");
+ log("Error: 找不到小红书应用");
+ return;
+ }
+
+ // 刷新主页
+ toast('刷新主页面...');
+ swipe(540, 500, 540, 1500, 500);
+ sleep(2000);
+ console.log('主页刷新完成');
+
+ // 查找并进入直播区域
+ var liveAreaButtonText = '直播'; // 确保文本正确
+ var liveAreaButton = text(liveAreaButtonText).visibleToUser().findOne(10000);
+ if (liveAreaButton) {
+ click("直播");
+ sleep(2000);
+ console.log('已进入直播区域');
+ } else {
+ console.error("未找到直播区域按钮: " + liveAreaButtonText);
+ return;
+ }
+
+ // 进入具体直播间
+ var specificLiveButtonId = 'com.xingin.xhs:id/eox';
+ var specificLiveButton = id(specificLiveButtonId).visibleToUser().findOne(2000); // 加长查找等待时间
+ if (specificLiveButton) {
+ var bounds = specificLiveButton.bounds();
+ click(bounds.centerX(), bounds.centerY()+500);
+ sleep(2000); // 等待直播间加载
+ console.log('已进入具体直播间');
+ }
+}
+}
+
+//任务5:自动发帖
+function task5() {
+ while (!threads.currentThread().isInterrupted()) {
+
+function clickbutton(buttonid)
+{
+ if (buttonid)
+ {
+ var button = id(buttonid).visibleToUser().findOne();
+ if (button)
+ {
+ var bounds = button.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ click(centerX,centerY);
+ }
+ }
+}
+var addButtonId = 'com.xingin.xhs:id/dvd';//需要修改
+clickbutton(addButtonId);
+sleep(1000);
+var wenzi = text("文字").findOne();
+click("文字");
+var taolunId = 'com.xingin.xhs:id/ca8'; //需要修改
+clickbutton(taolunId);
+// 定义评论内容
+var comments = ["好天气!", "赞一个!", "好开心!", "软件工程!", "auto.js!"];
+//找评论框
+var kuangId = 'com.xingin.xhs:id/bhc'; //需要修改
+clickbutton(kuangId);
+//输入评论
+if (kuangId)
+{
+ var randomComment = comments[random(0, comments.length - 1)];
+ log('准备输入评论: ' + randomComment);
+ var editText = id("bhc").findOne(2000); //要修改
+ setText(randomComment);
+ sleep(2000);
+ var nextId = 'com.xingin.xhs:id/bed'; //需要修改
+ clickbutton(nextId);
+ sleep(5000);
+ var nextId2 = 'com.xingin.xhs:id/g48'; //需要修改
+ clickbutton(nextId2);
+ sleep(2000);
+ var fabu = 'com.xingin.xhs:id/alz'; //需要修改
+ clickbutton(fabu);
+}
+ }
+}
+
+function task2() {
+ while (!threads.currentThread().isInterrupted()) {
+ // 创建悬浮窗
+ var window = floaty.window(
+
+ 点赞速度
+
+ 0.5秒/次
+
+ );
+
+ // 设置悬浮窗的位置
+ window.setPosition(700, 300);
+
+ // 初始化点赞速度
+ var currentInterval = 500; // 初始间隔为0.5秒
+ var totalLikes = 300; // 总共点赞次数
+ var likesCount = 0; // 当前点赞次数
+
+ // 监听进度条变化
+ window.speedSlider.setOnSeekBarChangeListener({
+ onProgressChanged: function(seekBar, progress, fromUser) {
+ var newInterval = (progress + 2) * 100; // 映射到200-2000毫秒
+ currentInterval = newInterval;
+ window.speedText.setText((newInterval / 1000).toFixed(1) + "秒/次");
+ },
+ onStartTrackingTouch: function(seekBar) {},
+ onStopTrackingTouch: function(seekBar) {}
+ });
+
+ // 自动点赞功能
+ function autoLike(interval) {
+ if (likesCount >= totalLikes) {
+ toast("点赞完成!");
+ return;
+ }
+
+ var likeButtonId = 'com.xingin.xhs:id/tl'; // 假设这是点赞按钮的ID
+ var likeButton = id(likeButtonId).visibleToUser().findOne(10000);
+ if (likeButton) {
+ log('找到点赞按钮,准备点赞');
+ var likeBounds = likeButton.bounds();
+ var likeCenterX = likeBounds.centerX();
+ var likeCenterY = likeBounds.centerY();
+
+ // 快速连续点击两次
+ click(likeCenterX, likeCenterY);
+ sleep(100); // 短暂延迟,确保第一次点击生效
+ click(likeCenterX, likeCenterY);
+
+ likesCount++;
+ log('已点赞 ' + likesCount + ' 次');
+ } else {
+ console.error("未找到点赞按钮: " + likeButtonId);
+ toast("未找到点赞按钮: " + likeButtonId);
+ }
+
+ // 递归调用自身,实现持续点赞
+ setTimeout(() => {
+ autoLike(currentInterval);
+ }, interval);
+ }
+
+ // 开始点赞
+ autoLike(currentInterval);
+
+ toast('点赞开始,可以通过悬浮窗调整点赞速度');
+ }
+}
+
+
+function task3() {
+ while (!threads.currentThread().isInterrupted()) {
+ // 迭代查找直播间并进行点赞和滑动
+var maxScrolls = 10; // 最大滑动次数
+var swipeInterval = 3000; // 滑动间隔时间,可以加长等待时间
+for (var i = 0; i < maxScrolls; i++) {
+
+ // 自动点赞
+ var likeButtonId = 'com.xingin.xhs:id/tl'; // 点赞按钮的ID
+ var likeButton = id(likeButtonId).visibleToUser().findOne(10000);
+ if (likeButton) {
+ log('找到点赞按钮,准备点赞');
+ var likeBounds = likeButton.bounds();
+ var likeCenterX = likeBounds.centerX();
+ var likeCenterY = likeBounds.centerY();
+
+ click(likeCenterX, likeCenterY);
+ sleep(100);
+ click(likeCenterX, likeCenterY);
+ console.log('完成点赞');
+ } else {
+ console.error("未找到点赞按钮: " + likeButtonId);
+ }
+
+
+ // 查找关注按钮并点击
+ var followButtonId = 'com.xingin.xhs:id/j10';
+ var followButton = id(followButtonId).visibleToUser().findOne();
+ if (followButton) {
+ var bounds = followButton.bounds();
+ click(bounds.centerX(), bounds.centerY());
+ sleep(1000);
+ } else {
+ log("未找到关注按钮: " + followButtonId);
+ }
+
+ // 滑动到下一个直播
+ sleep(2000);
+ toast('滑动到下一个直播间...');
+ swipe(540, 1200, 540, 500, 500); // 定义在直播间的滑动动作
+ sleep(5000);
+ console.log('滑动完成');
+
+ }
+}
+}
+
+
+
+function task4() {
+ while (!threads.currentThread().isInterrupted()) {
+ var comment;
+ var centerX;
+ var centerY;
+ for (var j = 0; j < 3; j++)
+ {
+ // 询问用户是否自行输入评论
+ var userInputChoice = confirm("您想要自行输入评论吗?", ["是", "否"]);
+ console.log(userInputChoice)
+ // 点击编辑文本框(使用desc方法)
+ var editTextDesc = "评论输入框"; // 假设这是编辑文本框的描述
+ var editTextInput = desc(editTextDesc).visibleToUser().findOne(5000);
+ if (editTextInput) {
+ var bounds = editTextInput.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ log('找到编辑文本框,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击编辑文本框');
+ click(centerX, centerY);
+ sleep(2000);
+ console.log('点击编辑文本框');
+ } else {
+ console.error("未找到编辑文本框");
+ toast("未找到编辑文本框");
+ exit();
+ }
+ if (userInputChoice) {
+ // 用户选择自行输入
+ var inputId = 'com.xingin.xhs:id/ft5'; // 假设这是具体直播间控件的ID
+ var selectInputId = id(inputId).visibleToUser().findOne(5000);
+ comment = selectInputId.text();
+ // comment = getInputText(); // 替换为获取外部输入框文本的函数
+ console.log(comment)
+ setText(comment); // 输入评论内容
+ sleep(7000); // 等待输入完成
+
+ // 点击发送按钮
+ var centerXX;
+ var centerYY;
+ var sendButtonId = 'com.xingin.xhs:id/hz5'; // 假设这是发送按钮的ID
+ var sendButton = id(sendButtonId).visibleToUser().findOne(10000);
+ if (sendButton) {
+ var bounds = sendButton.bounds();
+ centerXX = bounds.centerX();
+ centerYY = bounds.centerY();
+ log('找到发送按钮,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击发送按钮');
+ click(centerXX, centerYY);
+ sleep(5000); // 等待发送完成
+ console.log('点击发送按钮');
+ } else {
+ console.error("未找到发送按钮: " + sendButtonId);
+ }
+ var num = 10;
+ for (var k = 0; k < num; k++) {
+ // 重新点击编辑文本框,准备下一条评论
+ editTextInput = desc(editTextDesc).visibleToUser().findOne(5000);
+ if (editTextInput) {
+ click(centerX, centerY);
+ sleep(1000); // 等待文本框激活
+ setText(comment); // 输入评论内容
+ sleep(1000); // 等待发送完成
+ click(centerXX, centerYY);
+ sleep(3000); // 等待发送完成
+ console.log('点击发送按钮');
+ } else {
+ console.error("未找到编辑文本框,无法继续发布评论");
+ break;
+ }
+ }
+ } else {
+ // 评论内容数组,增加了更多评论选项
+ var comments = [
+ "好文章!", "赞一个!", "很有帮助!", "学习到了!",
+ "期待更多分享!", "这真的很棒!", "非常喜欢这篇!",
+ "非常有趣!", "太感谢了!", "内容很精彩!",
+ "我也有同样的感觉!", "你说的太对了!", "继续加油!",
+ "分享得很好!", "希望能看到更多!", "值得推荐!",
+ "真是个好主意!", "看完受益匪浅!", "这让我想到了...!",
+ "很不错的观点!", "写得真好!", "我完全同意你的看法!",
+ "太精彩了,继续努力!", "你真是个天才!", "希望你能多分享一些!"
+ ];
+
+ var numberOfComments = 3; // 设置要发布的评论数量
+
+ // 发布评论
+ for (var i = 0; i < numberOfComments; i++) {
+ // 随机选择评论内容
+ var randomIndex = random(0, comments.length - 1);
+ var randomComment = comments[randomIndex];
+
+ log('准备输入评论: ' + randomComment);
+ setText(randomComment); // 输入评论内容
+ sleep(1000); // 等待输入完成
+
+ // 点击发送按钮
+ var sendButtonId = 'com.xingin.xhs:id/hz5'; // 假设这是发送按钮的ID
+ var sendButton = id(sendButtonId).visibleToUser().findOne(10000);
+ if (sendButton) {
+ var bounds = sendButton.bounds();
+ var centerXXX = bounds.centerX();
+ var centerYYY = bounds.centerY();
+ log('找到发送按钮,中心坐标: (' + centerXXX + ', ' + centerYYY + ')');
+ toast('准备点击发送按钮');
+ click(centerXXX, centerYYY);
+ sleep(5000); // 等待发送完成
+ console.log('点击发送按钮');
+ } else {
+ console.error("未找到发送按钮: " + sendButtonId);
+ break; // 如果找不到发送按钮,退出循环
+ }
+ // 重新点击编辑文本框,准备下一条评论
+ editTextInput = desc(editTextDesc).visibleToUser().findOne(5000);
+ if (editTextInput) {
+ click(editTextInput.bounds().centerX(), editTextInput.bounds().centerY());
+ sleep(2000); // 等待文本框激活
+ } else {
+ console.error("未找到编辑文本框,无法继续发布评论");
+ break;
+ }
+ }
+ }
+ }
+ toast('end, AutoX.js');
+
+ }
+
+}
+
+
+
+
+
+
+// 按钮事件监听
+window.task1.click(() => {
+ stopAllTasks();
+ isTask1Running = true;
+ taskThread1 = threads.start(task1);
+});
+
+window.task2.click(() => {
+ stopAllTasks();
+ isTask2Running = true;
+ taskThread2 = threads.start(task2);
+});
+
+window.task3.click(() => {
+ stopAllTasks();
+ isTask3Running = true;
+ taskThread3 = threads.start(task3);
+});
+
+window.task4.click(() => {
+ stopAllTasks();
+ isTask4Running = true;
+ taskThread4 = threads.start(task4);
+});
+
+window.task5.click(() => {
+ stopAllTasks();
+ isTask5Running = true;
+ taskThread5 = threads.start(task5);
+});
+
+// 保持悬浮3窗和主线程运行
+setInterval(() => {}, 1000);
\ No newline at end of file
diff --git a/中等题目/直播间自动点赞.js b/中等题目/直播间自动点赞.js
new file mode 100644
index 0000000..3f567f2
--- /dev/null
+++ b/中等题目/直播间自动点赞.js
@@ -0,0 +1,128 @@
+try {
+ // 指定小红书的包名
+ var packageName = "com.xingin.xhs"; // 确保这个包名是正确的
+
+ // 检查包名是否存在
+ if (app.getAppName(packageName)) {
+ // 使用包名启动应用
+ toast("启动小红书...");
+ app.launch(packageName);
+ log("Package launched: " + packageName);
+ sleep(2000); // 等待应用启动
+ } else {
+ toast("找不到小红书应用");
+ log("Error: 找不到小红书应用");
+ exit();
+ }
+
+ // 添加刷新动作,从上往下滑动
+ toast('开始刷新主页面...');
+ swipe(540, 500, 540, 1500, 500); // 从屏幕上方向下滑动
+ sleep(2000); // 等待刷新完成
+ console.log('刷新主页面完成');
+
+ // 使用文本查找直播区域控件
+ var liveAreaButtonText = '直播'; // 假设这是直播区域的文本
+ var liveAreaButton = text(liveAreaButtonText).visibleToUser().findOne(10000);
+ if (liveAreaButton) {
+ var bounds = liveAreaButton.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ log('找到直播区域按钮,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击直播区域按钮');
+ click(centerX, centerY);
+ sleep(2000);
+ console.log('点击直播区域按钮');
+ } else {
+ console.error("未找到直播区域按钮: " + liveAreaButtonText);
+ toast("未找到直播区域按钮: " + liveAreaButtonText);
+ exit();
+ }
+
+ // 进入具体直播间(通过控件 ID)
+ var specificLiveButtonId = 'com.xingin.xhs:id/eox'; // 假设这是具体直播间控件的ID
+ var specificLiveButton = id(specificLiveButtonId).visibleToUser().findOne(10000);
+ if (specificLiveButton) {
+ var bounds = specificLiveButton.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ log('找到具体直播间按钮,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击具体直播间按钮');
+ click(centerX, centerY);
+ sleep(3000);
+ console.log('点击具体直播间按钮');
+ } else {
+ console.error("未找到具体直播间按钮: " + specificLiveButtonId);
+ toast("未找到具体直播间按钮: " + specificLiveButtonId);
+ exit();
+ }
+
+ // 创建悬浮窗
+ var window = floaty.window(
+
+ 点赞速度
+
+ 0.5秒/次
+
+ );
+
+ // 设置悬浮窗的位置
+ window.setPosition(100, 300);
+
+ // 初始化点赞速度
+ var currentInterval = 500; // 初始间隔为0.5秒
+ var totalLikes = 300; // 总共点赞次数
+ var likesCount = 0; // 当前点赞次数
+
+ // 监听进度条变化
+ window.speedSlider.setOnSeekBarChangeListener({
+ onProgressChanged: function(seekBar, progress, fromUser) {
+ var newInterval = (progress + 2) * 100; // 映射到200-2000毫秒
+ currentInterval = newInterval;
+ window.speedText.setText((newInterval / 1000).toFixed(1) + "秒/次");
+ },
+ onStartTrackingTouch: function(seekBar) {},
+ onStopTrackingTouch: function(seekBar) {}
+ });
+
+ // 自动点赞功能
+ function autoLike(interval) {
+ if (likesCount >= totalLikes) {
+ toast("点赞完成!");
+ return;
+ }
+
+ var likeButtonId = 'com.xingin.xhs:id/tl'; // 假设这是点赞按钮的ID
+ var likeButton = id(likeButtonId).visibleToUser().findOne(10000);
+ if (likeButton) {
+ log('找到点赞按钮,准备点赞');
+ var likeBounds = likeButton.bounds();
+ var likeCenterX = likeBounds.centerX();
+ var likeCenterY = likeBounds.centerY();
+
+ // 快速连续点击两次
+ click(likeCenterX, likeCenterY);
+ sleep(100); // 短暂延迟,确保第一次点击生效
+ click(likeCenterX, likeCenterY);
+
+ likesCount++;
+ log('已点赞 ' + likesCount + ' 次');
+ } else {
+ console.error("未找到点赞按钮: " + likeButtonId);
+ toast("未找到点赞按钮: " + likeButtonId);
+ }
+
+ // 递归调用自身,实现持续点赞
+ setTimeout(() => {
+ autoLike(currentInterval);
+ }, interval);
+ }
+
+ // 开始点赞
+ autoLike(currentInterval);
+
+ toast('点赞开始,可以通过悬浮窗调整点赞速度');
+} catch (e) {
+ toast("脚本执行异常: " + e.toString());
+ console.error("脚本执行异常: " + e.toString());
+}
\ No newline at end of file
diff --git a/中等题目/自动滑屏切换直播间.js b/中等题目/自动滑屏切换直播间.js
new file mode 100644
index 0000000..ca20b74
--- /dev/null
+++ b/中等题目/自动滑屏切换直播间.js
@@ -0,0 +1,86 @@
+var packageName = "com.xingin.xhs";
+
+// 启动小红书应用
+if (app.getAppName(packageName)) {
+ toast("启动小红书...");
+ app.launch(packageName);
+ log("Package launched: " + packageName);
+ sleep(5000); // 等待应用启动
+} else {
+ toast("找不到小红书应用");
+ log("Error: 找不到小红书应用");
+ exit();
+}
+
+// 刷新主页
+toast('刷新主页面...');
+swipe(540, 500, 540, 1500, 500);
+sleep(2000);
+console.log('主页刷新完成');
+
+// 查找并进入直播区域
+var liveAreaButtonText = '直播'; // 确保文本正确
+var liveAreaButton = text(liveAreaButtonText).visibleToUser().findOne(10000);
+if (liveAreaButton) {
+ var bounds = liveAreaButton.bounds();
+ click(bounds.centerX(), bounds.centerY());
+ sleep(5000);
+ console.log('已进入直播区域');
+} else {
+ console.error("未找到直播区域按钮: " + liveAreaButtonText);
+ exit();
+}
+
+var specificLiveButtonId = 'com.xingin.xhs:id/eox';
+var followButtonId = 'com.xingin.xhs:id/j10';
+var specificLiveButton = id(specificLiveButtonId).visibleToUser().findOne(5000); // 加长查找等待时间
+if (specificLiveButton) {
+ var bounds = specificLiveButton.bounds();
+ click(bounds.centerX(), bounds.centerY());
+ sleep(5000); // 等待直播间加载
+ console.log('已进入具体直播间');
+
+// 迭代查找直播间并进行点赞和滑动
+var maxScrolls = 10; // 最大滑动次数
+var swipeInterval = 3000; // 滑动间隔时间,可以加长等待时间// 确保这个ID正确
+for (var i = 0; i < maxScrolls; i++) {
+
+ // 自动点赞
+ var likeButtonId = 'com.xingin.xhs:id/tl'; // 点赞按钮的ID
+ var likeButton = id(likeButtonId).visibleToUser().findOne(10000);
+ if (likeButton) {
+ log('找到点赞按钮,准备点赞');
+ var likeBounds = likeButton.bounds();
+ var likeCenterX = likeBounds.centerX();
+ var likeCenterY = likeBounds.centerY();
+
+ click(likeCenterX, likeCenterY);
+ sleep(100);
+ click(likeCenterX, likeCenterY);
+ console.log('完成点赞');
+ } else {
+ console.error("未找到点赞按钮: " + likeButtonId);
+ }
+
+
+ // 查找关注按钮并点击
+ var followButton = id(followButtonId).visibleToUser().findOne(2000);
+ if (followButton) {
+ var bounds = followButton.bounds();
+ click(bounds.centerX(), bounds.centerY());
+ sleep(1000);
+ } else {
+ log("未找到关注按钮: " + followButtonId);
+ }
+
+ // 滑动到下一个直播
+ sleep(2000);
+ toast('滑动到下一个直播间...');
+ swipe(540, 1500, 540, 500, 500); // 定义在直播间的滑动动作
+ sleep(2000);
+ console.log('滑动完成');
+
+ }
+}
+
+toast('脚本已结束.');
diff --git a/基础题目/直播间进入.js b/基础题目/直播间进入.js
new file mode 100644
index 0000000..bd5ce11
--- /dev/null
+++ b/基础题目/直播间进入.js
@@ -0,0 +1,42 @@
+
+var packageName = "com.xingin.xhs";
+
+// 启动小红书应用
+if (app.getAppName(packageName)) {
+ toast("启动小红书...");
+ app.launch(packageName);
+ log("Package launched: " + packageName);
+ sleep(3000); // 等待应用启动
+} else {
+ toast("找不到小红书应用");
+ log("Error: 找不到小红书应用");
+ exit();
+}
+
+// 刷新主页
+toast('刷新主页面...');
+swipe(540, 500, 540, 1500, 500);
+sleep(2000);
+console.log('主页刷新完成');
+
+// 查找并进入直播区域
+var liveAreaButtonText = '直播'; // 确保文本正确
+var liveAreaButton = text(liveAreaButtonText).visibleToUser().findOne(10000);
+if (liveAreaButton) {
+ var bounds = liveAreaButton.bounds();
+ click(bounds.centerX(), bounds.centerY());
+ sleep(2000);
+ console.log('已进入直播区域');
+} else {
+ console.error("未找到直播区域按钮: " + liveAreaButtonText);
+ exit();
+}
+
+var specificLiveButtonId = 'com.xingin.xhs:id/eox';
+var specificLiveButton = id(specificLiveButtonId).visibleToUser().findOne(2000); // 加长查找等待时间
+if (specificLiveButton) {
+ var bounds = specificLiveButton.bounds();
+ click(bounds.centerX(), bounds.centerY());
+ sleep(2000); // 等待直播间加载
+ console.log('已进入具体直播间');
+}
\ No newline at end of file
diff --git a/基础题目/自动发帖.js b/基础题目/自动发帖.js
new file mode 100644
index 0000000..168accc
--- /dev/null
+++ b/基础题目/自动发帖.js
@@ -0,0 +1,47 @@
+
+function clickbutton(buttonid)
+{
+ if (buttonid)
+ {
+ var button = id(buttonid).visibleToUser().findOne();
+ if (button)
+ {
+ var bounds = button.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ click(centerX,centerY);
+ }
+ }
+}
+launchApp("小红书");
+sleep(3000);
+var addButtonId = 'com.xingin.xhs:id/dvd';//需要修改
+clickbutton(addButtonId);
+sleep(1000);
+var wenzi = text("文字").findOne();
+click("文字");
+var taolunId = 'com.xingin.xhs:id/ca8'; //需要修改
+clickbutton(taolunId);
+// 定义评论内容
+var comments = ["好天气!", "赞一个!", "好开心!", "软件工程!", "auto.js!"];
+//找评论框
+var kuangId = 'com.xingin.xhs:id/bhc'; //需要修改
+clickbutton(kuangId);
+//输入评论
+if (kuangId)
+{
+ var randomComment = comments[random(0, comments.length - 1)];
+ log('准备输入评论: ' + randomComment);
+ var editText = id("bhc").findOne(2000); //要修改
+ setText(randomComment);
+ sleep(2000);
+ var nextId = 'com.xingin.xhs:id/bed'; //需要修改
+ clickbutton(nextId);
+ sleep(5000);
+ var nextId2 = 'com.xingin.xhs:id/g48'; //需要修改
+ clickbutton(nextId2);
+ sleep(2000);
+ var fabu = 'com.xingin.xhs:id/alz'; //需要修改
+ clickbutton(fabu);
+}
+
diff --git a/进阶题目/自动发评论.js b/进阶题目/自动发评论.js
new file mode 100644
index 0000000..ff04c67
--- /dev/null
+++ b/进阶题目/自动发评论.js
@@ -0,0 +1,186 @@
+try {
+ // 指定小红书的包名
+ var packageName = "com.xingin.xhs"; // 确保这个包名是正确的
+
+ // 检查包名是否存在
+ if (app.getAppName(packageName)) {
+ // 使用包名启动应用
+ toast("启动小红书...");
+ app.launch(packageName);
+ log("Package launched: " + packageName);
+ sleep(5000); // 等待应用启动
+ } else {
+ toast("找不到小红书应用");
+ log("Error: 找不到小红书应用");
+ exit();
+ }
+
+ // 添加刷新动作,从上往下滑动
+ toast('开始刷新主页面...');
+ swipe(540, 500, 540, 1500, 500); // 从屏幕上方向下滑动
+ sleep(2000); // 等待刷新完成
+ console.log('刷新主页面完成');
+
+ // 使用文本查找直播区域控件
+ var liveAreaButtonText = '直播'; // 假设这是直播区域的文本
+ var liveAreaButton = text(liveAreaButtonText).visibleToUser().findOne(10000);
+ if (liveAreaButton) {
+ var bounds = liveAreaButton.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ log('找到直播区域按钮,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击直播区域按钮');
+ click(centerX, centerY);
+ sleep(5000);
+ console.log('点击直播区域按钮');
+ } else {
+ console.error("未找到直播区域按钮: " + liveAreaButtonText);
+ toast("未找到直播区域按钮: " + liveAreaButtonText);
+ exit();
+ }
+
+ // 进入具体直播间(通过控件 ID)
+ var specificLiveButtonId = 'com.xingin.xhs:id/eox'; // 假设这是具体直播间控件的ID
+ var specificLiveButton = id(specificLiveButtonId).visibleToUser().findOne(5000);
+ if (specificLiveButton) {
+ var bounds = specificLiveButton.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ log('找到具体直播间按钮,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击具体直播间按钮');
+ click(centerX, centerY);
+ sleep(5000);
+ console.log('点击具体直播间按钮');
+ } else {
+ console.error("未找到具体直播间按钮: " + specificLiveButtonId);
+ toast("未找到具体直播间按钮: " + specificLiveButtonId);
+ exit();
+ }
+
+ var comment;
+ var centerX;
+ var centerY;
+ for (var j = 0; j < 3; j++)
+ {
+ // 询问用户是否自行输入评论
+ var userInputChoice = confirm("您想要自行输入评论吗?", ["是", "否"]);
+ console.log(userInputChoice)
+ // 点击编辑文本框(使用desc方法)
+ var editTextDesc = "评论输入框"; // 假设这是编辑文本框的描述
+ var editTextInput = desc(editTextDesc).visibleToUser().findOne(5000);
+ if (editTextInput) {
+ var bounds = editTextInput.bounds();
+ var centerX = bounds.centerX();
+ var centerY = bounds.centerY();
+ log('找到编辑文本框,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击编辑文本框');
+ click(centerX, centerY);
+ sleep(2000);
+ console.log('点击编辑文本框');
+ } else {
+ console.error("未找到编辑文本框");
+ toast("未找到编辑文本框");
+ exit();
+ }
+ if (userInputChoice) {
+ // 用户选择自行输入
+ var inputId = 'com.xingin.xhs:id/ft5'; // 假设这是具体直播间控件的ID
+ var selectInputId = id(inputId).visibleToUser().findOne(5000);
+ comment = selectInputId.text();
+ // comment = getInputText(); // 替换为获取外部输入框文本的函数
+ console.log(comment)
+ setText(comment); // 输入评论内容
+ sleep(5000); // 等待输入完成
+
+ // 点击发送按钮
+ var centerXX;
+ var centerYY;
+ var sendButtonId = 'com.xingin.xhs:id/hz5'; // 假设这是发送按钮的ID
+ var sendButton = id(sendButtonId).visibleToUser().findOne(10000);
+ if (sendButton) {
+ var bounds = sendButton.bounds();
+ centerXX = bounds.centerX();
+ centerYY = bounds.centerY();
+ log('找到发送按钮,中心坐标: (' + centerX + ', ' + centerY + ')');
+ toast('准备点击发送按钮');
+ click(centerXX, centerYY);
+ sleep(5000); // 等待发送完成
+ console.log('点击发送按钮');
+ } else {
+ console.error("未找到发送按钮: " + sendButtonId);
+ }
+ var num = 10;
+ for (var k = 0; k < num; k++) {
+ // 重新点击编辑文本框,准备下一条评论
+ editTextInput = desc(editTextDesc).visibleToUser().findOne(5000);
+ if (editTextInput) {
+ click(centerX, centerY);
+ sleep(1000); // 等待文本框激活
+ setText(comment); // 输入评论内容
+ sleep(1000); // 等待发送完成
+ click(centerXX, centerYY);
+ sleep(5000); // 等待发送完成
+ console.log('点击发送按钮');
+ } else {
+ console.error("未找到编辑文本框,无法继续发布评论");
+ break;
+ }
+ }
+ } else {
+ // 评论内容数组,增加了更多评论选项
+ var comments = [
+ "好文章!", "赞一个!", "很有帮助!", "学习到了!",
+ "期待更多分享!", "这真的很棒!", "非常喜欢这篇!",
+ "非常有趣!", "太感谢了!", "内容很精彩!",
+ "我也有同样的感觉!", "你说的太对了!", "继续加油!",
+ "分享得很好!", "希望能看到更多!", "值得推荐!",
+ "真是个好主意!", "看完受益匪浅!", "这让我想到了...!",
+ "很不错的观点!", "写得真好!", "我完全同意你的看法!",
+ "太精彩了,继续努力!", "你真是个天才!", "希望你能多分享一些!"
+ ];
+
+ var numberOfComments = 3; // 设置要发布的评论数量
+
+ // 发布评论
+ for (var i = 0; i < numberOfComments; i++) {
+ // 随机选择评论内容
+ var randomIndex = random(0, comments.length - 1);
+ var randomComment = comments[randomIndex];
+
+ log('准备输入评论: ' + randomComment);
+ setText(randomComment); // 输入评论内容
+ sleep(1000); // 等待输入完成
+
+ // 点击发送按钮
+ var sendButtonId = 'com.xingin.xhs:id/hz5'; // 假设这是发送按钮的ID
+ var sendButton = id(sendButtonId).visibleToUser().findOne(10000);
+ if (sendButton) {
+ var bounds = sendButton.bounds();
+ var centerXXX = bounds.centerX();
+ var centerYYY = bounds.centerY();
+ log('找到发送按钮,中心坐标: (' + centerXXX + ', ' + centerYYY + ')');
+ toast('准备点击发送按钮');
+ click(centerXXX, centerYYY);
+ sleep(5000); // 等待发送完成
+ console.log('点击发送按钮');
+ } else {
+ console.error("未找到发送按钮: " + sendButtonId);
+ break; // 如果找不到发送按钮,退出循环
+ }
+ // 重新点击编辑文本框,准备下一条评论
+ editTextInput = desc(editTextDesc).visibleToUser().findOne(5000);
+ if (editTextInput) {
+ click(editTextInput.bounds().centerX(), editTextInput.bounds().centerY());
+ sleep(2000); // 等待文本框激活
+ } else {
+ console.error("未找到编辑文本框,无法继续发布评论");
+ break;
+ }
+ }
+ }
+ }
+ toast('end, AutoX.js');
+} catch (e) {
+ toast("脚本执行异常: " + e.toString());
+ console.error("脚本执行异常: " + e.toString());
+}