//刷宝
var myApp ={};
myApp.currentRunNum = 0;//当前运行数量
myApp.maxRunNum = 3;//运行次数
myApp.minRunTime = 20;//分钟
myApp.maxRunTime = 25;//最大运行时间
myApp.startTime = null;
myApp.appPackage = "com.jm.video";
myApp.homeActivity = "com.jm.video.ui.main.MainActivity";
myApp.ocr={};
isRoot = false;
myApp.moveMaxY = (device.height-300);//滑动的最大y值
//时间差 ,返回分钟
function timeDeffToSecond(start,end){
var c = end.getTime()-start.getTime();
return c/(60*1000);
}
//判断是否root
function whetherRoot() {
threads.start(function () {
log('判断是否root')
try {
click(2000, 2000)
isRoot = false
log('未root')
} catch (error) {
isRoot = true
log(error)
log('已root')
}
})
}
/**
* 点击
* @param {*} x
* @param {*} y
*/
function onClick(x, y) {
if (isRoot == true) {
Tap(x, y)
} else {
click(x, y)
}
}
/**
* 控件查找并点击
* @param {控件查找类型} way
* @param {查找字符} str
* @param { 查找时间} sleepTime
*/
function clickNode(way, str, sleepTime) {
if (!sleepTime) {
sleepTime = 1000
}
let result = false //点击结果
let object;
if (way == "text") {
object = text(str).findOne(sleepTime);
} else if (way == "desc") {
object = desc(str).findOne(sleepTime);
} else if (way == "id") {
object = id(str).findOne(sleepTime);
} else if (way == "className") {
object = className(str).findOne(sleepTime);
} else {
log("Error:clickNode-way参数不正确")
}
if (object != null) {
if (object.clickable()) {
result = object.click();
result && sleep(sleepTime);
// if (result) {
// sleep(sleepTime);
// }
} else {
//log("Error:clickNode-组件不可点击")
let x = object.bounds().centerX();
let y = object.bounds().centerY();
log(str)
console.log(x+","+y);
if (x > 0 && y > 0) {
result = click(parseInt(x), parseInt(y));
} else {
log("Error:clickNodeR-中心点坐标不在可视区")
}
result && sleep(sleepTime);
}
} else {
// log("Error:clickNode-组件不存在/没找到")
}
return result;
};
//关闭按钮 针对x按钮 无id, 无标记的情况
function imgClose(findColor){
log("开始关闭 X 控件");
sleep(1000);
var img = captureScreen();
var p = findMultiColors(img, findColor, [[10, 10, findColor], [10, -10, findColor],[-10, -10, findColor],[-10, 10, findColor]]);
console.log(p);
if(p){
// var top = images.pixel(img, p.x,p.y-5);//y正半轴
// var bottom = images.pixel(img, p.x,p.y+5);//y负半轴
// var right = images.pixel(img, p.x+5,p.y);//x正半轴
// var left = images.pixel(img, p.x-5,p.y);//x正负轴
// log(top);
// log(bottom);
// log(right);
// log(left);
click(p.x,p.y);
sleep(1000);
log("关闭成功");
}else{
className("android.widget.ImageView").find().forEach(function(currentValue, index) {
if(currentValue.clickable()){
currentValue.click();
}
});
}
}
//申请提现
function sqTX() {
if (clickNode("text","立即提现",2000)) {
if (clickNode("text","我知道了",2000)) {
if (clickNode("text","提现详情",1000)) {
return true;
}
}else {
if (clickNode("text","提现详情",1000)) {
return true;
}
}
}
return false;
}
//开始提现
function startTX() {
if (clickNode("text","提现",2000)) {
if (clickNode("text","立即提现",2000)) {
swipe(random(300,400),device.height-random(300, 400),400,random(200, 300),random(1000,1500));
if (text("今日已提现").exists()) {
return false;
}
log("===========>>>");
log(text("¥10.00元").exists());
ui.run(function(){
toastLog("====>>>");
})
if (clickNode("text","¥10.00元",2000)) {
if(sqTX()){
return true;
}
}
if (clickNode("text","¥3.00元",2000)) {
if(sqTX()){
return true;
}
}
if (clickNode("text","¥0.3元",2000)) {
if(sqTX()){
return true;
}
}
log("22222222");
sleep(2000);
back();
}
sleep(2000);
back();
}
}
//关闭签到弹框
function closeQDDialog() {
if (clickNode("id","imgClose",2000)) {
log("---->> 立即签到");
if(clickNode("text","立即签到",2000)){
imgClose("#998980");
}
}else{
log("---->> 立即签到");
if(clickNode("text","立即签到",2000)){
imgClose("#998980");
}
}
}
//打开首页
function openSY() {
clickNode("text","首页",2000);
}
//签到 imgClose
function qd() {
if (clickNode("text","任务",2000)) {
//closeQDDialog();
sleep(3000);
closeQDDialog();
sleep(1000);
} else if(clickNode("text","福利",2000)){
sleep(3000);
closeQDDialog();
sleep(1000);
}
else
if(id("ll_tap").depth(10).exists()){
var b = id("ll_tap").depth(10).findOne();
if (b.centerX()>0&&b.centerY()>0) {
onClick(b.centerX(),b.centerY());
sleep(2000);
closeQDDialog();
sleep(1000);
}
}
}
function jsMaxMoveY(){
if(id("portait").exists()){
let b = id("portait").findOne().bounds();
if(b.bottom>0){
myApp.moveMaxY = b.botto;
}
}else{
if(text("首页").exists()){
let b = text("首页").findOne().bounds();
if(b.bottom>0){
myApp.moveMaxY = b.top-100;
}
}
}
}
myApp.start = function (runNum){
console.log("--------==>"+"运行刷宝短视频");
if(runNum>myApp.maxRunNum){
return;
}
sleep(3000);
myApp.startTime = new Date();
sleep(3000);
if(launchApp("刷宝短视频")){
waitForActivity(myApp.homeActivity);
sleep(5000);
qd();
startTX();
// whetherRoot();
// log("---->"+runNum);
// // if(runNum==1){
// // sleep(random(5000, 10000));
// // qd();
// // openRW();
// // openTX();
// // onTX();
// // }
openSY();
log("width:"+device.width);
while(true){
sleep(random(8000, 16000));
if(id("live_top_users").exists()||id("btn_active").exists()||id("btn_gift").exists()){
swipe(device.width - random(400,700),device.height-random(0, 100),device.width - random(300, 400),random(100, 300),random(500,1000));
}
// qd();
swipe(device.width - random(300,400),myApp.moveMaxY-random(0, 100),device.width - random(400, 700),random(100, 200),random(500,1000));
log("-------->时间:"+timeDeffToSecond( myApp.startTime,new Date()))
if(timeDeffToSecond( myApp.startTime,new Date())>(random(myApp.minRunTime,myApp.maxRunTime))){
return;
}
}
}
}
module.exports = myApp;
感兴趣的一起交流,
用庖丁加密试了几次都不成功;头疼!!!