From 28ab54e0a569bc5cceee557c9f2bf3dd2e9e620d Mon Sep 17 00:00:00 2001 From: pxskm4tvn <2836285168@qq.com> Date: Sat, 2 Nov 2024 20:26:56 +0800 Subject: [PATCH] ADD file via upload --- 5.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 5.js diff --git a/5.js b/5.js new file mode 100644 index 0000000..7b5da41 --- /dev/null +++ b/5.js @@ -0,0 +1,45 @@ +// 等待Auto.js无障碍服务启动 +auto.waitFor(); + +// 启动小红书应用 +function openXiaoHongShu() { + console.log("启动小红书..."); + app.launchApp('小红书'); + sleep(5000); // 等待应用加载 +} + +// 进入发帖页面 +function enterPostPage() { + text("关注").findOne().click(); + console.log('进入关注页面'); + className("android.view.ViewGroup").clickable(true).depth(21).findOne().click() + console.log('进入直播页面'); + +} + +function searchAndEnterLiveRoom(keyword) { + className("android.widget.Button").text("说点什么…").findOne().click() + console.log('编辑文字'); + console.log("编辑内容"); + setText(keyword); // 输入直播间关键词 + console.log("输入关键词:" + keyword); + sleep(1000); + + // 点击搜索按钮 + let searchButton1 = text("发送").findOne(); // 假设搜索按钮的文本为“搜索” + searchButton1.click(); + console.log("发送完成"); +} +// 主函数:启动小红书,进入发帖页面,编辑内容并发布 +function main() { + openXiaoHongShu(); // 启动小红书 + sleep(1000); + enterPostPage(); // 进入发帖页面 + sleep(1000); + searchAndEnterLiveRoom("富强民主文明和谐"); + searchAndEnterLiveRoom("内容太棒了"); + searchAndEnterLiveRoom("点赞"); +} + +// 执行主程序 +main();