回答
文档地址 https://docs.hamibot.com/
// 引入仿真滑动函数(基于贝塞尔曲线)
function getBezierPath(p1, p2, p3, p4, times) {
function Point2D(x, y) {
this.x = x || 0.0;
this.y = y || 0.0;
}
function PointOnCubicBezier(cp, t) {
var ax, bx, cx;
var ay, by, cy;
var tSquared, tCubed;
var result = new Point2D();
cx = 3.0 * (cp[1].x - cp[0].x);
bx = 3.0 * (cp[2].x - cp[1].x) - cx;
ax = cp[3].x - cp[0].x - cx - bx;
cy = 3.0 * (cp[1].y - cp[0].y);
by = 3.0 * (cp[2].y - cp[1].y) - cy;
ay = cp[3].y - cp[0].y - cy - by;
tSquared = t * t;
tCubed = tSquared * t;
result.x = ax * tCubed + bx * tSquared + cx * t + cp[0].x;
result.y = ay * tCubed + by * tSquared + cy * t + cp[0].y;
return result;
}
function ComputeBezier(cp, numberOfPoints, curve) {
var dt = 1.0 / (numberOfPoints - 1);
for (var i = 0; i < numberOfPoints; i++) {
curve[i] = PointOnCubicBezier(cp, i * dt);
}
}
var cp = [
new Point2D(parseInt(p4[0]), parseInt(p4[1])),
new Point2D(p2[0], p2[1]),
new Point2D(p3[0], p3[1]),
new Point2D(p1[0], p1[1])
];
var curve = [];
ComputeBezier(cp, times, curve);
return curve;
}
// 下滑刷新(从下往上滑)
function swipeUp(dw, dh, duration) {
if (!(typeof duration === 'number' && !isNaN(duration) && duration > 0)) {
duration = random(7000, 10000); // 随机7-10秒滑动时间
}
var grid = Math.round(dw * 0.1);
var xStart = Math.round(dw * 0.3);
var xEnd = Math.round(dw * 0.7);
var yStart = Math.round(dh * 0.25);
var yEnd = Math.round(dh * 0.85);
var start = [random(xStart, xEnd), random(yEnd - grid / 2, yEnd + grid / 2)];
var end = [random(xStart, xEnd), random(yStart, yStart + grid / 2)];
var ctl1 = null;
var ctl2 = null;
var sign = Math.round(Math.random());
if (sign === 0) {
ctl1 = [end[0] - random(grid, grid * 2), end[1] - random(0, grid)];
ctl2 = [end[0] + random(grid, grid * 2), end[1] + random(0, grid)];
} else {
ctl1 = [end[0] + random(grid, grid * 2), end[1] + random(0, grid)];
ctl2 = [end[0] - random(grid, grid * 2), end[1] - random(0, grid)];
}
var path = getBezierPath(end, ctl1, ctl2, start, 100);
var parms = [duration];
for (var i = 0; i < path.length; i++) {
parms.push([path[i].x, path[i].y]);
}
gesture.apply(null, parms);
}
// 振动函数
function vibrate() {
device.vibrate(500); // 振动500毫秒
}
// 判断是否在直播间(根据文字或控件判断)
function isInLiveRoom() {
return text("直播间").exists() || descContains("直播").exists() || idContains("live").exists();
}
// 主循环
auto.waitFor(); // 确保无障碍服务启动
while (true) {
// 检测验证码
if (textContains("验证").
ℹ️ 本回答由 AI 生成,内容仅供参考