下载地址:http://m.pan38.com/download.php?code=HGFUWK 提取码:6666
脚本提供了完整的抖音自动化操作功能,包括随机滑动视频、点赞、关注、评论和私信。代码中包含了详细的注释和配置选项,您可以根据需要调整参数。使用时请确保已授予Auto.js必要的权限。
/**
- 抖音自动化脚本 v1.0
- 功能:自动评论、点赞、关注、私信
- 需要:Auto.js 4.1.1+ 版本
- 权限:无障碍服务、悬浮窗权限
*/
// 基础配置
const config = {
commentList: ["真不错!", "太棒了!", "学到了", "666", "感谢分享"],
privateMessage: "你好,我很喜欢你的内容,交个朋友吧!",
runTime: 30 60 1000, // 运行30分钟
scrollDelay: 3000, // 滑动间隔
actionDelay: 1500, // 操作间隔
maxLike: 50, // 最大点赞数
maxFollow: 20, // 最大关注数
maxComment: 30 // 最大评论数
};
// 主函数
function main() {
// 检查抖音是否已安装
if (!launchApp("抖音")) {
toast("请先安装抖音");
exit();
}
// 等待抖音启动
sleep(5000);
// 记录已执行操作
let stats = {
liked: 0,
followed: 0,
commented: 0,
messaged: 0
};
// 开始时间
const startTime = new Date().getTime();
// 主循环
while (new Date().getTime() - startTime < config.runTime) {
// 随机滑动视频
randomScroll();
// 随机执行操作
const action = randomAction();
switch (action) {
case 'like':
if (stats.liked < config.maxLike && likeVideo()) {
stats.liked++;
log("点赞成功,总数: " + stats.liked);
}
break;
case 'follow':
if (stats.followed < config.maxFollow && followAuthor()) {
stats.followed++;
log("关注成功,总数: " + stats.followed);
}
break;
case 'comment':
if (stats.commented < config.maxComment && postComment()) {
stats.commented++;
log("评论成功,总数: " + stats.commented);
}
break;
case 'message':
if (stats.messaged < 5 && sendPrivateMessage()) { // 私信限制更严格
stats.messaged++;
log("私信成功,总数: " + stats.messaged);
}
break;
}
// 随机延迟
sleep(config.actionDelay + random(0, 1000));
}
// 输出统计信息
toast("任务完成\n点赞: " + stats.liked + "\n关注: " + stats.followed +
"\n评论: " + stats.commented + "\n私信: " + stats.messaged);
}
// 随机滑动视频
function randomScroll() {
const x = device.width / 2;
const startY = device.height 0.8;
const endY = device.height 0.2;
// 随机向上或向下滑动
if (random(0, 1) > 0.5) {
swipe(x, startY, x, endY, 500);
} else {
swipe(x, endY, x, startY, 500);
}
sleep(config.scrollDelay + random(0, 1000));
}
// 点赞视频
function likeVideo() {
const likeBtn = id("aweme").findOne().findOne(id("like"));
if (likeBtn && likeBtn.click()) {
sleep(1000);
return true;
}
return false;
}
// 关注作者
function followAuthor() {
const followBtn = id("follow").findOne();
if (followBtn && followBtn.click()) {
sleep(1000);
return true;
}
return false;
}
// 发表评论
function postComment() {
// 点击评论按钮
const commentBtn = id("comment").findOne();
if (!commentBtn || !commentBtn.click()) return false;
sleep(1000);
// 输入随机评论
const commentInput = className("EditText").findOne();
if (!commentInput) return false;
const randomComment = config.commentList[random(0, config.commentList.length - 1)];
commentInput.setText(randomComment);
sleep(500);
// 点击发送按钮
const sendBtn = text("发送").findOne();
if (!sendBtn || !sendBtn.click()) return false;
sleep(1000);
// 返回视频页面
back();
return true;
}
// 发送私信
function sendPrivateMessage() {
// 进入作者主页
const authorBtn = id("author").findOne();
if (!authorBtn || !authorBtn.click()) return false;
sleep(2000);
// 点击私信按钮
const messageBtn = text("私信").findOne();
if (!messageBtn || !messageBtn.click()) return false;
sleep(2000);
// 输入私信内容
const messageInput = className("EditText").findOne();
if (!messageInput) {
back();
sleep(1000);
back();
return false;
}
messageInput.setText(config.privateMessage);
sleep(500);
// 点击发送按钮
const sendBtn = text("发送").findOne();
if (!sendBtn || !sendBtn.click()) {
back();
sleep(1000);
back();
return false;
}
sleep(1000);
// 返回视频页面
back();
sleep(1000);
back();
return true;
}
// 随机选择操作
function randomAction() {
const actions = ['like', 'follow', 'comment', 'message'];
const weights = [0.4, 0.3, 0.2, 0.1]; // 操作权重
let rand = Math.random();
let sum = 0;
for (let i = 0; i < actions.length; i++) {
sum += weights[i];
if (rand <= sum) {
return actions[i];
}
}
return 'like'; // 默认返回点赞
}
// 启动脚本
auto.waitFor();
main();