悟空-看广告
function clickBounds(obj) {
if(obj == null || !obj.bounds){
return;
}
var point = obj.bounds()
click(point.centerX() + random(0, 10), point.centerY() + random(0, 10))
}
function soundOff(){
var sel = desc('开启声音').boundsInside(0, 0, device.width / 2, device.height /8);
if (sel.exists()) {
var btn = sel.findOnce();
clickBounds(btn);
}
}
function mySleep(){
var regex = /^(\d+)s$/;
var sel = textMatches(regex);
if (sel.exists()) {
var btn = sel.findOnce();
var txt = btn.text();
var time = parseInt(txt.match(regex)[1]);
sleep(time * 1000 + random(3000, 5000));
}
}
function myBack(){
var sel = text("反馈");
if(sel.exists()){
var [left, top, right, bottom] = [924, 60, 1008, 144];
var width = right - left;
click(left + width/2 + random(0, 10), top + width/2 + random(0, 10));
}else{
back();
}
}
function clickAndPlay(regex){
var sel = textMatches(regex);
if (sel.exists()) {
var btn = sel.findOnce();
sleep(2000);
clickBounds(btn);
sleep(2000);
soundOff();
mySleep();
myBack();
return true;
}
return false;
}
function clickBtn(regex){
var sel = textMatches(regex);
if (sel.exists()) {
var btn = sel.findOnce();
sleep(2000);
clickBounds(btn);
return true;
}
return false;
}
function main(){
if(clickBtn(/^看视频$/)){
}else if(clickBtn(/^领取金币$/)){
}
if(clickAndPlay(/^再看一个领.*(\d+)$/)){
} else if(clickAndPlay(/^看视频领取.*(\d+)$/)){
} else if(clickAndPlay(/^再看一条视频领.*(\d+)$/)){
} else if(clickAndPlay(/^再看一个获得(\d+)金币$/)){
} else if(clickAndPlay(/^看视频再领.*(\d+)$/)){
} else if(clickAndPlay(/^继续观看$/)){
} else if(clickBtn(/^继续观看$/)){
}
}
var i = 1;
while(true){
main();
sleep(2000);
console.log(`完成 ${i++} 次!`);
}
悟空-搜索赚金币
function jerrySwipe(){
let p = {
_x1: device.width * 0.5,
_y1: device.height * 0.7,
_x2: device.width * 0.7,
_y2: device.height * 0.5,
x1: function() { return this._x1 + random(100, 200); },
y1: function() { return this._y1 + random(100, 200); },
x2: function() { return this._x1 + random(50, 50); },
y2: function() { return this._y2 + random(50, 100); }
};
var speedArr = [200,200,200,200,200,220,230,240,250,500,1000,2000,3000];
function innerSwipe(i){
swipe(p.x1(), p.y1(), p.x2(), p.y2(), 100 + speedArr[random(0, speedArr.length-1)]);
}
innerSwipe(1);
}
function clickBounds(obj) {
if(obj == null || !obj.bounds){
return;
}
var point = obj.bounds()
click(point.centerX() + random(0, 10), point.centerY() + random(0, 10))
}
function clickBtn(regex){
var sel = textMatches(regex);
if (sel.exists()) {
var btn = sel.findOnce();
clickBounds(btn);
}
}
var i = 1;
while(true){
jerrySwipe(1);
sleep(1000);
clickBtn(/.*点击继续搜.*/);
console.log(`完成 ${i++} 次!`);
}
参考资料
AutoX.js 不需要Root权限 的 JavaScript 自动化软件