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.
87 lines
2.8 KiB
87 lines
2.8 KiB
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('脚本已结束.');
|