下载地址:https://www.pan38.com/dow/share.php?code=JCnzE 提取密码:1133
代码说明:这个Auto.js脚本包含主模块、工具函数和配置文件三个部分,实现了自动浏览、点赞、评论等功能。使用时需要开启无障碍服务和屏幕截图权限。
// 快手自动化工具 v1.0
// 主要功能:自动浏览、点赞、评论等操作
const _KS = {
config: {
runTime: 60 60 1000, // 运行时长(ms)
likeRate: 0.7, // 点赞概率
commentRate: 0.3, // 评论概率
followRate: 0.1, // 关注概率
swipeInterval: [8000, 15000], // 滑动间隔(ms)
comments: [
"真不错!",
"666",
"太棒了",
"支持一下",
"继续加油",
"👍👍👍"
]
},
// 初始化函数
init: function() {
auto.waitFor();
device.keepScreenOn();
this.checkPermission();
this.mainLoop();
},
// 权限检查
checkPermission: function() {
if (!requestScreenCapture()) {
toast("请授予屏幕截图权限");
exit();
}
if (!auto.service) {
toast("请开启无障碍服务");
exit();
}
},
// 主循环
mainLoop: function() {
const startTime = new Date().getTime();
let count = 0;
while (new Date().getTime() - startTime < this.config.runTime) {
count++;
this.processVideo();
this.randomSwipe();
sleep(random(...this.config.swipeInterval));
}
toast(`运行结束,共处理${count}个视频`);
device.cancelKeepingAwake();
},
// 处理当前视频
processVideo: function() {
// 随机点赞
if (Math.random() < this.config.likeRate) {
this.likeVideo();
}
// 随机评论
if (Math.random() < this.config.commentRate) {
this.postComment();
}
// 随机关注
if (Math.random() < this.config.followRate) {
this.followAuthor();
}
},
// 点赞视频
likeVideo: function() {
const likeBtn = id("like_button").findOne(2000);
if (likeBtn) {
likeBtn.click();
sleep(500);
}
},
// 发表评论
postComment: function() {
const commentBtn = id("comment_button").findOne(2000);
if (commentBtn) {
commentBtn.click();
sleep(1000);
const commentInput = id("comment_edit").findOne(2000);
if (commentInput) {
const randomComment = this.config.comments[
Math.floor(Math.random() * this.config.comments.length)
];
commentInput.setText(randomComment);
sleep(500);
const sendBtn = id("send_comment").findOne(1000);
if (sendBtn) {
sendBtn.click();
sleep(1000);
}
}
// 返回
back();
sleep(500);
}
},
// 关注作者
followAuthor: function() {
const followBtn = id("follow_button").findOne(2000);
if (followBtn) {
followBtn.click();
sleep(500);
}
},
// 随机滑动
randomSwipe: function() {
const width = device.width;
const height = device.height;
const startX = width / 2;
const startY = height * 0.8;
const endY = height * 0.2;
swipe(startX, startY, startX, endY, 500);
}
};
// 启动脚本
_KS.init();