下载地址:https://www.pan38.com/share.php?code=pvvmX 提取码:8888 【仅供学习】
// 无障碍服务检测
auto.waitFor();
console.show(); // 开启悬浮窗日志
const $ = require('./selector_engine'); // 自定义选择器引擎
// 代理控制器主类
class ProxyController {
constructor(config) {
this.taskQueue = []; // 任务队列
this.threadPool = []; // 线程池
this.maxThreads = config.maxThreads || 3;
this.isRunning = false;
this.lastOperationTime = 0;
}
// 启动代理服务
start() {
this.isRunning = true;
threads.start(() => this._dispatchTasks());
}
// 任务分发器
_dispatchTasks() {
while (this.isRunning) {
if (this.taskQueue.length > 0 &&
this.threadPool.length < this.maxThreads) {
const task = this.taskQueue.shift();
this._executeTask(task);
}
sleep(200);
}
}
// 执行任务(需被子类重写)
_executeTask(task) {
throw new Error("Not implemented");
}
}
// 继承基础控制器
class MeituanGrabber extends ProxyController {
constructor() {
super({ maxThreads: 5 });
this.priceThreshold = 30; // 最低接单价格
this.distanceLimit = 5; // 最大配送距离(km)
}
// 重写任务执行方法
_executeTask(task) {
const thread = threads.start(() => {
try {
this._grabOrder(task.orderId);
} catch (e) {
console.error("抢单失败:", e);
} finally {
this.threadPool.splice(this.threadPool.indexOf(thread), 1);
}
});
this.threadPool.push(thread);
}
// 核心抢单逻辑
_grabOrder(orderId) {
const orderInfo = this._parseOrder(orderId);
if (orderInfo.price < this.priceThreshold ||
orderInfo.distance > this.distanceLimit) {
return false;
}
// 模拟人工操作轨迹
this._randomSwipe();
const grabBtn = $().id("com.meituan.banma:id/grab_btn").findOne();
if (grabBtn) {
this._humanLikeClick(grabBtn);
return this._confirmGrab();
}
return false;
}
// 订单解析(需根据实际界面调整)
_parseOrder(orderId) {
return {
price: parseFloat($().textContains("¥").findOne().text().substring(1)),
distance: parseFloat($().textContains("km").findOne().text())
};
}
}
// 行为模拟器
class BehaviorSimulator {
static randomDelay(min=300, max=1500) {
sleep(random(min, max));
}
static humanLikeClick(view) {
const bounds = view.bounds();
const x = bounds.centerX() + random(-10, 10);
const y = bounds.centerY() + random(-5, 5);
press(x, y, random(80, 120));
}
static randomSwipe() {
const width = device.width;
const height = device.height;
swipe(
width * 0.5 + random(-100, 100),
height * 0.7 + random(-50, 50),
width * 0.5 + random(-100, 100),
height * 0.3 + random(-50, 50),
random(300, 800)
);
}
}
// 设备指纹混淆
class DeviceFingerprint {
static randomize() {
const props = {
model: ["Mi 10", "P40 Pro", "iPhone12"][random(0, 2)],
androidId: randomBytes(16).toString('hex'),
screenRes: `${random(1080,1440)}x${random(2240,2960)}`
};
require('device').setProperties(props);
}
}
MeituanGrabber = require('./meituan_grabber');
const AntiBan = require('./anti_ban');
// 初始化
DeviceFingerprint.randomize();
const grabber = new MeituanGrabber();
// 订单监听循环
setInterval(() => {
const orders = detectNewOrders(); // 需实现订单检测
orders.forEach(order => grabber.taskQueue.push(order));
}, 3000);
// 启动服务
grabber.start();
function detectNewOrders() {
// 实现订单检测逻辑(示例)
return Array(3).fill().map(() => ({
orderId: randomBytes(8).toString('hex'),
price: random(15, 50),
distance: random(1, 10)
}));
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。