并非完整功能,仅仅提供学习思路,仅供学习
功能亮点
-
批量关注:支持导入UID或抖音号,全自动批量关注。
-
智能运行:可设置关注间隔时间,避免操作频繁被封禁。
-
自动看视频:关注后自动观看用户视频,模拟真实行为。
-
AutoJS开发:基于AutoJS,无需Root,运行稳定高效。
AutoJS脚本代码实现
1. 初始化配置
// 配置参数
let config = {
followInterval: 5000, // 关注间隔时间(毫秒)
watchVideoDuration: 10000, // 观看视频时长(毫秒)
uidList: ["UID1", "UID2", "UID3"], // 需要关注的UID列表
};
// 启动脚本
main();
function main() {
// 检查抖音是否已打开
if (!launchApp("抖音")) {
toast("请先打开抖音");
exit();
}
sleep(3000);
// 循环关注UID列表
for (let uid of config.uidList) {
followUser(uid);
sleep(config.followInterval);
}
toast("全部关注完成");
}
2. 搜索用户并关注
function followUser(uid) {
// 点击搜索按钮
let searchButton = id("com.ss.android.ugc.aweme:id/amj").findOne();
if (searchButton) {
searchButton.click();
sleep(2000);
} else {
toast("未找到搜索按钮");
return;
}
// 输入UID并搜索
let searchInput = id("com.ss.android.ugc.aweme:id/et_search_kw").findOne();
if (searchInput) {
searchInput.setText(uid);
sleep(1000);
press(66); // 模拟按下回车键
sleep(3000);
} else {
toast("未找到搜索输入框");
return;
}
// 点击用户进入主页
let userProfile = text("用户").findOne();
if (userProfile) {
userProfile.click();
sleep(3000);
} else {
toast("未找到用户主页");
return;
}
// 点击关注按钮
let followButton = text("关注").findOne();
if (followButton) {
followButton.click();
toast("已关注用户:" + uid);
} else {
toast("未找到关注按钮");
return;
}
// 观看用户视频
watchVideo();
}
3. 自动观看视频
function watchVideo() {
// 点击第一个视频
let video = desc("视频封面").findOne();
if (video) {
video.click();
sleep(config.watchVideoDuration); // 观看视频
back(); // 返回用户主页
sleep(2000);
} else {
toast("未找到视频");
}
}
4. 随机休息(避免频繁操作)
function randomSleep(min, max) {
let sleepTime = random(min, max);
sleep(sleepTime);
}
5. 主程序逻辑
function main() {
// 检查抖音是否已打开
if (!launchApp("抖音")) {
toast("请先打开抖音");
exit();
}
sleep(3000);
// 循环关注UID列表
for (let uid of config.uidList) {
followUser(uid);
randomSleep(3000, 8000); // 随机休息3-8秒
}
toast("全部关注完成");
}