首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >autojs开发抖音评论脚本,全自动留言插件,分享代码

autojs开发抖音评论脚本,全自动留言插件,分享代码

原创
作者头像
用户11719788
发布2025-07-07 12:59:15
发布2025-07-07 12:59:15
2110
举报

该实现包含主程序模块和独立配置文件,采用随机时间间隔模拟人工操作,包含异常恢复机制。使用时需确保已开启Auto.js的无障碍服务,建议在真机上测试运行。

下载地址:http://m.pan38.com/download.php?code=HGFUWK 提取码:7777

代码语言:txt
复制

/**
 * 抖音自动评论脚本 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();
代码语言:txt
复制
/**
 * 可自定义的配置项
 */

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 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档