
1888888888
"ui";
device.keepScreenOn();//保持屏幕常亮
myapp = {}
myapp.path = ""
myapp.qdnumber = "3"
myapp.delayMin = "5"
myapp.delayMax = "8"
myapp.bossnumber = "10"
myapp.dingy = "400"
myapp.xialasy = "0"
myapp.kx = "500"
myapp.ky = "1000"
myapp.jx = "500"
myapp.jy = "1500"
myapp.hd = "3"
myapp.wenzi = "20"
myapp.diy = device.height - 300 + ""
myapp.Words = false
myapp.emoji = false
myapp.mingle = false
myapp.duanwei = false
myapp.wzqd = false
myapp.yyqd = false
myapp.voice = false
myapp.fsong = false
myapp.siliao = false
myapp.qdan = false
myapp.guanzhu = false
myapp.arrMsg = "你好#老板好"
myapp.arrMsg1 = "选我我超甜!嘿嘿#萌妹子一枚,喜欢吗?"
myapp.arrMsg2 ="请输入抢单话术用#隔开话术"
myapp.SDKl = "输入激活码"
myapp.存储标识 = "mike963"
var 语音路径组 = Array()
var xxy = 0
ui.layout(
<ScrollView >
<vertical>
<appbar>
<toolbar id="toolbar" title="比心助手" />
</appbar>
<card w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" gravity="center_vertical">
<vertical padding="18 8" h="auto">
<linear>
<Switch id="autoService" text=" 无障碍服务:" checked="{{auto.service != null}}" w="auto" textStyle="bold" />
<Switch id="overlayService" text=" 悬浮窗权限" checked="{{auto.service != null}}" w="auto" textStyle="bold" />
</linear>
</vertical>
<View bg="#E51400" h="*" w="5" />
</card>
<card w="*" h="auto" margin="10 5" cardCornerRadius="2dp"
cardElevation="1dp" gravity="center_vertical">
<vertical padding="18 8" h="auto">
<linear>
<text text="激活码:" textcolor="black" w="auto" />
<input id="SDKl" inputType="number" text="" w="*" inputType="text" />
</linear>
</vertical>
<View bg="#ff5722" h="*" w="5" />
</card>
<card w="*" h="auto" margin="10 5" cardCornerRadius="2dp"
cardElevation="1dp" gravity="center_vertical">
<vertical padding="18 8" h="auto">
<linear>
<text text="需要测试激活码加微信:654269474" textcolor="black" w="auto" />
</linear>
<linear>
<text text="全局功能设置:" textcolor="black" w="auto" />
</linear>
<linear>
<checkbox id="siliao" text="开启私聊关注功能" w="auto" marginLeft="20" />
<checkbox id="fsong" text="开启三连发" w="auto" marginLeft="10" />
</linear>
<linear>
<text text="老板私聊文字话术:" textcolor="black" w="auto" />
<input id="arrMsg" inputType="text" text="" w="*" />
</linear>
<linear>
<text text="自动回复文字话术:" textcolor="black" w="auto" />
<input id="arrMsg1" inputType="text" text="" w="*" />
</linear>
<linear>
<text text="语音包路径:" textcolor="black" w="auto" />
<input id="path" inputType="text" text="" hint="/sdcard/文件夹/" w="*" />
</linear>
<linear>
<text text="每私聊老板" textcolor="black" w="auto" />
<input id="bossnumber" inputType="text" text="" w="60" />
<text text="个执行私信回复>>检查:" textcolor="black" w="auto" />
<input id="hd" inputType="text" text="" w="60" />
</linear>
<linear>
<checkbox id="guanzhu" text="关注私聊" w="auto" marginLeft="10" />
<checkbox id="duanwei" text="私信段位" w="auto" marginLeft="10" />
<checkbox id="voice" text="回复语音" w="auto" marginLeft="10" />
</linear>
<linear>
<text text="抢单或私聊老板间隔" textcolor="black" w="auto" />
<input id="delayMin" inputType="text" text="" w="60" />
<text text="秒至" textcolor="black" w="auto" />
<input id="delayMax" inputType="text" text="" w="60" />
<text text="秒" textcolor="black" w="auto" />
</linear>
<linear>
<text text="滑动开始位置:横坐标" textcolor="black" w="auto" />
<input id="kx" inputType="text" text="" w="60" />
<text text=",纵坐标" textcolor="black" w="auto" />
<input id="ky" inputType="text" text="" w="60" />
</linear>
<linear>
<text text="滑动结束位置:横坐标" textcolor="black" w="auto" />
<input id="jx" inputType="text" text="" w="60" />
<text text=",纵坐标" textcolor="black" w="auto" />
<input id="jy" inputType="text" text="" w="60" />
</linear>
</vertical>
<View bg="#ff5722" h="*" w="5" />
</card>
<card w="*" h="auto" margin="10 5" cardCornerRadius="2dp"cardElevation="1dp" gravity="center_vertical">
<vertical padding="18 8" h="auto">
<linear>
<checkbox id="siliao" text="开启文字抢单功能" w="auto" marginLeft="20" />
</linear>
<linear>
<text text="文字抢单话术:" textcolor="black" w="auto" />
<input id="arrMsg2" inputType="text" text="" w="*" />
</linear>
<linear>
<text text="语音包路径:" textcolor="black" w="auto" />
<input id="path" inputType="text" text="" hint="/sdcard/文件夹/" w="*" />
</linear>
<linear>
<text text="抢单次数" textcolor="black" w="auto" />
<input id="wenzi" inputType="text" text="" w="50" />
<checkbox id="wzqd" text="文字抢单" w="auto" marginLeft="10" />
<checkbox id="yyqd" text="正在开发" w="auto" marginLeft="10" />
</linear>
</vertical>
<View bg="#ff5722" h="*" w="5" />
</card>
<button style="Widget.AppCompat.Button.Colored" margin="5" id="start">开始执行脚本</button>
</vertical>
</ScrollView>
);
读取界面配置(true)
//创建选项菜单(右上角)
ui.emitter.on("create_options_menu", menu => {
menu.add("关于");
});
//监听选项菜单点击
ui.emitter.on("options_item_selected", (e, item) => {
switch (item.getTitle()) {
case "关于":
alert("关于", myapp.gg);
break;
}
e.consumed = true;
});
activity.setSupportActionBar(ui.toolbar);
//开关的单击事件
ui.autoService.on("check", function (checked) {
// 用户勾选无障碍服务的选项时,跳转到页面让用户去开启
if (checked && auto.service == null) {
app.startActivity({
action: "android.settings.ACCESSIBILITY_SETTINGS"
});
}
if (!checked && auto.service != null) {
auto.service.disableSelf();
}
});
// 当用户回到本界面时,resume事件会被触发
ui.emitter.on("resume", function () {
// 此时根据无障碍服务的开启情况,同步开关的状态
ui.autoService.checked = auto.service != null;
});
//开启悬浮窗权限
ui.overlayService.on("check", function (checked) {
// 用户勾选无障碍服务的选项时,跳转到页面让用户去开启
if (checked) {
int = app.startActivity({
packageName: "com.android.settings",
className: "com.android.settings.Settings$AppDrawOverlaySettingsActivity",
data: "package:com.cn.bixin"
});
toast("请打开悬浮窗开关");
}
if (!checked && auto.service != null) {
auto.service.disableSelf();
toast("已关闭悬浮窗权限");
}
});
const PJYSDK = (function () {
function PJYSDK(app_key, app_secret) {
http.__okhttp__.setMaxRetries(0);
http.__okhttp__.setTimeout(10 * 1000);
this.event = events.emitter();
this.debug = false;
this._lib_version = "v1.08";
this._protocol = "https";
this._host = "api.paojiaoyun.com";
this._device_id = this.getDeviceID();
this._retry_count = 9;
this._app_key = app_key;
this._app_secret = app_secret;
this._card = null;
this._username = null;
this._password = null;
this._token = null;
this.is_trial = false; // 是否是试用用户
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
this._auto_heartbeat = true; // 是否自动开启心跳任务
this._heartbeat_gap = 60 * 1000; // 默认60秒
this._heartbeat_task = null;
this._heartbeat_ret = {
"code": -9,
"message": "还未开始验证"
};
this._prev_nonce = null;
}
PJYSDK.prototype.SetCard = function (card) {
this._card = card.trim();
}
PJYSDK.prototype.SetUser = function (username, password) {
this._username = username.trim();
this._password = password;
}
PJYSDK.prototype.getDeviceID = function () {
let id = device.serial;
if (id == null || id == "" || id == "unknown") {
id = device.getAndroidId();
}
if (id == null || id == "" || id == "unknown") {
id = device.getIMEI();
}
return id;
}
PJYSDK.prototype.MD5 = function (str) {
try {
let digest = java.security.MessageDigest.getInstance("md5");
let result = digest.digest(new java.lang.String(str).getBytes("UTF-8"));
let buffer = new java.lang.StringBuffer();
for (let index = 0; index < result.length; index++) {
let b = result[index];
let number = b & 0xff;
let str = java.lang.Integer.toHexString(number);
if (str.length == 1) {
buffer.append("0");
}
buffer.append(str);
}
return buffer.toString();
} catch (error) {
alert(error);
return "";
}
}
PJYSDK.prototype.getTimestamp = function () {
try {
let res = http.get("http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp");
let data = res.body.json();
return Math.floor(data["data"]["t"] / 1000);
} catch (error) {
return Math.floor(new Date().getTime() / 1000);
}
}
PJYSDK.prototype.genNonce = function () {
const ascii_str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let tmp = '';
for (let i = 0; i < 20; i++) {
tmp += ascii_str.charAt(Math.round(Math.random() * ascii_str.length));
}
return this.MD5(this.getDeviceID() + tmp);
}
PJYSDK.prototype.joinParams = function (params) {
let ps = [];
for (let k in params) {
ps.push(k + "=" + params[k])
}
ps.sort()
return ps.join("&")
}
PJYSDK.prototype.CheckRespSign = function (resp) {
if (resp.code != 0 && resp.nonce === "" && resp.sign === "") {
return resp
}
let ps = "";
if (resp["result"]) {
ps = this.joinParams(resp["result"]);
}
let s = resp["code"] + resp["message"] + ps + resp["nonce"] + this._app_secret;
let sign = this.MD5(s);
if (sign === resp["sign"]) {
if (this._prev_nonce === null) {
this._prev_nonce = resp["nonce"];
return {
"code": 0,
"message": "OK"
};
} else {
if (resp["nonce"] > this._prev_nonce) {
this._prev_nonce = resp["nonce"];
return {
"code": 0,
"message": "OK"
};
} else {
return {
"code": -98,
"message": "轻点,疼~"
};
}
}
}
return {
"code": -99,
"message": "轻点,疼~"
};
}
PJYSDK.prototype.retry_fib = function (num) {
if (num > 9) {
return 34
}
let a = 0;
let b = 1;
for (i = 0; i < num; i++) {
let tmp = a + b;
a = b
b = tmp
}
return a
}
PJYSDK.prototype._debug = function (path, params, result) {
if (this.debug) {
log("\n" + path, "\nparams:", params, "\nresult:", result);
}
}
PJYSDK.prototype.Request = function (method, path, params) {
// 构建公共参数
params["app_key"] = this._app_key;
method = method.toUpperCase();
let url = this._protocol + "://" + this._host + path
let max_retries = this._retry_count;
let retries_count = 0;
let data = {
"code": -1,
"message": "连接服务器失败"
};
do {
retries_count++;
let sec = this.retry_fib(retries_count);
delete params["sign"]
params["nonce"] = this.genNonce();
params["timestamp"] = this.getTimestamp();
let ps = this.joinParams(params);
let s = method + this._host + path + ps + this._app_secret;
let sign = this.MD5(s);
params["sign"] = sign;
let resp, body;
try {
if (method === "GET") {
resp = http.get(url + "?" + ps + "&sign=" + sign);
} else { // POST
resp = http.post(url, params);
}
body = resp.body.string();
data = JSON.parse(body);
this._debug(method + '-' + path + ':', params, data);
let crs = this.CheckRespSign(data);
if (crs.code !== 0) {
return crs;
} else {
return data;
}
} catch (error) {
log("[*] request error: ", error, sec + "s后重试");
this._debug(method + '-' + path + ':', params, body)
sleep(sec * 1000);
}
} while (retries_count < max_retries);
return data;
}
/* 通用 */
PJYSDK.prototype.GetHeartbeatResult = function () {
return this._heartbeat_ret;
}
PJYSDK.prototype.GetTimeRemaining = function () {
let g = this.login_result.expires_ts - this.getTimestamp();
if (g < 0) {
return 0;
}
return g;
}
/* 卡密相关 */
PJYSDK.prototype.CardLogin = function () { // 卡密登录
if (!this._card) {
return {
"code": -4,
"message": "请先设置卡密"
};
}
let method = "POST";
let path = "/v1/card/login";
let data = {
"card": this._card,
"device_id": this._device_id
};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this._token = ret.result.token;
this.login_result = ret.result;
if (this._auto_heartbeat) {
this._startCardHeartheat();
}
}
return ret;
}
PJYSDK.prototype.CardHeartbeat = function () { // 卡密心跳,默认会自动调用
if (!this._token) {
return {
"code": -2,
"message": "请在卡密登录成功后调用"
};
}
let method = "POST";
let path = "/v1/card/heartbeat";
let data = {
"card": this._card,
"token": this._token
};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.login_result.expires = ret.result.expires;
this.login_result.expires_ts = ret.result.expires_ts;
}
return ret;
}
PJYSDK.prototype._startCardHeartheat = function () { // 开启卡密心跳任务
if (this._heartbeat_task) {
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
this._heartbeat_task = threads.start(function () {
setInterval(function () { }, 10000);
});
this._heartbeat_ret = this.CardHeartbeat();
this._heartbeat_task.setInterval((self) => {
self._heartbeat_ret = self.CardHeartbeat();
if (self._heartbeat_ret.code != 0) {
self.event.emit("heartbeat_failed", self._heartbeat_ret);
}
}, this._heartbeat_gap, this);
this._heartbeat_task.setInterval((self) => {
if (self.GetTimeRemaining() == 0) {
self.event.emit("heartbeat_failed", {
"code": 10210,
"message": "卡密已过期!"
});
}
}, 1000, this);
}
PJYSDK.prototype.CardLogout = function () { // 卡密退出登录
this._heartbeat_ret = {
"code": -9,
"message": "还未开始验证"
};
if (this._heartbeat_task) { // 结束心跳任务
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
if (!this._token) {
return {
"code": 0,
"message": "OK"
};
}
let method = "POST";
let path = "/v1/card/logout";
let data = {
"card": this._card,
"token": this._token
};
let ret = this.Request(method, path, data);
// 清理
this._token = null;
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
return ret;
}
PJYSDK.prototype.CardUnbindDevice = function () { // 卡密解绑设备,需开发者后台配置
if (!this._token) {
return {
"code": -2,
"message": "请在卡密登录成功后调用"
};
}
let method = "POST";
let path = "/v1/card/unbind_device";
let data = {
"card": this._card,
"device_id": this._device_id,
"token": this._token
};
return this.Request(method, path, data);
}
PJYSDK.prototype.SetCardUnbindPassword = function (password) { // 自定义设置解绑密码
if (!this._token) {
return {
"code": -2,
"message": "请在卡密登录成功后调用"
};
}
let method = "POST";
let path = "/v1/card/unbind_password";
let data = {
"card": this._card,
"password": password,
"token": this._token
};
return this.Request(method, path, data);
}
PJYSDK.prototype.CardUnbindDeviceByPassword = function (password) { // 用户通过解绑密码解绑设备
let method = "POST";
let path = "/v1/card/unbind_device/by_password";
let data = {
"card": this._card,
"password": password
};
return this.Request(method, path, data);
}
PJYSDK.prototype.CardRecharge = function (card, use_card) { // 以卡充卡
let method = "POST";
let path = "/v1/card/recharge";
let data = {
"card": card,
"use_card": use_card
};
return this.Request(method, path, data);
}
/* 用户相关 */
PJYSDK.prototype.UserRegister = function (username, password, card) { // 用户注册(通过卡密)
let method = "POST";
let path = "/v1/user/register";
let data = {
"username": username,
"password": password,
"card": card,
"device_id": this._device_id
};
return this.Request(method, path, data);
}
PJYSDK.prototype.UserLogin = function () { // 用户账号登录
if (!this._username || !this._password) {
return {
"code": -4,
"message": "请先设置用户账号密码"
};
}
let method = "POST";
let path = "/v1/user/login";
let data = {
"username": this._username,
"password": this._password,
"device_id": this._device_id
};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this._token = ret.result.token;
this.login_result = ret.result;
if (this._auto_heartbeat) {
this._startUserHeartheat();
}
}
return ret;
}
PJYSDK.prototype.UserHeartbeat = function () { // 用户心跳,默认会自动开启
if (!this._token) {
return {
"code": -2,
"message": "请在用户登录成功后调用"
};
}
let method = "POST";
let path = "/v1/user/heartbeat";
let data = {
"username": this._username,
"token": this._token
};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.login_result.expires = ret.result.expires;
this.login_result.expires_ts = ret.result.expires_ts;
}
return ret;
}
PJYSDK.prototype._startUserHeartheat = function () { // 开启用户心跳任务
if (this._heartbeat_task) {
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
this._heartbeat_task = threads.start(function () {
setInterval(function () { }, 10000);
});
this._heartbeat_ret = this.UserHeartbeat();
this._heartbeat_task.setInterval((self) => {
self._heartbeat_ret = self.UserHeartbeat();
if (self._heartbeat_ret.code != 0) {
self.event.emit("heartbeat_failed", self._heartbeat_ret);
}
}, this._heartbeat_gap, this);
this._heartbeat_task.setInterval((self) => {
if (self.GetTimeRemaining() == 0) {
self.event.emit("heartbeat_failed", {
"code": 10250,
"message": "用户已到期!"
});
}
}, 1000, this);
}
PJYSDK.prototype.UserLogout = function () { // 用户退出登录
this._heartbeat_ret = {
"code": -9,
"message": "还未开始验证"
};
if (!this._token) {
return {
"code": 0,
"message": "OK"
};
}
let method = "POST";
let path = "/v1/user/logout";
let data = {
"username": this._username,
"token": this._token
};
let ret = this.Request(method, path, data);
// 清理
this._token = null;
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
return ret;
}
PJYSDK.prototype.UserChangePassword = function (username, password, new_password) { // 用户修改密码
let method = "POST";
let path = "/v1/user/password";
let data = {
"username": username,
"password": password,
"new_password": new_password
};
return this.Request(method, path, data);
}
PJYSDK.prototype.UserRecharge = function (username, card) { // 用户通过卡密充值
let method = "POST";
let path = "/v1/user/recharge";
let data = {
"username": username,
"card": card
};
return this.Request(method, path, data);
}
PJYSDK.prototype.UserUnbindDevice = function () { // 用户解绑设备,需开发者后台配置
if (!this._token) {
return {
"code": -2,
"message": "请在用户登录成功后调用"
};
}
let method = "POST";
let path = "/v1/user/unbind_device";
let data = {
"username": this._username,
"device_id": this._device_id,
"token": this._token
};
return this.Request(method, path, data);
}
/* 配置相关 */
PJYSDK.prototype.GetCardConfig = function () { // 获取卡密配置
let method = "GET";
let path = "/v1/card/config";
let data = {
"card": this._card
};
return this.Request(method, path, data);
}
PJYSDK.prototype.UpdateCardConfig = function (config) { // 更新卡密配置
let method = "POST";
let path = "/v1/card/config";
let data = {
"card": this._card,
"config": config
};
return this.Request(method, path, data);
}
PJYSDK.prototype.GetUserConfig = function () { // 获取用户配置
let method = "GET";
let path = "/v1/user/config";
let data = {
"user": this._username
};
return this.Request(method, path, data);
}
PJYSDK.prototype.UpdateUserConfig = function (config) { // 更新用户配置
let method = "POST";
let path = "/v1/user/config";
let data = {
"username": this._username,
"config": config
};
return this.Request(method, path, data);
}
/* 软件相关 */
PJYSDK.prototype.GetSoftwareConfig = function () { // 获取软件配置
let method = "GET";
let path = "/v1/software/config";
return this.Request(method, path, {});
}
PJYSDK.prototype.GetSoftwareNotice = function () { // 获取软件通知
let method = "GET";
let path = "/v1/software/notice";
return this.Request(method, path, {});
}
PJYSDK.prototype.GetSoftwareLatestVersion = function (current_ver) { // 获取软件最新版本
let method = "GET";
let path = "/v1/software/latest_ver";
let data = {
"version": current_ver
};
return this.Request(method, path, data);
}
/* 试用功能 */
PJYSDK.prototype.TrialLogin = function () { // 试用登录
let method = "POST";
let path = "/v1/trial/login";
let data = {
"device_id": this._device_id
};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.is_trial = true;
this.login_result = ret.result;
if (this._auto_heartbeat) {
this._startTrialHeartheat();
}
}
return ret;
}
PJYSDK.prototype.TrialHeartbeat = function () { // 试用心跳,默认会自动调用
let method = "POST";
let path = "/v1/trial/heartbeat";
let data = {
"device_id": this._device_id
};
let ret = this.Request(method, path, data);
if (ret.code == 0) {
this.login_result.expires = ret.result.expires;
this.login_result.expires_ts = ret.result.expires_ts;
}
return ret;
}
PJYSDK.prototype._startTrialHeartheat = function () { // 开启试用心跳任务
if (this._heartbeat_task) {
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
this._heartbeat_task = threads.start(function () {
setInterval(function () { }, 10000);
});
this._heartbeat_ret = this.TrialHeartbeat();
this._heartbeat_task.setInterval((self) => {
self._heartbeat_ret = self.TrialHeartbeat();
if (self._heartbeat_ret.code != 0) {
self.event.emit("heartbeat_failed", self._heartbeat_ret);
}
}, this._heartbeat_gap, this);
this._heartbeat_task.setInterval((self) => {
if (self.GetTimeRemaining() == 0) {
self.event.emit("heartbeat_failed", {
"code": 10407,
"message": "试用已到期!"
});
}
}, 1000, this);
}
PJYSDK.prototype.TrialLogout = function () { // 试用退出登录,没有http请求,只是清理本地记录
this.is_trial = false;
this._heartbeat_ret = {
"code": -9,
"message": "还未开始验证"
};
if (this._heartbeat_task) { // 结束心跳任务
this._heartbeat_task.interrupt();
this._heartbeat_task = null;
}
// 清理
this._token = null;
this.login_result = {
"card_type": "",
"expires": "",
"expires_ts": 0,
"config": "",
};
return {
"code": 0,
"message": "OK"
};;
}
/* 高级功能 */
PJYSDK.prototype.GetRemoteVar = function (key) { // 获取远程变量
let method = "GET";
let path = "/v1/af/remote_var";
let data = {
"key": key
};
return this.Request(method, path, data);
}
PJYSDK.prototype.GetRemoteData = function (key) { // 获取远程数据
let method = "GET";
let path = "/v1/af/remote_data";
let data = {
"key": key
};
return this.Request(method, path, data);
}
PJYSDK.prototype.CreateRemoteData = function (key, value) { // 创建远程数据
let method = "POST";
let path = "/v1/af/remote_data";
let data = {
"action": "create",
"key": key,
"value": value
};
return this.Request(method, path, data);
}
PJYSDK.prototype.UpdateRemoteData = function (key, value) { // 修改远程数据
let method = "POST";
let path = "/v1/af/remote_data";
let data = {
"action": "update",
"key": key,
"value": value
};
return this.Request(method, path, data);
}
PJYSDK.prototype.DeleteRemoteData = function (key, value) { // 删除远程数据
let method = "POST";
let path = "/v1/af/remote_data";
let data = {
"action": "delete",
"key": key
};
return this.Request(method, path, data);
}
PJYSDK.prototype.CallRemoteFunc = function (func_name, params) { // 执行远程函数
let method = "POST";
let path = "/v1/af/call_remote_func";
let ps = JSON.stringify(params);
let data = {
"func_name": func_name,
"params": ps
};
let ret = this.Request(method, path, data);
if (ret.code == 0 && ret.result.return) {
ret.result = JSON.parse(ret.result.return);
}
return ret;
}
return PJYSDK;
})();
/* 将PJYSDK.js文件中的代码复制粘贴到上面 */
let pjysdk = new PJYSDK("c019rcko6itd9d2n3to0", "INML6c6pZUhR5ypv90i30oC47LJcY1R3");
pjysdk._protocol = "https"
pjysdk.debug = false;
// 监听心跳失败事件
pjysdk.event.on("heartbeat_failed", function (hret) {
log("心跳失败,尝试重登...")
sleep(2000);
let login_ret = pjysdk.CardLogin();
if (login_ret.code == 0) {
log("重登成功");
} else {
toastLog(login_ret.message); // 重登失败
sleep(200);
exit(); // 退出脚本
}
});
// 当脚本正常或者异常退出时会触发exit事件
events.on("exit", function () {
pjysdk.CardLogout(); // 调用退出登录
log("结束运行");
});
ui.start.on("click", () => { //按钮单击事件 哪个按钮 start 需要修改这个ID
保存界面配置() //先读取配置
读取界面配置(false)
if (auto.service == null) {
toastLog("请先开启无障碍服务!");
return
};
if (!floaty.checkPermission()) {
floaty.requestPermission()
return
}
// 屏蔽音量键调节声音
events.setKeyInterceptionEnabled("volume_up", true);
//启用按键监听
events.observeKey();
//监听音量键按下
events.onKeyDown("volume_up", () => {
toastLog('按音量键停止');
exit(); //停止、退出脚本
});
threads.start(function () { //线程启动主程序
console.show()
//recents()
// 老板私聊();
cdk = String(ui.SDKl.getText());
pjysdk.SetCard(cdk);
let login_ret = pjysdk.CardLogin();
if (login_ret.code == 0) {
//登录成功,后面写你的业务代码
let ret = pjysdk.GetTimeRemaining();
console.info("卡密剩余" + ret + "秒")
//老板私聊();
开始脚本();
} else {
登录失败提示
toast(login_ret.message);
}
});
});
function 开始脚本() {
if (myapp.siliao) {
老板私聊();
} else {
文字语音抢单();
}
// 发送语音();
// sleep(6000)
};
function 文字语音抢单() {
console.info("请手动进入语音抢单页面");
if (launch("com.yitantech.gaigai")) {
launch("com.yitantech.gaigai")
} else {
toast("未安装比心app")
sleep(3000)
exit()
}
myapp.wenziy = 0
while (true) {
if (myapp.wzqd) {
文字抢单()
} else {
//此处是无段位筛选
语音私聊()
}
sleep(1000)
}
};
function 老板私聊() {
console.info("请手动进入老板私聊页面");
if (launch("com.yitantech.gaigai")) {
launch("com.yitantech.gaigai")
} else {
toast("未安装比心app")
sleep(3000)
exit()
};
if (text('去聊聊').findOne()) {
log("老板私聊 开始运行");
} else {
log("请手动刷新一下用户!!")
};
sleep(500)
myapp.bossnumbery = 0
while (true) {
if (myapp.guanzhu) {
关注私聊模式();
} else if (myapp.duanwei) {
}
sleep(1000)
}
};
function 检查私信() {
console.warn("开始检查私信>>>>>>")
sleep(1000)
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent(3).findOne().click()
sleep(1000)
console.warn("检查私信:" + myapp.hd + "次")
sleep(1000)
for (let a = 0; a < myapp.hd; a++) {
var num = a + 1
console.info("寻找消息第" + num + "次")
sleep(500)
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent(3).findOne().click()
sleep(100)
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent(3).findOne().click()
sleep(100)
if (id("txvUnread").exists()) {
log("找到可回复信息")
sleep(500)
log("开始回复!!")
sleep(1000)
var red = id("txvUnread").findOne().parent()
red.click()
sleep(1000)
//此处判断是否发送语音私信
if (myapp.voice) {
发送语音();
} else {
发送文字2();
}
back()
sleep(1000)
if (id("iftBack").exists()) {
back()
sleep(1000)
}
if (id("iftTv").className("android.widget.TextView").text("").exists()) {
back()
sleep(1000)
}
} else {
log("没有发现可回复的信息")
}
sleep(1000)
}
sleep(1000)
//检查完不能执行就注释这行 id("reddot").findOne().parent().parent().click()
sleep(2000)
myapp.bossnumbery = 0
}
function 发送文字() {
if (id("toolbarButtonText").className("android.widget.TextView").text("").exists()) {
log("当前界面可能无法回复")
} else {
// if (id("bx_avatar_view_id").findOne(1000)) {
// log("此处是检查是否私聊过,私聊过直接跳过")
// sleep(1000)
// back();
// sleep(1000)
// back();
// sleep(1000)
// back();
// }
// else {
sleep(500)
var 分割 = myapp.arrMsg.split("#")
var x = random(0, 分割.length - 1)
var 话术 = 分割[x]
sleep(1000)
log("发送内容:" + 话术)
var shuru = id("etInputContent").findOne().parent().bounds();
click((shuru.left + shuru.right) / 2, (shuru.top + shuru.bottom) / 2)
sleep(1000)
setText(话术)
sleep(1000)
click("发送")
sleep(1000)
sleep(500)
var 分割 = myapp.arrMsg.split("#")
var x = random(0, 分割.length - 1)
var 话术 = 分割[x]
sleep(1000)
setText(话术)
sleep(1000)
click("发送")
sleep(1000)
sleep(500)
var 分割 = myapp.arrMsg.split("#")
var x = random(0, 分割.length - 1)
var 话术 = 分割[x]
sleep(1000)
log("发送内容:" + 话术)
var shuru = id("etInputContent").findOne().parent().bounds();
click((shuru.left + shuru.right) / 2, (shuru.top + shuru.bottom) / 2)
sleep(1000)
setText(话术)
sleep(1000)
click("发送")
sleep(1000)
}
}
function 发送文字1() {
if (id("toolbarButtonText").className("android.widget.TextView").text("").exists()) {
log("当前界面可能无法回复")
} else {
// if (id("bx_avatar_view_id").findOne(1000)) {
// log("此处是检查是否私聊过,私聊过直接跳过")
// sleep(1000)
// back();
// sleep(1000)
// back();
// sleep(1000)
// back();
// }
// else {
sleep(500)
var x = random(0, 分割.length - 1)
var 话术 = 分割[x]
sleep(1000)
log("发送内容:" + 话术)
var shuru = id("etInputContent").findOne().parent().bounds();
click((shuru.left + shuru.right) / 2, (shuru.top + shuru.bottom) / 2)
sleep(1000)
setText(话术)
sleep(1000)
click("发送")
sleep(1000)
}
}
function 发送文字2() {
if (id("toolbarButtonText").className("android.widget.TextView").text("").exists()) {
log("当前界面可能无法回复")
} else {
log("发送文字")
var 分割 = myapp.arrMsg1.split("#")
var x = random(0, 分割.length - 1)
var 话术 = 分割[x]
log("发送内容:" + 话术)
sleep(1000)
var shuru = id("etInputContent").findOne().parent().bounds();
click( (shuru.left + shuru.right) / 2,(shuru.top + shuru.bottom) / 2)
sleep(1000)
setText(话术)
sleep(1000)
click("发送")
sleep(1000)
}
}
function 直接私聊模式() {
console.log("开启>>>直接私聊模式")
console.info("开始提取用户名称:")
sleep(2000)
var ar2 = new Array();
ar = className("android.view.View").depth(20).packageName("com.yitantech.gaigai").indexInParent(0).find()
if (ar.length > 0) {
for (i = 0; i < ar.length; i++) {
if(ar[i].text()!=""){
var 名字 = ar[i].text()
console.info(">>>" + 名字)
ar2.push(名字)
}
}
}
if (ar2.length == 0) {
if (ar2[0] == undefined) {
console.log("搜索用户数量:" + arr2.length)
log("开始刷新!!")
sleep(1000)
console.hide()
sleep(500)
swipe(myapp.kx, myapp.ky, myapp.jx, myapp.jy, 500)
sleep(1000)
console.show()
sleep(1000)
}
}
if (ar2.length > 0) {
sleep(1000)
back()
sleep(1000)
log("前往首页:执行直接私聊模式")
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent("0").findOne().click()
for (let i = 0; i < ar2.length; ++i) {
id("timeline_text_search").findOne().click()
sleep(1000)
console.info("搜索用户:" + ar2[i])
名字 = ar2[i]
id("editText").findOne().setText(名字)
sleep(1000)
var 搜索 = id("toolbarButtonText").className("android.widget.TextView").text("搜索").findOne().bounds()
click(搜索.centerX(), 搜索.centerY());
sleep(1000)
console.hide()
sleep(1000)
id("cl_wrapper").className("android.view.ViewGroup").findOne().click();
sleep(1000)
console.show()
sleep(1000)
id("chat").findOne().click();
sleep(1000)
if (myapp.fsong) {
发送文字();
} else {
发送文字1();
}
sleep(1000)
sleep(1000)
back();
sleep(1000)
back();
sleep(1000)
back();
sleep(1000)
if (id("editText").exists()) {
back()
sleep(1000)
}
myapp.bossnumbery++
if (myapp.bossnumbery == parseInt(myapp.bossnumber)) {
log("私信任务完成,开始检查私信!")
检查私信();
} else {
log("当前已私信数: " + myapp.bossnumbery)
log("目标私信数量: " + myapp.bossnumber)
}
myapp.delay = random(parseInt(myapp.delayMin), parseInt(myapp.delayMax))
for (var j = parseInt(myapp.delay); j > 0; j--) {
log("下次私信等待" + j + "秒")
sleep(1000)
}
}
log("前往发现老板页面获取名字")
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent(4).findOne().click()
sleep(1000)
id("tvGodNewbieItemFuncTitle").text("发现新老板").findOne().parent().parent().click()
sleep(1000)
log("开始刷新!!")
sleep(1000)
console.hide()
sleep(500)
swipe(myapp.kx, myapp.ky, myapp.jx, myapp.jy, 500)
sleep(1000)
console.show()
sleep(1000)
}
}
function 关注私聊段位模式() {
console.log("开启>>>关注私聊段位模式")
console.info("开始提取段位用户名称:")
sleep(2000)
var l1=[]//创建一个空数组
void function(o){
l1.push(o)//添加到数组
for (let i=0;i<o.childCount(); i++)//如果子控件数量不为0,则循环
arguments.callee(o.child(i))//调用自己,参数是子控件
}(className('FrameLayout').findOne(100))//参数是顶层控件
var l2=[]
for(var i=0;i<l1.length;i++){//循环
var o=l1[i]//取第i个控件
var text=o.text()//取其文本
//文本长度为32 且 只由数字和小写字母组成 且控件深度为10
if(text.length==32&&/^[0-9a-z]+$/.test(text)){
if(l1[i-4].text()=="发现老板")continue
if(text=="4261825fd28d4f799c85f298ebe1b1ef"){//空白的
//print("空白 "+l1[i-4].text())//向上偏移4个就是
}else{
//print(text+" "+l1[i-4].text())
l2.push(l1[i-4].text())
}
}
}
for(var i=0;i<l2.length;i++){
print(l2[i])
}
if (l2.length==0) {
console.log("搜索用户数量:" + l2.length)
log("开始刷新!!")
sleep(1000)
console.hide()
sleep(500)
swipe(myapp.kx, myapp.ky, myapp.jx, myapp.jy, 500)
sleep(1000)
console.show()
sleep(1000)
}
if (l2.length > 0) {
sleep(1000)
back()
sleep(1000)
log("前往首页:执行关注私聊模式")
sleep(1000)
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent("0").findOne().click()
for (let i = 0; i < l2.length; ++i) {
id("timeline_text_search").findOne().click()
sleep(1000)
console.info("搜索用户:" + l2[i])
名字 = l2[i]
id("editText").findOne().setText(名字)
sleep(1000)
var 搜索 = id("toolbarButtonText").className("android.widget.TextView").text("搜索").findOne().bounds()
click(搜索.centerX(), 搜索.centerY());
sleep(1000)
console.hide()
sleep(1000)
id("cl_wrapper").className("android.view.ViewGroup").findOne().click();
sleep(1000)
console.show()
sleep(1000)
if (id("follow").findOne(1000)) {
click("关注")
sleep(1000)
id("chat").findOne().click();
sleep(1000)
if (myapp.fsong) {
发送文字();
} else {
发送文字1();
}
sleep(1000)
sleep(1000)
back();
sleep(1000)
back();
sleep(1000)
back();
sleep(1000)
}
if (id("editText").exists()) {
back()
sleep(1000)
}
else {
log("已私聊返回重新搜索")
sleep(1000)
back();
sleep(1000)
back();
}
myapp.bossnumbery++
if (myapp.bossnumbery == parseInt(myapp.bossnumber)) {
log("私信任务完成,开始检查私信!")
检查私信();
} else {
log("当前已私信数: " + myapp.bossnumbery)
log("目标私信数量: " + myapp.bossnumber)
}
myapp.delay = random(parseInt(myapp.delayMin), parseInt(myapp.delayMax))
for (var j = parseInt(myapp.delay); j > 0; j--) {
log("下次私信等待" + j + "秒")
sleep(1000)
}
}
log("前往发现老板页面获取名字")
id("bottomItemContainer").className("android.view.ViewGroup").indexInParent(4).findOne().click()
sleep(1000)
id("tvGodNewbieItemFuncTitle").text("发现新老板").findOne().parent().parent().click()
sleep(1000)
log("开始刷新!!")
sleep(1000)
console.hide()
sleep(500)
swipe(myapp.kx, myapp.ky, myapp.jx, myapp.jy, 500)
sleep(1000)
console.show()
sleep(1000)
}
}
var yuyin = id("iftTv").className("android.widget.TextView").text("").findOnce()
if (yuyin != null) {
console.log("语音回复>>>true")
sleep(1000)
var re = yuyin.bounds()
click(re.centerX(), re.centerY())
sleep(1000)
var yuy = id("flVoiceLayout").findOne()
var rect = yuy.bounds()
press(rect.centerX(), rect.centerY(), 3000)
sleep(2000)
xxy = 1
}
}
}
function 文字抢单() {
if(text("我的抢单记录").findOne()){
for (var i = 0; i < myapp.wenzi; i++) {
if(text("文字抢单").findOne(1000)){
开始文字抢单();
}
sleep(1000)
swipe(myapp.kx, myapp.ky, myapp.jx, myapp.jy, 500)
}
}
}
function 开始文字抢单() {
swipe(myapp.kx, myapp.ky, myapp.jx, myapp.jy, 500)
sleep(1000)
if(text("文字抢单").findOne(1000)){
id("tv_order_grab_layout_item_text").findOne().click()
sleep(1000)
var 分割 = myapp.arrMsg2.split("#")
var x = random(0, 分割.length - 1)
var 话术 = 分割[x]
log("发送内容:" + 话术)
sleep(1000)
id("etGrabComment").findOne().setText(话术)
sleep(1000)
id("tvGrab").findOne().click()
sleep(2000)
myapp.wenziy++
if (myapp.wenziy == parseInt(myapp.wenzi)) {
log("抢单任务已经完成关闭脚本")
sleep(2000)
shell("am kill-all", true);
} else {
log("当前抢单次数: " + myapp.weiziy)
log("目标抢单数量: " + myapp.weizi)
}
myapp.delay = random(parseInt(myapp.delayMin), parseInt(myapp.delayMax))
for (var j = parseInt(myapp.delay); j > 0; j--) {
log("下次抢单等待" + j + "秒")
sleep(1000)
}
}
}
function 语音抢单() {
console.info("语音抢单开发中");
};
function 保存界面配置() {
保存本地数据(myapp.存储标识, "duanwei", ui.duanwei.isChecked())
保存本地数据(myapp.存储标识, "siliao", ui.siliao.isChecked())
保存本地数据(myapp.存储标识, "wzqd", ui.wzqd.isChecked())
保存本地数据(myapp.存储标识, "yyqd", ui.yyqd.isChecked())
保存本地数据(myapp.存储标识, "guanzhu", ui.guanzhu.isChecked())
保存本地数据(myapp.存储标识, "voice", ui.voice.isChecked())
保存本地数据(myapp.存储标识, "fsong", ui.fsong.isChecked())
保存本地数据(myapp.存储标识, "SDKl", ui.SDKl.text())
保存本地数据(myapp.存储标识, "delayMin", ui.delayMin.text())
保存本地数据(myapp.存储标识, "wenzi", ui.wenzi.text())
保存本地数据(myapp.存储标识, "delayMax", ui.delayMax.text())
保存本地数据(myapp.存储标识, "bossnumber", ui.bossnumber.text())
保存本地数据(myapp.存储标识, "kx", ui.kx.text())
保存本地数据(myapp.存储标识, "ky", ui.ky.text())
保存本地数据(myapp.存储标识, "jx", ui.jx.text())
保存本地数据(myapp.存储标识, "jy", ui.jy.text())
//坐标 kx ky jx jy
保存本地数据(myapp.存储标识, "arrMsg", ui.arrMsg.text())
保存本地数据(myapp.存储标识, "arrMsg1", ui.arrMsg1.text())
保存本地数据(myapp.存储标识, "arrMsg2", ui.arrMsg2.text())
保存本地数据(myapp.存储标识, "path", ui.path.text())
};
function 读取界面配置(是否设置组件值) { //逻辑值 是否设置组件值
if (读取本地数据(myapp.存储标识, "duanwei") != undefined) {
myapp.duanwei = 读取本地数据(myapp.存储标识, "duanwei")
};
是否设置组件值 && ui.duanwei.setChecked(myapp.duanwei);
if (读取本地数据(myapp.存储标识, "siliao") != undefined) {
myapp.siliao = 读取本地数据(myapp.存储标识, "siliao")
};
是否设置组件值 && ui.siliao.setChecked(myapp.siliao);
if (读取本地数据(myapp.存储标识, "wzqd") != undefined) {
myapp.wzqd = 读取本地数据(myapp.存储标识, "wzqd")
};
是否设置组件值 && ui.wzqd.setChecked(myapp.wzqd);
if (读取本地数据(myapp.存储标识, "yyqd") != undefined) {
myapp.yyqd = 读取本地数据(myapp.存储标识, "yyqd")
};
是否设置组件值 && ui.yyqd.setChecked(myapp.yyqd);
if (读取本地数据(myapp.存储标识, "guanzhu") != undefined) {
myapp.guanzhu = 读取本地数据(myapp.存储标识, "guanzhu")
};
是否设置组件值 && ui.guanzhu.setChecked(myapp.guanzhu);
if (读取本地数据(myapp.存储标识, "voice") != undefined) {
myapp.voice = 读取本地数据(myapp.存储标识, "voice")
};
是否设置组件值 && ui.voice.setChecked(myapp.voice);
if (读取本地数据(myapp.存储标识, "fsong") != undefined) {
myapp.fsong = 读取本地数据(myapp.存储标识, "fsong")
};
是否设置组件值 && ui.fsong.setChecked(myapp.fsong);
if (读取本地数据(myapp.存储标识, "bossnumber") != undefined) {
myapp.bossnumber = 读取本地数据(myapp.存储标识, "bossnumber")
};
是否设置组件值 && ui.bossnumber.setText(myapp.bossnumber);
if (读取本地数据(myapp.存储标识, "hd") != undefined) {
myapp.hd = 读取本地数据(myapp.存储标识, "hd")
};
是否设置组件值 && ui.hd.setText(myapp.hd);
if (读取本地数据(myapp.存储标识, "wenzi") != undefined) {
myapp.wenzi = 读取本地数据(myapp.存储标识, "wenzi")
};
是否设置组件值 && ui.wenzi.setText(myapp.wenzi);
if (读取本地数据(myapp.存储标识, "kx") != undefined) {
myapp.kx = 读取本地数据(myapp.存储标识, "kx")
};
是否设置组件值 && ui.kx.setText(myapp.kx);
if (读取本地数据(myapp.存储标识, "ky") != undefined) {
myapp.ky = 读取本地数据(myapp.存储标识, "ky")
};
是否设置组件值 && ui.ky.setText(myapp.ky);
if (读取本地数据(myapp.存储标识, "jx") != undefined) {
myapp.jx = 读取本地数据(myapp.存储标识, "jx")
};
是否设置组件值 && ui.jx.setText(myapp.jx);
if (读取本地数据(myapp.存储标识, "jy") != undefined) {
myapp.jy = 读取本地数据(myapp.存储标识, "jy")
};
是否设置组件值 && ui.jy.setText(myapp.jy);
//坐标kx ky jx jy
if (读取本地数据(myapp.存储标识, "arrMsg") != undefined) {
myapp.arrMsg = 读取本地数据(myapp.存储标识, "arrMsg")
};
是否设置组件值 && ui.arrMsg.setText(myapp.arrMsg);
if (读取本地数据(myapp.存储标识, "arrMsg1") != undefined) {
myapp.arrMsg1 = 读取本地数据(myapp.存储标识, "arrMsg1")
};
是否设置组件值 && ui.arrMsg1.setText(myapp.arrMsg1);
if (读取本地数据(myapp.存储标识, "arrMsg2") != undefined) {
myapp.arrMsg2 = 读取本地数据(myapp.存储标识, "arrMsg2")
};
是否设置组件值 && ui.arrMsg2.setText(myapp.arrMsg2);
if (读取本地数据(myapp.存储标识, "path") != undefined) {
myapp.path = 读取本地数据(myapp.存储标识, "path")
};
是否设置组件值 && ui.path.setText(myapp.path);
if (读取本地数据(myapp.存储标识, "delayMin") != undefined) {
myapp.delayMin = 读取本地数据(myapp.存储标识, "delayMin")
};
是否设置组件值 && ui.delayMin.setText(myapp.delayMin);
if (读取本地数据(myapp.存储标识, "delayMax") != undefined) {
myapp.delayMax = 读取本地数据(myapp.存储标识, "delayMax")
};
是否设置组件值 && ui.delayMax.setText(myapp.delayMax);
if (读取本地数据(myapp.存储标识, "SDKl") != undefined) {
myapp.SDKl = 读取本地数据(myapp.存储标识, "SDKl")
};
是否设置组件值 && ui.SDKl.setText(myapp.SDKl);
};
function 保存本地数据(存储标识, ID, 界面组件值) {
const storage = storages.create(存储标识); //创建storage对象
storage.put(ID, 界面组件值);
};
function 读取本地数据(存储标识, ID) {
const storage = storages.create(存储标识); //创建storage对象
if (storage.contains(ID)) {
return storage.get(ID, "");
};
//默认返回undefined
};
function 删除本地数据(存储标识, ID) {
const storage = storages.create(存储标识); //创建storage对象
if (storage.contains(ID)) {
storage.remove(ID);
};
};