|
|
@ -1,113 +1,223 @@ |
|
|
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */ |
|
|
|
import { DPStarter, DPTask } from './base/index'; |
|
|
|
import { clickForce, clickForceXY, isNextElement, findPrevElement, withMakeSure } from './lib/utils'; |
|
|
|
import { DPStarter, DPTask } from './lib/index'; |
|
|
|
import { clickForce, clickForceXY, isNextElement, findPrevElement, withMakeSure, swipeToCenter } from './lib/utils'; |
|
|
|
|
|
|
|
// 弹窗关闭按钮
|
|
|
|
const modalCloseBtn = className('com.lynx.tasm.behavior.ui.LynxFlattenUI') |
|
|
|
const 弹窗关闭按钮 = className('com.lynx.tasm.behavior.ui.LynxFlattenUI') |
|
|
|
.boundsInside(100, device.height / 2, device.width - 100, device.height) |
|
|
|
.clickable(true) |
|
|
|
.text(''); |
|
|
|
|
|
|
|
// 福利界面底部栏入口按钮
|
|
|
|
const welfareEntry = id('di1').text('福利').visibleToUser(); |
|
|
|
const 底部栏入口按钮 = id('di1').text('福利').visibleToUser(); |
|
|
|
|
|
|
|
const lookTime = 60 * 8; // 看剧时间 默认8小时
|
|
|
|
|
|
|
|
class Hongguo extends DPStarter { |
|
|
|
doInit() { |
|
|
|
withMakeSure('打开红果', () => app.launch('com.phoenix.read'), { |
|
|
|
landOver: [() => welfareEntry.findOne(500)] // 确认是否到达目的页
|
|
|
|
landOver: [() => 底部栏入口按钮.findOne(500)] // 确认是否到达目的页
|
|
|
|
}); |
|
|
|
const widget = welfareEntry.findOne(500); |
|
|
|
widget && clickForce(widget); |
|
|
|
clickForce(底部栏入口按钮.findOne(500)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const hongguo = new Hongguo(); |
|
|
|
|
|
|
|
const task1 = new DPTask(hongguo, '新人见面礼'); |
|
|
|
const task2 = new DPTask(hongguo, '日常福利-签到'); |
|
|
|
const task3 = new DPTask(hongguo, '看广告视频'); |
|
|
|
const task4 = new DPTask(hongguo, '看短剧'); |
|
|
|
const 新人见面礼task = new DPTask(hongguo, '新人见面礼'); |
|
|
|
const 吃饭补贴task = new DPTask(hongguo, '日常福利-吃饭补贴'); |
|
|
|
const 签到task = new DPTask(hongguo, '日常福利-签到'); |
|
|
|
const 看广告视频task = new DPTask(hongguo, '看广告视频'); |
|
|
|
const 看短剧task = new DPTask(hongguo, '看短剧'); |
|
|
|
|
|
|
|
// 新人见面礼立即领取
|
|
|
|
task1.run(() => { |
|
|
|
const startBtn = className('com.lynx.tasm.behavior.ui.text.FlattenUIText') |
|
|
|
新人见面礼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') |
|
|
|
.boundsInside(0, 0, device.width / 2, device.height / 2) |
|
|
|
.text('立即领取') |
|
|
|
.visibleToUser(); |
|
|
|
const getBtn = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('立即领取').visibleToUser(); |
|
|
|
const getGoldNext = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('金币奖励可在「福利」查看').visibleToUser(); |
|
|
|
const overBtn = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('明日再来').visibleToUser(); |
|
|
|
console.log('task1'); |
|
|
|
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 stepBtn1 = withMakeSure( |
|
|
|
'立即领取', |
|
|
|
const 确定有这个按钮 = withMakeSure( |
|
|
|
'点击立即领取', |
|
|
|
() => { |
|
|
|
clickForce(startBtn.findOne(500)); |
|
|
|
return startBtn; |
|
|
|
clickForce(开始立即领取.findOne(500)); |
|
|
|
return 开始立即领取; |
|
|
|
}, |
|
|
|
{ |
|
|
|
landOver: [() => modalCloseBtn.findOne(500), () => getGoldNext.findOne(500)], // 确认是否到达目的页
|
|
|
|
landOver: [() => 弹窗关闭按钮.findOne(500), () => 有金币奖励字样.findOne(500)], // 确认是否到达目的页
|
|
|
|
retry: 2 |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
if (stepBtn1) { |
|
|
|
if (overBtn.findOne(500)) { |
|
|
|
return clickForce(overBtn.findOne(500)); |
|
|
|
if (确定有这个按钮) { |
|
|
|
if (明日再来.findOne(500)) { |
|
|
|
return clickForce(明日再来.findOne(500)); |
|
|
|
} |
|
|
|
withMakeSure('立即领取inModal', () => clickForce(getBtn.findOne(500)), { |
|
|
|
withMakeSure('弹窗里立即领取', () => clickForce(弹窗里立即领取.findOne(500)), { |
|
|
|
landOver: [ |
|
|
|
() => modalCloseBtn.findOne(500), |
|
|
|
() => isNextElement(overBtn, getGoldNext, 'com.lynx.tasm.behavior.ui.text.FlattenUIText') |
|
|
|
() => 弹窗关闭按钮.findOne(500), |
|
|
|
() => isNextElement(明日再来, 有金币奖励字样, 'com.lynx.tasm.behavior.ui.text.FlattenUIText') |
|
|
|
] // 确认是否到达目的页
|
|
|
|
}); |
|
|
|
|
|
|
|
return clickForce(overBtn.findOne(500)); |
|
|
|
return clickForce(明日再来.findOne(500)); |
|
|
|
} else { |
|
|
|
// 如果没有找到说明任务已经做了
|
|
|
|
task.log('新人任务已经做过了'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
task2.run(() => { |
|
|
|
console.log('task2'); |
|
|
|
try { |
|
|
|
const 日常福利区域 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('日常福利').visibleToUser().findOne(500)!; |
|
|
|
swipe(日常福利区域.bounds().centerX(), 日常福利区域.bounds().centerY(), 日常福利区域.bounds().centerX(), 0, 500); |
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
} |
|
|
|
吃饭补贴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); |
|
|
|
} |
|
|
|
] |
|
|
|
}); |
|
|
|
swipeToCenter(吃饭补贴区域.findOne(500)!); |
|
|
|
|
|
|
|
const 去领取 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('去领取').visibleToUser(); |
|
|
|
const 早饭 = className('com.lynx.tasm.behavior.ui.text.UIText').textContains('早饭').visibleToUser(); |
|
|
|
const 午饭 = className('com.lynx.tasm.behavior.ui.text.UIText').textContains('午饭').visibleToUser(); |
|
|
|
const 晚饭 = className('com.lynx.tasm.behavior.ui.text.UIText').textContains('晚饭').visibleToUser(); |
|
|
|
const 夜宵 = className('com.lynx.tasm.behavior.ui.text.UIText').textContains('夜宵').visibleToUser(); |
|
|
|
|
|
|
|
withMakeSure('签到', () => clickForce(去领取.findOne(500)), { |
|
|
|
landOver: [() => 早饭.findOne(500)], // 确认是否到达目的页
|
|
|
|
retry: 2 |
|
|
|
}); |
|
|
|
|
|
|
|
const eat = (ele: UiSelector) => { |
|
|
|
clickForce(ele.findOne(500), false); |
|
|
|
const 后可领取奖励 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').textContains('后可领取奖励').visibleToUser(); |
|
|
|
const 看视频再领 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').textContains('看视频再领').visibleToUser(); |
|
|
|
sleep(3000); |
|
|
|
if (后可领取奖励.exists()) { |
|
|
|
lookAD(); |
|
|
|
sleep(3000); |
|
|
|
if (看视频再领.exists()) { |
|
|
|
clickForce(看视频再领.findOne(1500), false); |
|
|
|
lookAD(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
eat(早饭); |
|
|
|
eat(午饭); |
|
|
|
eat(晚饭); |
|
|
|
eat(夜宵); |
|
|
|
|
|
|
|
back(); |
|
|
|
}); |
|
|
|
|
|
|
|
签到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: [() => modalCloseBtn.findOne(500)], // 确认是否到达目的页
|
|
|
|
landOver: [() => 弹窗关闭按钮.findOne(500)], // 确认是否到达目的页
|
|
|
|
retry: 2 |
|
|
|
}); |
|
|
|
|
|
|
|
clickForce(立即签到.findOne(1500)); |
|
|
|
clickForce(看视频再领.findOne(1500), false); |
|
|
|
|
|
|
|
clickForce(看视频再领.findOne(3000), false); |
|
|
|
|
|
|
|
lookAD(); |
|
|
|
clickForce(modalCloseBtn.findOne(1500)); |
|
|
|
|
|
|
|
clickForce(弹窗关闭按钮.findOne(1500)); |
|
|
|
}); |
|
|
|
|
|
|
|
task3.run(() => { |
|
|
|
try { |
|
|
|
const 日常福利区域 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('日常福利').visibleToUser().findOne(500)!; |
|
|
|
swipe(日常福利区域.bounds().centerX(), 日常福利区域.bounds().centerY(), 日常福利区域.bounds().centerX(), 0, 500); |
|
|
|
} catch (e) {} |
|
|
|
const 立即领取 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').textContains('立即领取').visibleToUser(); |
|
|
|
clickForce(立即领取.findOne(500)); |
|
|
|
看广告视频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(); |
|
|
|
}); |
|
|
|
|
|
|
|
task4.run(() => { |
|
|
|
try { |
|
|
|
const 日常福利区域 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('日常福利').visibleToUser().findOne(500)!; |
|
|
|
swipe(日常福利区域.bounds().centerX(), 日常福利区域.bounds().centerY(), 日常福利区域.bounds().centerX(), 0, 500); |
|
|
|
} catch (e) {} |
|
|
|
看短剧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(); |
|
|
|
clickForce(去看剧.findOne(500)); |
|
|
|
|
|
|
@ -126,8 +236,8 @@ task4.run(() => { |
|
|
|
retry: 2, |
|
|
|
landOver: [() => 立即领取.findOne(500)] |
|
|
|
}); |
|
|
|
const current立即领取 = findPrevElement(再攒, 'com.lynx.tasm.behavior.ui.text.FlattenUIText'); |
|
|
|
clickForce(current立即领取); |
|
|
|
const 再攒旁边的立即领取 = findPrevElement(再攒, 'com.lynx.tasm.behavior.ui.text.FlattenUIText'); |
|
|
|
clickForce(再攒旁边的立即领取); |
|
|
|
if (看视频再领.exists()) { |
|
|
|
clickForce(看视频再领.findOne(1500), false); |
|
|
|
lookAD(); |
|
|
@ -137,7 +247,7 @@ task4.run(() => { |
|
|
|
const 开宝箱 = className('com.lynx.tasm.behavior.ui.text.FlattenUIText').text('开宝箱得金币'); |
|
|
|
if (开宝箱.exists()) { |
|
|
|
withMakeSure('开宝箱', () => clickForce(开宝箱.findOne(500)), { |
|
|
|
landOver: [() => modalCloseBtn.findOne(500)], // 确认是否到达目的页
|
|
|
|
landOver: [() => 弹窗关闭按钮.findOne(500)], // 确认是否到达目的页
|
|
|
|
retry: 2 |
|
|
|
}); |
|
|
|
if (看视频再领.exists()) { |
|
|
@ -145,36 +255,49 @@ task4.run(() => { |
|
|
|
lookAD(); |
|
|
|
} |
|
|
|
} |
|
|
|
clickForce(modalCloseBtn.findOne(1500)); |
|
|
|
clickForce(弹窗关闭按钮.findOne(1500)); |
|
|
|
clickForce(去看剧.findOne(500)); |
|
|
|
} |
|
|
|
if (!追剧.exists()) { |
|
|
|
looking = false; |
|
|
|
} |
|
|
|
sleep(30000); |
|
|
|
console.log(`已经看了${(new Date().getTime() - startTime) / 1000 / 60}分钟`); |
|
|
|
console.log(`已经看了${((new Date().getTime() - startTime) / 1000 / 60).toFixed(1)}分钟`); |
|
|
|
// 8小时结束
|
|
|
|
if (new Date().getTime() - startTime > 1000 * 60 * 60 * 8) { |
|
|
|
if (new Date().getTime() - startTime > 1000 * 60 * lookTime) { |
|
|
|
looking = false; |
|
|
|
} |
|
|
|
} |
|
|
|
back(); |
|
|
|
}); |
|
|
|
|
|
|
|
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(5000); |
|
|
|
sleep(3000); |
|
|
|
let ok = false; |
|
|
|
let times = 0; |
|
|
|
while (!ok) { |
|
|
|
if (times > 100) { |
|
|
|
break; |
|
|
|
} |
|
|
|
ok = 领取成功.exists(); |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|