下载地址:m.pan38.com/download.ph… 提取码:7777
脚本实现了抖音的自动化点赞、关注和评论功能。代码包含了完整的配置选项、错误处理和日志记录。使用时需要AutoJS环境,并授予必要的权限。请注意合理使用,避免对他人造成困扰。
// 抖音自动化脚本 by 百度AI
// 需要AutoJS 4.1.1以上版本
// 请勿用于商业用途
// 基础配置
let config = {
likeCount: 50, // 点赞数量
followCount: 20, // 关注数量
commentList: ["好看!", "太棒了", "666", "喜欢这个视频"], // 评论内容池
scrollDelay: 3000, // 滑动间隔(ms)
operationDelay: 1500, // 操作间隔(ms)
maxRunTime: 30 * 60 * 1000 // 最大运行时间(30分钟)
};
// 主函数
function main() {
auto.waitFor();
console.show();
console.log("抖音自动化脚本启动");
launchApp("抖音");
sleep(3000);
let startTime = new Date().getTime();
let processed = 0;
while (new Date().getTime() - startTime < config.maxRunTime) {
processVideo();
processed++;
// 滑动到下一个视频
swipeVideo();
sleep(config.scrollDelay);
if (processed >= config.likeCount && processed >= config.followCount) {
break;
}
}
console.log("脚本执行完成");
}
// 处理当前视频
function processVideo() {
// 点赞
if (randomClick("com.ss.android.ugc.aweme:id/ah6", 0.8)) {
console.log("点赞成功");
sleep(config.operationDelay);
}
// 关注
if (randomClick("com.ss.android.ugc.aweme:id/gxy", 0.3)) {
console.log("关注成功");
sleep(config.operationDelay);
}
// 随机评论
if (Math.random() < 0.2) {
postComment();
}
}
// 发表评论
function postComment() {
let commentBtn = id("com.ss.android.ugc.aweme:id/dy1").findOne(1000);
if (commentBtn) {
commentBtn.click();
sleep(1000);
let input = id("com.ss.android.ugc.aweme:id/dy_").findOne(1000);
if (input) {
let randomComment = config.commentList[Math.floor(Math.random() * config.commentList.length)];
input.setText(randomComment);
sleep(500);
let sendBtn = id("com.ss.android.ugc.aweme:id/dz0").findOne(1000);
if (sendBtn) {
sendBtn.click();
console.log("评论成功: " + randomComment);
sleep(config.operationDelay);
}
}
// 返回
back();
sleep(1000);
}
}
// 滑动视频
function swipeVideo() {
let width = device.width;
let height = device.height;
let startY = height * 0.8;
let endY = height * 0.2;
swipe(width / 2, startY, width / 2, endY, 500);
}
// 随机点击控件
function randomClick(idStr, probability) {
if (Math.random() > probability) return false;
let widget = id(idStr).findOne(1000);
if (widget) {
let bounds = widget.bounds();
click(bounds.centerX(), bounds.centerY());
return true;
}
return false;
}
// 启动APP
function launchApp(appName) {
let packageName = getPackageName(appName);
if (!packageName) {
console.error("找不到应用: " + appName);
return false;
}
app.launch(packageName);
return true;
}
// 获取包名
function getPackageName(appName) {
let appMap = {
"抖音": "com.ss.android.ugc.aweme",
"抖音极速版": "com.ss.android.ugc.aweme.lite"
};
return appMap[appName] || null;
}
// 执行主函数
main();