You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
205 lines
6.6 KiB
205 lines
6.6 KiB
const View = android.view.View;
|
|
// 创建悬浮窗
|
|
let window = floaty.window(
|
|
<vertical>
|
|
<button id="toggleBtn" text="展开/隐藏"/>
|
|
<button id="enter" text="进入直播间"/>
|
|
<button id="push" text="自动发帖"/>
|
|
<button id="comment" text="评论"/>
|
|
<button id="follow" text="关注"/>
|
|
</vertical>
|
|
);
|
|
|
|
// 设置悬浮窗的位置
|
|
window.setPosition(0, 50);
|
|
|
|
// 初始化悬浮窗的状态
|
|
let isExpanded = true;
|
|
|
|
// 隐藏和展开悬浮窗
|
|
window.toggleBtn.click(() => {
|
|
if (isExpanded) {
|
|
// 隐藏悬浮窗
|
|
if (window.enter) window.enter.setVisibility(View.GONE);
|
|
if (window.push) window.push.setVisibility(View.GONE);
|
|
if (window.comment) window.comment.setVisibility(View.GONE);
|
|
if (window.follow) window.follow.setVisibility(View.GONE);
|
|
window.toggleBtn.setText("展开");
|
|
} else {
|
|
// 展开悬浮窗
|
|
if (window.enter) window.enter.setVisibility(View.VISIBLE);
|
|
if (window.push) window.push.setVisibility(View.VISIBLE);
|
|
if (window.comment) window.comment.setVisibility(View.VISIBLE);
|
|
if (window.follow) window.follow.setVisibility(View.VISIBLE);
|
|
window.toggleBtn.setText("隐藏");
|
|
}
|
|
isExpanded = !isExpanded;
|
|
});
|
|
|
|
// 为每个按钮添加点击事件处理
|
|
window.enter.click(function() {
|
|
// 进入任意直播间
|
|
setTimeout(function() {
|
|
var appName = "小红书";
|
|
launchApp(appName);
|
|
|
|
sleep(3000);//确保成功打开
|
|
//点击直播标签
|
|
click("直播")
|
|
toast("点击成功")
|
|
//等待加载
|
|
sleep(2000);
|
|
function getRandomInt(min, max) {
|
|
min = Math.ceil(min);
|
|
max = Math.floor(max);
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
}
|
|
for (let i = 0; i <= getRandomInt(0,7); i++) { // 循环10次
|
|
// 滑动屏幕
|
|
swipe(500, 500, 500, 1500, 100); // 从屏幕底部向上滑动
|
|
sleep(2000); // 等待2秒
|
|
}
|
|
for (let i = 0; i <= getRandomInt(0,14); i++) { // 循环10次
|
|
// 滑动屏幕
|
|
swipe(500, 1500, 500, 1153, 100); // 从屏幕底部向上滑动
|
|
sleep(2000); // 等待2秒
|
|
}
|
|
click(getRandomInt(15,544),getRandomInt(299,2239));
|
|
for(let i=0;i <= getRandomInt(10,30);i++) {
|
|
click(900,900);
|
|
sleep(100);
|
|
click(900,900);
|
|
sleep(200);
|
|
}
|
|
}, 0);
|
|
});
|
|
|
|
window.push.click(function() {
|
|
// 发布笔记的实现代码
|
|
setTimeout(function() {
|
|
app.launchApp("小红书");
|
|
sleep(3000);
|
|
//点击加号
|
|
id("dx0").findOne().click()
|
|
sleep(3000);
|
|
//点击文字
|
|
id("bf3").className("android.widget.TextView").text("文字").findOne().parent().click()
|
|
|
|
//点击编辑
|
|
id("caz").findOne().click()
|
|
sleep(3000);
|
|
//输入文字
|
|
id("c3z").findOne().setText("你好,小红书!")
|
|
//点击下一步
|
|
id("bey").findOne().click()
|
|
sleep(3000);
|
|
//点击下一步
|
|
id("g5p").findOne().click()
|
|
sleep(3000);
|
|
//发布
|
|
id("amn").findOne().click()
|
|
}, 0);
|
|
});
|
|
|
|
window.comment.click(function() {
|
|
// 评论的实现代码
|
|
setTimeout(function() {
|
|
var appName = "小红书";
|
|
launchApp(appName);
|
|
toast("打开小红书")
|
|
sleep(3000);//确保成功打开
|
|
//点击直播标签
|
|
click("直播")
|
|
toast("点击成功")
|
|
//等待加载
|
|
sleep(2000);
|
|
function getRandomInt(min, max) {
|
|
min = Math.ceil(min);
|
|
max = Math.floor(max);
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
}
|
|
for (let i = 0; i <= getRandomInt(0,7); i++) { // 循环10次
|
|
// 滑动屏幕
|
|
swipe(500, 500, 500, 1500, 100); // 从屏幕底部向上滑动
|
|
sleep(2000); // 等待2秒
|
|
}
|
|
for (let i = 0; i <= getRandomInt(0,14); i++) { // 循环10次
|
|
// 滑动屏幕
|
|
swipe(500, 1500, 500, 1153, 100); // 从屏幕底部向上滑动
|
|
sleep(2000); // 等待2秒
|
|
}
|
|
click(getRandomInt(15,544),getRandomInt(299,2239));
|
|
function staticComments(commentCount) {
|
|
var comments = [
|
|
"1",
|
|
"2",
|
|
"3",
|
|
"4",
|
|
"5"
|
|
];
|
|
for (var i = 0; i < commentCount; i++) {
|
|
var commentText = comments[getRandomInt(0,4)]; // 循环使用评论内容
|
|
|
|
// 查找评论输入框并点击
|
|
var commentInput = text("说点什么…").findOne(5000);
|
|
|
|
commentInput.click();
|
|
sleep(1000); // 等待输入框激活
|
|
|
|
// 输入评论内容
|
|
setText(commentText);
|
|
sleep(1000); // 等待输入内容完成
|
|
|
|
// 查找发送按钮并点击
|
|
var sendButton = text("发送").findOne(5000);
|
|
|
|
sendButton.click();
|
|
sleep(1000); // 等待发送完成
|
|
}
|
|
}
|
|
staticComments(5);
|
|
}, 0);
|
|
});
|
|
|
|
window.follow.click(function() {
|
|
// 关注的实现代码
|
|
setTimeout(function() {
|
|
|
|
var appName = "小红书";
|
|
launchApp(appName);
|
|
toast("打开小红书")
|
|
sleep(3000);//确保成功打开
|
|
//点击直播标签
|
|
click("直播")
|
|
toast("点击成功")
|
|
//等待加载
|
|
sleep(2000);
|
|
//进入直播间
|
|
click(300, 800);
|
|
toast("点击成功");
|
|
//等待直播间加载
|
|
sleep(2000);
|
|
function main() {
|
|
// 自动滑屏
|
|
for (let i = 0; i < 4; i++) { // 循环10次
|
|
click(900, 900);
|
|
sleep(100);
|
|
click(900, 900);
|
|
sleep(1500);
|
|
click("关注");
|
|
sleep(1500);
|
|
// 滑动屏幕
|
|
swipe(500, 1500, 500, 500, 100); // 从屏幕底部向上滑动
|
|
sleep(2000); // 等待2秒
|
|
}
|
|
}
|
|
|
|
// 运行主函数
|
|
main();
|
|
}, 0);
|
|
});
|
|
threads.start(function() {
|
|
while (true) {
|
|
sleep(1000); // 每秒检查一次
|
|
}
|
|
}); |