Skip to content

Commit

Permalink
update to 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyJiangWJ committed Dec 2, 2024
2 parents af97da0 + 2222ef8 commit 5b7689e
Show file tree
Hide file tree
Showing 43 changed files with 1,828 additions and 635 deletions.
33 changes: 20 additions & 13 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2019-12-09 20:42:08
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2024-05-11 23:03:25
* @Last Modified time: 2024-12-02 15:09:26
* @Description:
*/
require('./lib/Runtimes.js')(global)
Expand Down Expand Up @@ -67,6 +67,8 @@ let default_config = {
bottomHeight: 200,
// 当以下包正在前台运行时,延迟执行
skip_running_packages: [],
// 视频app,当前app前台时先退出到桌面再打开支付宝 避免小窗执行
video_packages: [{ packageName: 'tv.danmaku.bili', appName: '哔哩哔哩' }],
warn_skipped_ignore_package: false,
warn_skipped_too_much: false,
auto_check_update: true,
Expand Down Expand Up @@ -94,19 +96,17 @@ let default_config = {
other_accessisibility_services: '',
// 不需要执行resolver
noneed_resolve_dex: false,
notificationId: 113,
notificationChannelId: 'unify_sign_channel_id',
notificationChannel: '聚合签到通知',
show_summary_notice: true,
supported_signs: [
{
name: '蚂蚁积分签到',
taskCode: 'AntCredits',
script: 'AntCredits.js',
enabled: true
},
{
name: '全家签到',
taskCode: 'Fami',
script: 'Fami.js',
enabled: true
},
{
name: '京东签到',
taskCode: 'JingDong',
Expand Down Expand Up @@ -157,11 +157,6 @@ let default_config = {
taskCode: 'fishpond',
taskName: '鱼塘签到',
enabled: true,
},
{
taskCode: 'orchard',
taskName: '叮咚果园',
enabled: true,
}
]
},
Expand Down Expand Up @@ -206,6 +201,18 @@ let default_config = {
taskCode: 'XiaomiShop',
script: 'XiaomiShop.js',
enabled: true
},
{
name: '华住会签到',
taskCode: 'HuaZhu',
script: 'HuaZhu.js',
enabled: true
},
{
name: '小米钱包',
taskCode: 'XiaomiWallet',
script: 'XiaomiWallet.js',
enabled: true
}
].concat(custom_config.supported_signs || [])
}
Expand Down Expand Up @@ -292,7 +299,7 @@ config.overwrite = (key, value) => {
}
// 扩展配置
extendSignConfig(default_config, config, CONFIG_STORAGE_NAME)
config.code_version = 'v2.2.0'
config.code_version = 'v2.3.0'
if (!isRunningMode) {
module.exports = function (__runtime__, scope) {
if (typeof scope.config_instance === 'undefined') {
Expand Down
61 changes: 14 additions & 47 deletions core/AlipayMerchantCredits.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ function SignRunner () {
sleep(500)
let creditEntry = widgetUtils.widgetGetOne('商家积分')
if (this.displayButtonAndClick(creditEntry, '商家积分')) {
return true
creditEntry = widgetUtils.widgetGetOne('每日签到')
if (this.displayButtonAndClick(creditEntry, '每日签到')) {
return true
}
}

// FloatyInstance.setFloatyText('查找 商家服务 控件')
Expand All @@ -80,31 +83,21 @@ function SignRunner () {
}

this.checkDailySign = function () {
let region = [config.device_width / 2, config.device_height * 0.3, config.device_width / 2, config.device_height * 0.3]
let targetContainer = widgetUtils.widgetGetById('am-tabs-bar-activeTab-content')
if (targetContainer) {
sleep(1000)
widgetUtils.widgetGetById('am-tabs-bar-activeTab-content')
let containerBounds = targetContainer.bounds()
logUtils.debugInfo(['根据控件信息获取ocr识别区域'])
region = [containerBounds.centerX(), containerBounds.top - 20, containerBounds.width() / 2, containerBounds.height()]
}
logUtils.debugInfo(['ocr识别区域:{}', JSON.stringify(region)])
WarningFloaty.addRectangle('识别区域', region)
sleep(1000)
if (this.captureAndCheckByOcr('^领取$', '领取按钮', region, null, true, 3)) {
let signed = this.captureAndCheckByOcr('已领取')
if (this.displayButton(signed, '已领取')) {
this.setExecuted()
} else {
FloatyInstance.setFloatyText('未找到领取按钮')
FloatyInstance.setFloatyText('未找到已领取按钮')
}

}

/**
* 执行签到
*/
this.checkAndSign = function () {
FloatyInstance.setFloatyText('查找今日签到控件')
let signEntry = widgetUtils.widgetGetOne('今日签到领.*')
let signEntry = this.captureAndCheckByOcr('今日签到领.*')
if (this.displayButton(signEntry, '今日签到')) {
let clickPoint = { x: signEntry.bounds().left, y: signEntry.bounds().bottom + signEntry.bounds().height() }
logUtils.debugInfo(['点击位置:{}', JSON.stringify(clickPoint)])
Expand All @@ -115,6 +108,7 @@ function SignRunner () {
this.doTask()
} else {
FloatyInstance.setFloatyText('未找到签到入口,可能今天已经完成签到')
this.checkDailySign()
this.findEntranceAndDoTask()
// TODO 校验是否真实的完成了签到
// this.setExecuted()
Expand All @@ -123,12 +117,7 @@ function SignRunner () {
}

this.findEntranceAndDoTask = function () {
FloatyInstance.setFloatyText('查找 领更多积分 入口')
if (this.captureAndCheckByOcr('^领更多积分$', '任务入口', null, null, true, 3)) {
this.checkDailySign()
sleep(1000)
this.doTask()
}
this.doTask()
FloatyInstance.setFloatyText('')
}

Expand All @@ -140,31 +129,9 @@ function SignRunner () {
}
let startY = config.device_height - config.device_height * 0.15
let endY = startY - config.device_height * 0.3
FloatyInstance.setFloatyText('查找去浏览|去完成')
let browserBtns = widgetUtils.widgetGetAll('去浏览|去完成') || []
let findOne = false
browserBtns = browserBtns.filter(btn => {
if (btn.text() == '去浏览') {
findOne = true
return true
}
if (findOne) {
return false
}
let btnContainer = btn.parent()
let listContainer = btnContainer.parent()
if (btnContainer.indexInParent() <= 1) {
return false
}
let titleContainer = listContainer.child(btnContainer.indexInParent() - 1)
let title = titleContainer.child(0).text()
return title.indexOf('15秒') > -1
})
let browserBtn = null
if (browserBtns.length > 0) {
browserBtn = browserBtns[0]
}
if (this.displayButtonAndClick(browserBtn, '去浏览', null, true)) {

let browserBtn = this.captureAndCheckByOcr('去浏览|去完成')
if (this.displayButtonAndClick(browserBtn, '去浏览')) {
widgetUtils.widgetWaiting('.*浏览15秒.*')
let limit = 16
while (limit-- > 0 && !widgetUtils.widgetCheck('任务已完成', 1000)) {
Expand Down
11 changes: 9 additions & 2 deletions core/BaseSignRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function BaseSignRunner () {
this.displayButtonAndClick = function (button, desc, delay, clickByA11y) {
this.displayButton(button, desc, delay)
if (button) {
if (clickByA11y && button.clickable()) {
if (clickByA11y && typeof button.clickable !== 'undefined' && button.clickable()) {
button.click()
} else if (automator.checkCenterClickable(button)) {
automator.clickCenter(button)
Expand Down Expand Up @@ -257,15 +257,18 @@ function BaseSignRunner () {
logUtils.warnInfo('当前AutoJS不支持OCR')
return null
}
content = content || regex
delay = delay || 800
if (typeof loop === 'undefined') {
loop = 3
}
FloatyInstance.hide()
logFloaty.hide()
sleep(40)
let screen = commonFunctions.captureScreen()
FloatyInstance.restore()
logUtils.debugInfo('准备OCR查找目标:' + content)
logFloaty.show()
logUtils.debugInfo('准备OCR查找目标:' + content + ' 正则:' + regex)
if (screen) {
let findText = localOcrUtil.recognizeWithBounds(screen, region, regex)
if (findText && findText.length > 0) {
Expand Down Expand Up @@ -406,6 +409,10 @@ function BaseSignRunner () {
logFloaty.pushLog(text)
}

this.replaceLastLog = function (text) {
logFloaty.replaceLastLog(text)
}

this.pushErrorLog = function (text) {
logFloaty.pushErrorLog(text)
}
Expand Down
61 changes: 15 additions & 46 deletions core/DingDong.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ function SignRunner () {
taskName: '鱼塘签到',
enabled: true,
},
{
taskCode: 'orchard',
taskName: '叮咚果园',
enabled: true,
}
]
let CREDIT_SIGN = this.subTasks[0]
let FISHPOND = this.subTasks[1]
let ORCHARD = this.subTasks[2]
let _package_name = 'com.yaya.zone'
let mine_base64 = config.dingdong_config.mine_base64
let fishpond_entry = config.dingdong_config.fishpond_entry
Expand Down Expand Up @@ -93,11 +87,8 @@ function SignRunner () {
// 鱼塘
this.fishpond()
sleep(1000)
// 果园
this.orchard()
if (this.isSubTaskExecuted(CREDIT_SIGN, true)
&& this.isSubTaskExecuted(FISHPOND, true)
&& this.isSubTaskExecuted(ORCHARD, true)) {
&& this.isSubTaskExecuted(FISHPOND, true)) {
infoLog(['全部任务完成'])
this.setExecuted()
} else {
Expand Down Expand Up @@ -154,6 +145,7 @@ function SignRunner () {
sleep(2000)
}
}
// 检测左下角入口 是否有可领取
let collect = this.captureAndCheckByImg(can_collect, '可领取')
if (collect) {
automator.click(collect.centerX(), collect.centerY())
Expand All @@ -170,6 +162,16 @@ function SignRunner () {
this.checkForTargetImg(fishpond_check, '鱼塘加载校验')
sign2 = this.captureAndCheckByImg(fishpond_normal_collect, '奖励领取')
}
// ocr保底
let hasNext = false
do {
hasNext = false
let collectIcon = this.captureAndCheckByOcr('可领取', '可领取')
if (this.displayButtonAndClick(collectIcon, '可领取')) {
sleep(1000)
hasNext = true
}
} while (hasNext)
}
closeButton = this.captureAndCheckByImg(fishpond_close, '关闭按钮')
if (closeButton) {
Expand All @@ -192,7 +194,7 @@ function SignRunner () {
let pointEntry = widgetUtils.widgetGetOne('(福利.*)?积分')
if (pointEntry) {
this.displayButtonAndClick(pointEntry, '领积分', 1000)
if (widgetUtils.widgetCheck('积分规则|福利中心')) {
if (widgetUtils.widgetCheck('积分规则|福利中心|签到提醒')) {
FloatyInstance.setFloatyText('进入积分界面成功')
sleep(1000)
let signContentReg = /^(立即|今日)?签到$/
Expand All @@ -213,43 +215,10 @@ function SignRunner () {
}
sleep(1000)
}
sleep(500)
automator.back()
sleep(1000)
sleep(500)
}
}
}

let orchardEntry = config.dingdong_config.orchard_entry
let orchardCanCollect = config.dingdong_config.orchard_can_collect
let orchardCollect = config.dingdong_config.orchard_daily_collect
let orchardCollect2 = config.dingdong_config.orchard_normal_collect
let orchardEnterCheck = config.dingdong_config.orchard_check

this.orchard = function () {
if (this.isSubTaskExecuted(ORCHARD)) {
return
}
let orchard = this.captureAndCheckByImg(orchardEntry, '叮咚果园')
if (orchard) {
automator.click(orchard.centerX(), orchard.centerY())
sleep(2000)
if (!this.checkForTargetImg(orchardEnterCheck, '果园加载校验')) {
FloatyInstance.setFloatyText('未能正确打开果园')
automator.back()
sleep(2000)
return this.orchard()
}
let canCollect = this.captureAndCheckByImg(orchardCanCollect, '可领取')
if (canCollect && this.captureAndCheckByImg(orchardEnterCheck, '领水滴', null, true)) {
this.captureAndCheckByImg(orchardCollect, '每日签到', null, true)
sleep(2000)
while (!!this.captureAndCheckByImg(orchardCollect2, '任务签到', null, true)) {
sleep(2000)
}
}
this.setSubTaskExecuted(ORCHARD)
automator.back()
sleep(1000)
}
}

Expand Down
19 changes: 15 additions & 4 deletions core/Eleme.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ function SignRunner () {
if (rewardButton) {
sleep(1000)
if (!this.signedStore.getValue().executed) {
let signBtn = widgetUtils.widgetGetOne('签到')
let signBtn = widgetUtils.widgetGetOne('^签到$')
if (signBtn) {
boundsInfo = signBtn.bounds()
FloatyInstance.setFloatyInfo({ x: boundsInfo.centerX(), y: boundsInfo.top - 10 }, '立即签到')
sleep(500)
automator.clickCenter(signBtn)
if (!signBtn.click()) {
warnInfo(['无障碍点击失败,尝试坐标点击:{},{}', boundsInfo.centerX(), boundsInfo.top - 10])
automator.click(boundsInfo.centerX(), boundsInfo.top - 10)
}
sleep(1000)
this.signedStore.updateStorageValue(value => value.executed = true)
if (widgetUtils.widgetCheck('明日签到', 500)) {
this.signedStore.updateStorageValue(value => value.executed = true)
} else {
warnInfo(['签到失败,下次执行时继续尝试'])
}
} else {
this.pushLog('未找到立即签到按钮')
let signed = widgetUtils.widgetCheck('(今日已|明日)签到.*', 1500)
Expand All @@ -63,7 +70,11 @@ function SignRunner () {
this.pushLog('今日已签到,不再检测是否已签到')
}
this.doHangTasks()
this.setExecuted()
if (!this.signedStore.getValue().executed) {
warnInfo(['今日签到判断为失败,延迟重试'])
} else {
this.setExecuted()
}
} else {
this.pushLog('未找到赚吃货豆按钮')
}
Expand Down
Loading

0 comments on commit 5b7689e

Please sign in to comment.