下载地址:http://m.pan38.com/download.php?code=MOQYVN 提取码:5564
AutoJS脚本实现了抖音直播间的自动互动功能,包括持续点赞、关注主播和收藏商品。代码中包含了详细的注释说明每个函数的功能。使用时需要确保已授予AutoJS必要的权限,并在抖音直播间界面运行。调试模式可以帮助了解脚本运行状态。
/**
- 抖音直播间自动互动脚本
- 功能:自动点赞、关注主播、收藏商品
- 使用AutoJS实现
*/
// 基础配置参数
let config = {
likeInterval: 1000, // 点赞间隔(ms)
maxLikeCount: 500, // 最大点赞次数
followAnchor: true, // 是否关注主播
collectProduct: true, // 是否收藏商品
debugMode: false // 调试模式
};
// 主函数
function main() {
if (!requestScreenCapture()) {
toast("请求截图权限失败");
exit();
}
toast("脚本开始运行");
sleep(2000);
// 检查是否在抖音直播间
if (!isInLiveRoom()) {
toast("未检测到抖音直播间");
exit();
}
// 执行互动任务
let likeCount = 0;
while (likeCount < config.maxLikeCount) {
// 自动点赞
autoLike();
likeCount++;
// 关注主播(只执行一次)
if (likeCount === 1 && config.followAnchor) {
followAnchor();
}
// 收藏商品(每50次点赞检查一次)
if (likeCount % 50 === 0 && config.collectProduct) {
collectProduct();
}
sleep(config.likeInterval);
}
toast("脚本执行完成");
}
// 自动点赞函数
function autoLike() {
let likeBtn = findLikeButton();
if (likeBtn) {
click(likeBtn.bounds().centerX(), likeBtn.bounds().centerY());
if (config.debugMode) {
toast("点赞成功");
}
return true;
}
return false;
}
// 查找点赞按钮
function findLikeButton() {
let screen = captureScreen();
let likeBtn = images.findMultiColors(screen, "#FF4E64", [
[0, -30, "#FF2D55"],
[0, 30, "#FF2D55"]
], {
region: [device.width - 200, device.height / 2, 200, 300],
threshold: 10
});
if (likeBtn) {
return likeBtn;
}
// 备用查找方式
let likeText = textContains("点赞").findOne(1000);
if (likeText) {
return likeText.parent();
}
return null;
}
// 关注主播
function followAnchor() {
let followBtn = textContains("关注").findOne(2000);
if (followBtn) {
click(followBtn.bounds().centerX(), followBtn.bounds().centerY());
sleep(1000);
// 处理可能出现的弹窗
let confirmBtn = textContains("确定").findOne(500);
if (confirmBtn) {
click(confirmBtn.bounds().centerX(), confirmBtn.bounds().centerY());
}
if (config.debugMode) {
toast("关注主播成功");
}
return true;
}
return false;
}
// 收藏商品
function collectProduct() {
// 打开商品列表
let productBtn = descContains("商品").findOne(2000);
if (!productBtn) {
return false;
}
click(productBtn.bounds().centerX(), productBtn.bounds().centerY());
sleep(2000);
// 查找收藏按钮
let collectBtns = descContains("收藏").find();
if (collectBtns.empty()) {
back();
return false;
}
// 收藏第一个未收藏的商品
for (let i = 0; i < collectBtns.length; i++) {
let btn = collectBtns[i];
if (btn.text().includes("收藏")) {
click(btn.bounds().centerX(), btn.bounds().centerY());
sleep(1000);
if (config.debugMode) {
toast("收藏商品成功");
}
break;
}
}
back(); // 返回直播间
return true;
}
// 检查是否在直播间
function isInLiveRoom() {
let liveIndicator = descContains("直播间").findOne(2000);
if (liveIndicator) {
return true;
}
let liveText = textContains("直播").findOne(2000);
if (liveText) {
return true;
}
return false;
}
// 启动脚本
main();