该实现包含主程序模块和独立配置文件,采用随机时间间隔模拟人工操作,包含异常恢复机制。使用时需确保已开启Auto.js的无障碍服务,建议在真机上测试运行。
下载地址:http://m.pan38.com/download.php?code=HGFUWK 提取码:7777
/**
* 抖音自动评论脚本 v1.0
* 功能:自动滑动视频并随机评论
* 需要:Auto.js 4.1.1+ 安卓7.0+
*/
// ===== 基础配置 =====
const CONFIG = {
commentList: [
"这个视频太棒了!",
"作者加油💪",
"哈哈哈笑死我了",
"点赞收藏了",
"求更新下一集",
"背景音乐是什么呀?",
"已关注,求回关",
"这个特效怎么做的?"
],
runTime: 2 * 60 * 60 * 1000, // 运行时长(ms)
swipeInterval: [15, 25] // 滑动间隔(秒)
};
// ===== 主程序 =====
function main() {
prepare();
let startTime = new Date().getTime();
while (new Date().getTime() - startTime < CONFIG.runTime) {
try {
swipeVideo();
let waitTime = random(...CONFIG.swipeInterval);
sleep(waitTime * 1000);
if (randomComment()) {
log("评论成功");
} else {
log("未找到评论入口");
}
} catch (e) {
log("发生错误:" + e);
recover();
}
}
}
// ===== 功能函数 =====
function prepare() {
auto.waitFor();
device.wakeUp();
launchApp("抖音");
sleep(3000);
}
function swipeVideo() {
let width = device.width;
let height = device.height;
swipe(width / 2, height * 0.8, width / 2, height * 0.2, 500);
}
function randomComment() {
let commentBtn = text("添加评论").findOne(3000);
if (!commentBtn) return false;
commentBtn.click();
sleep(1000);
let input = className("EditText").findOne(2000);
if (!input) return false;
let randomText = CONFIG.commentList[random(0, CONFIG.commentList.length - 1)];
input.setText(randomText);
sleep(500);
let sendBtn = text("发送").findOne(1000);
if (sendBtn) {
sendBtn.click();
sleep(1500);
return true;
}
return false;
}
function recover() {
back();
sleep(1000);
back();
sleep(1000);
home();
sleep(1000);
launchApp("抖音");
sleep(3000);
}
// ===== 工具函数 =====
function random(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// ===== 执行 =====
main();
/**
* 可自定义的配置项
*/
module.exports = {
// 评论内容池
comments: [
"优质内容!",
"已三连支持",
"这个运镜太专业了",
"BGM好评",
"求教程",
"关注了期待更新",
"这个转场怎么做的?",
"看了10遍不过瘾"
],
// 行为参数
behavior: {
likeVideo: true, // 是否自动点赞
followAuthor: false, // 是否关注作者
maxComments: 50 // 最大评论数
},
// 时间控制(秒)
timing: {
minWatchTime: 10,
maxWatchTime: 30,
retryDelay: 5
}
};
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。