下载地址:https://www.pan38.com/dow/share.php?code=JCnzE 提取密码:1133
该脚本主要包含以下技术特点:
支持三大主流短视频平台自动识别
采用随机时间间隔模拟人工操作
包含完善的异常恢复机制
通过无障碍服务实现精准控件定位
可配置的运行参数和调试模式
/**
- 多平台头像点赞脚本 - AutoJS实现版
- 功能:自动识别抖音/快手/小红书平台,执行头像点赞操作
- 特性:随机延迟防检测、异常恢复、多平台适配
*/
// ========== 全局配置 ==========
const CONFIG = {
platform: "auto", // 可指定douyin/kuaishou/xiaohongshu
maxRunTime: 3600000, // 最大运行时间(ms)
likeDelay: [1500, 5000], // 点赞随机延迟(ms)
scrollDelay: [3000, 8000], // 滚动间隔(ms)
debugMode: true // 调试模式
};
// 平台元素选择器配置
const SELECTORS = {
douyin: {
avatar: "desc('头像')", // 抖音头像元素
likeBtn: "desc('未点赞')", // 点赞按钮
mainTab: "text('首页')", // 主Tab
profileTab: "desc('我')" // 个人主页
},
kuaishou: {
avatar: "desc('头像')",
likeBtn: "desc('喜欢')",
mainTab: "text('发现')",
profileTab: "desc('我的')"
},
xiaohongshu: {
avatar: "desc('头像')",
likeBtn: "desc('点赞')",
mainTab: "text('首页')",
profileTab: "desc('我的')"
}
};
// ========== 核心功能类 ==========
class AvatarLiker {
constructor(config) {
this.config = config;
this.platform = this.detectPlatform();
this.startTime = Date.now();
this.likeCount = 0;
this.setupScreenMetrics();
}
// 设置屏幕适配
setupScreenMetrics() {
if (device.width > 0 && device.height > 0) {
setScreenMetrics(device.width, device.height);
} else {
setScreenMetrics(1080, 2340); // 默认分辨率
}
}
// 平台检测
detectPlatform() {
if (CONFIG.platform !== "auto") return CONFIG.platform;
const apps = {
douyin: ["抖音", "com.ss.android.ugc.aweme"],
kuaishou: ["快手", "com.kuaishou.nebula"],
xiaohongshu: ["小红书", "com.xingin.xhs"]
};
for (const [platform, [appName, pkg]] of Object.entries(apps)) {
if (currentPackage() === pkg) return platform;
if (launch(appName)) {
sleep(3000);
return platform;
}
}
return "douyin"; // 默认抖音
}
// 主执行流程
start() {
this.showConsole();
this.prepareEnvironment();
while (this.checkRunningTime()) {
try {
this.scrollAndLike();
this.randomSleep(this.config.scrollDelay);
} catch (e) {
this.handleError(e);
}
}
this.finish();
}
// 滚动并点赞
scrollAndLike() {
const { avatar, likeBtn } = SELECTORS[this.platform];
const avatars = this.findElements(avatar);
if (avatars && avatars.length > 0) {
for (const av of avatars) {
if (!this.checkRunningTime()) break;
// 点击头像进入主页
av.click();
sleep(this.randomDelay(2000, 4000));
// 尝试点赞
if (this.tryLike()) {
this.likeCount++;
log(`成功点赞 ${this.likeCount} 次`);
}
// 返回列表页
back();
sleep(this.randomDelay(1000, 3000));
}
} else {
// 无头像时滚动
this.randomScroll();
}
}
// 尝试点赞
tryLike() {
const { likeBtn } = SELECTORS[this.platform];
const btn = this.findElement(likeBtn);
if (btn) {
btn.click();
sleep(this.randomDelay(this.config.likeDelay));
return true;
}
return false;
}
// 随机滚动
randomScroll() {
const startY = device.height 0.7;
const endY = device.height 0.3;
const x = device.width / 2;
swipe(x, startY, x, endY, 500);
}
// ========== 工具方法 ==========
findElement(selector, timeout = 2000) {
return selector ? selector.findOne(timeout) : null;
}
findElements(selector) {
return selector ? selector.find() : [];
}
randomDelay(range = [1000, 3000]) {
return Array.isArray(range)
? random(range[0], range[1])
: range;
}
randomSleep(range) {
sleep(this.randomDelay(range));
}
showConsole() {
if (CONFIG.debugMode) {
console.show();
console.setSize(device.width / 2, device.height / 3);
}
}
prepareEnvironment() {
device.keepScreenOn();
auto.waitFor();
events.observeKey();
events.onKeyDown("volume_down", () => {
toast("脚本手动停止");
exit();
});
}
checkRunningTime() {
return Date.now() - this.startTime < this.config.maxRunTime;
}
handleError(e) {
log(发生错误: ${e});
sleep(5000);
this.recover();
}
recover() {
if (this.platform === "douyin") {
launch("抖音");
} else if (this.platform === "kuaishou") {
launch("快手");
} else {
launch("小红书");
}
sleep(5000);
}
finish() {
toast(任务完成,共点赞 ${this.likeCount} 次);
device.cancelKeepingAwake();
if (CONFIG.debugMode) console.hide();
}
}
// ========== 脚本入口 ==========
auto.waitFor();
new AvatarLiker(CONFIG).start();