下载地址:https://www.pan38.com/share.php?code=CNmUz 提取码:8888
当然这里分享的仅仅只是部分逻辑代码,并非完整的,仅供学习用!!!
功能亮点
自动私信:支持自定义话术,批量发送私信。
自动关注:私信后自动关注用户,提升互动率。
养号操作:模拟真实用户行为,如观看视频、点赞等。
AutoJS开发:无需Root,运行稳定高效。
AutoJS脚本代码实现
- 初始化配置
// 配置参数
let config = {
message: "你好,很高兴认识你!", // 自定义私信话术
followInterval: 5000, // 关注间隔时间(毫秒)
watchVideoDuration: 10000, // 观看视频时长(毫秒)
likeProbability: 0.5, // 点赞概率(0-1)
uidList: ["UID1", "UID2", "UID3"], // 需要私信的UID列表
};
// 启动脚本
main();
function main() {
// 检查抖音是否已打开
if (!launchApp("抖音")) {
toast("请先打开抖音");
exit();
}
sleep(3000);
// 循环处理UID列表
for (let uid of config.uidList) {
sendMessageAndFollow(uid);
randomSleep(3000, 8000); // 随机休息3-8秒
}
toast("全部操作完成");
}
- 搜索用户并进入主页
function searchUser(uid) {
// 点击搜索按钮
let searchButton = id("com.ss.android.ugc.aweme:id/amj").findOne();
if (searchButton) {
searchButton.click();
sleep(2000);
} else {
toast("未找到搜索按钮");
return false;
}
// 输入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 false;
}
// 点击用户进入主页
let userProfile = text("用户").findOne();
if (userProfile) {
userProfile.click();
sleep(3000);
return true;
} else {
toast("未找到用户主页");
return false;
}
}
- 发送私信
function sendMessage(uid) {
// 点击私信按钮
let messageButton = text("私信").findOne();
if (messageButton) {
messageButton.click();
sleep(3000);
} else {
toast("未找到私信按钮");
return;
}
// 输入话术并发送
let messageInput = id("com.ss.android.ugc.aweme:id/et_input").findOne();
if (messageInput) {
messageInput.setText(config.message);
sleep(1000);
let sendButton = id("com.ss.android.ugc.aweme:id/aoh").findOne();
if (sendButton) {
sendButton.click();
toast("已发送私信给用户:" + uid);
} else {
toast("未找到发送按钮");
}
} else {
toast("未找到私信输入框");
}
}
- 自动关注用户
function followUser() {
// 点击关注按钮
let followButton = text("关注").findOne();
if (followButton) {
followButton.click();
toast("已关注用户");
} else {
toast("未找到关注按钮");
}
}
- 养号操作(观看视频、点赞)
function watchAndLikeVideo() {
// 点击第一个视频
let video = desc("视频封面").findOne();
if (video) {
video.click();
sleep(config.watchVideoDuration); // 观看视频
// 随机点赞
if (Math.random() < config.likeProbability) {
let likeButton = desc("点赞").findOne();
if (likeButton) {
likeButton.click();
toast("已点赞视频");
}
}
back(); // 返回用户主页
sleep(2000);
} else {
toast("未找到视频");
}
}
- 主逻辑:私信 + 关注 + 养号
function sendMessageAndFollow(uid) {
if (searchUser(uid)) {
sendMessage(uid); // 发送私信
followUser(); // 关注用户
watchAndLikeVideo(); // 养号操作
}
}
- 随机休息(避免频繁操作)
function randomSleep(min, max) {
let sleepTime = random(min, max);
sleep(sleepTime);
}