You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

183 lines
6.8 KiB

/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { DPStarter, DPTask } from './lib/index';
import { clickForce, isNextElement, findPrevElement, withMakeSure, swipeToCenter, nextElement } from './lib/utils';
// 弹窗关闭按钮
const = className('com.lynx.tasm.behavior.ui.LynxFlattenUI')
.boundsInside(100, device.height / 2, device.width - 100, device.height)
.clickable(true)
.text('');
// 福利界面底部栏入口按钮
const = id('di1').text('福利').visibleToUser();
class Hongguo extends DPStarter {
doInit() {
withMakeSure('打开红果', () => app.launch('com.phoenix.read'), {
hasModal: [
() => {
if (nextElement(, 'com.lynx.tasm.behavior.ui.LynxFlattenUI') === null) {
return .findOne(500);
} else {
return null;
}
}
],
landOver: [() => .findOne(500)] // 确认是否到达目的页
});
clickForce(.findOne(500));
}
doFinish() {
sleep(3000);
app.launch('org.autojs.autoxjs.v6');
}
}
const hongguo = new Hongguo();
const task = new DPTask(hongguo, '新人见面礼');
// 新人见面礼立即领取
task.run((task) => {
swipe(device.width / 2, device.height * 0.2, device.width / 2, device.height * 0.9, 500);
swipe(device.width / 2, device.height * 0.2, device.width / 2, device.height * 0.9, 500);
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').textContains('额外福利').visibleToUser();
const = findPrevElement(, 'com.lynx.tasm.behavior.ui.text.FlattenUIText');
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('立即领取').visibleToUser();
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('金币奖励可在「福利」查看').visibleToUser();
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('明日再来').visibleToUser();
const = withMakeSure(
'点击立即领取',
() => {
clickForce();
return ;
},
{
landOver: [() => .findOne(500), () => .findOne(500)], // 确认是否到达目的页
retry: 2
}
);
if () {
if (.findOne(500)) {
return clickForce(.findOne(500));
}
withMakeSure('弹窗里立即领取', () => clickForce(.findOne(500)), {
landOver: [
() => .findOne(500),
() => isNextElement(, , 'com.lynx.tasm.behavior.ui.text.FlattenUIText')
] // 确认是否到达目的页
});
return clickForce(.findOne(500));
} else {
// 如果没有找到说明任务已经做了
task.log('新人任务已经做过了');
}
});
const task = new DPTask(hongguo, '日常福利-签到');
task.run((task) => {
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('日常福利').visibleToUser();
withMakeSure('确保在日常福利区域', () => .findOne(500), {
landOver: [() => .findOne(500)], // 确认是否到达目的页
auxAction: [
(makeSure) => {
// 如果有这个控件 直接划到可视区域
makeSure && swipe(makeSure.bounds().centerX(), makeSure.bounds().centerY(), makeSure.bounds().centerX(), 0, 500);
},
() => {
// 如果没有 滑到顶部
swipe(device.width / 2, device.height * 0.2, device.width / 2, device.height * 0.9, 500);
},
() => {
// 如果没有 往下滑动
swipe(device.width / 2, device.height * 0.7, device.width / 2, 0, 500);
}
]
});
const Btn = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('去签到').visibleToUser();
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('已签到').visibleToUser();
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').textContains('立即签到').visibleToUser();
const = className('com.lynx.tasm.behavior.ui.text.UIText').textContains('看视频最高再领').visibleToUser();
if (.findOne(500)) {
task.log('签到任务已经做过了');
return;
}
withMakeSure('签到', () => clickForce(Btn.findOne(500)), {
landOver: [() => .findOne(500)], // 确认是否到达目的页
retry: 2
});
clickForce(.findOne(1500));
clickForce(.findOne(3000), false);
lookAD();
clickForce(.findOne(1500));
});
const 广task = new DPTask(hongguo, '看广告视频');
广task.run(() => {
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('日常福利').visibleToUser();
withMakeSure('确保在日常福利区域', () => .findOne(500), {
landOver: [() => .findOne(500)], // 确认是否到达目的页
auxAction: [
(makeSure) => {
// 如果有这个控件 直接划到可视区域
makeSure && swipe(makeSure.bounds().centerX(), makeSure.bounds().centerY(), makeSure.bounds().centerX(), 0, 500);
},
() => {
// 如果没有 滑到顶部
swipe(device.width / 2, device.height * 0.2, device.width / 2, device.height * 0.9, 500);
},
() => {
// 如果没有 往下滑动
swipe(device.width / 2, device.height * 0.7, device.width / 2, 0, 500);
}
]
});
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').textContains('看视频立得').visibleToUser();
swipeToCenter(.findOne(500)!);
const = findPrevElement(, 'com.lynx.tasm.behavior.ui.text.FlattenUIText');
clickForce();
lookAD();
});
function lookAD() {
//已经进入广告页面
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('领取成功').visibleToUser();
const = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('领取奖励').visibleToUser();
sleep(3000);
let ok = false;
let times = 0;
while (!ok) {
if (times > 100) {
break;
}
ok = .exists();
times % 2 === 1 && console.log('广告ing');
sleep(2000);
times++;
}
if (!ok) {
console.log('看广告失败');
return;
}
const bounds = .findOne(500)!.bounds();
click(bounds.right + 5, bounds.top + 5);
sleep(1000);
if (.exists()) {
clickForce(.findOne(500), false);
console.log('看第二个广告再次领取奖励');
lookAD();
}
}
hongguo.start();