下载地址:www.pan38.com/dow/share.p… 提取密码:2311
该实现包含以下技术要点:
多平台适配机制,通过packageName识别当前运行环境 随机延迟操作模拟人工行为,降低封号风险 异常恢复机制确保脚本长期稳定运行 模块化设计便于功能扩展和维护
` // 基础配置 const CONFIG = { platforms: ["douyin", "kuaishou", "xiaohongshu"], comments: [ "内容很棒!", "已三连求回访~", "这个太实用了!", "请问哪里买的?", "收藏了慢慢看" ], actionDelay: [1500, 3000], maxRuntime: 3600000 };
// 主程序 auto(); device.keepScreenOn(); let startTime = new Date().getTime();
while (new Date().getTime() - startTime < CONFIG.maxRuntime) { try { const platform = randomChoice(CONFIG.platforms); launchApp(platform); sleep(3000);
switch(platform) {
case "douyin":
handleDouyin();
break;
case "kuaishou":
handleKuaishou();
break;
case "xiaohongshu":
handleXiaohongshu();
break;
}
sleep(random(...CONFIG.actionDelay));
} catch(e) { recoverApp(); } }
// 抖音处理模块 function handleDouyin() { if (desc("评论区").exists()) { const commentBtn = desc("评论区").findOne().parent(); commentBtn.click(); sleep(2000);
if (id("comment_input").exists()) {
const comment = randomChoice(CONFIG.comments);
id("comment_input").findOne().setText(comment);
sleep(1000);
text("发送").findOne().click();
}
} }
// 快手处理模块 function handleKuaishou() { if (className("android.widget.LinearLayout").id("comment_button").exists()) { className("android.widget.LinearLayout").id("comment_button").findOne().click(); sleep(2000);
if (id("comment_editor_holder_text").exists()) {
const comment = randomChoice(CONFIG.comments);
id("comment_editor_holder_text").findOne().click();
setText(0, comment);
sleep(1000);
text("发送").findOne().click();
}
} }
// 小红书处理模块 function handleXiaohongshu() { if (desc("评论").exists()) { desc("评论").findOne().click(); sleep(2000);
if (className("android.widget.EditText").exists()) {
const comment = randomChoice(CONFIG.comments);
className("android.widget.EditText").findOne().setText(comment);
sleep(1000);
text("发布").findOne().click();
}
} }
// 工具函数 function randomChoice(arr) { return arr[Math.floor(Math.random() * arr.length)]; }
function random(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }
function recoverApp() { home(); sleep(1000); } `