From 6c5ac26d6138ad96574879c637e9e1249277f8ba Mon Sep 17 00:00:00 2001
From: GoldenSection0618 <172290907+GoldenSection0618@users.noreply.github.com>
Date: Sat, 24 Oct 2026 05:30:52 +0000
Subject: [PATCH 1/3] =?UTF-8?q?style:=20=E5=AF=B9=E9=BD=90=E6=90=9C?=
=?UTF-8?q?=E7=B4=A2=E8=AE=A1=E6=95=B0=E4=BF=AE=E5=A4=8D=E7=9A=84=E5=85=A8?=
=?UTF-8?q?=E9=87=8F=E6=A0=BC=E5=BC=8F=E6=A3=80=E6=9F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 48 ++++++-------
config.example.json | 5 +-
scripts/api/logParser.js | 42 +++++-------
src/browser/Browser.ts | 17 ++---
src/browser/BrowserFunc.ts | 25 ++-----
src/browser/BrowserUtils.ts | 12 +---
src/browser/MediaBlocker.ts | 6 +-
src/browser/auth/Login.ts | 68 +++++--------------
src/browser/auth/methods/GetACodeLogin.ts | 12 +---
src/browser/auth/methods/MobileAccessLogin.ts | 6 +-
src/browser/auth/methods/PasswordlessLogin.ts | 6 +-
.../auth/methods/RecoveryEmailLogin.ts | 6 +-
src/functions/QueryEngine.ts | 23 +++----
.../activities/api/ActivateSearchPerk.ts | 6 +-
src/functions/activities/api/ClaimReward.ts | 12 +---
.../activities/api/EnsureStreakProtection.ts | 6 +-
src/functions/activities/api/UrlReward.ts | 6 +-
src/functions/activities/app/AppPromotions.ts | 6 +-
src/functions/activities/app/AppReward.ts | 6 +-
src/functions/activities/app/DailyCheckIn.ts | 6 +-
src/functions/activities/app/ReadToEarn.ts | 6 +-
.../activities/experimental/ApiSearch.ts | 6 +-
.../experimental/ApiSearchOnBing.ts | 6 +-
.../activities/experimental/BingSearchApi.ts | 6 +-
.../activities/experimental/EdgeBrowsing.ts | 37 ++--------
src/functions/activities/rewards/DailySet.ts | 6 +-
.../activities/rewards/MorePromotions.ts | 6 +-
.../rewards/PromotionActivityRunner.ts | 10 +--
.../activities/rewards/PunchCards.ts | 6 +-
.../activities/search/BrowserSearch.ts | 12 +---
.../activities/search/BrowserSearchOnBing.ts | 6 +-
.../activities/search/SearchOnBingShared.ts | 12 +---
.../activities/visualSearch/VisualSearch.ts | 30 ++------
.../visualSearch/VisualSearchBrowser.ts | 12 +---
src/index.ts | 45 +++---------
src/logging/ClawBot.ts | 4 +-
src/util/ClawBotClient.ts | 18 ++---
src/util/Humanize.ts | 6 +-
38 files changed, 145 insertions(+), 413 deletions(-)
diff --git a/README.md b/README.md
index 94f8214..3700727 100644
--- a/README.md
+++ b/README.md
@@ -197,9 +197,9 @@ ACCOUNT_1_PASSWORD=your_password
>
> ```yaml
> services:
-> microsoft-rewards-script:
-> env_file:
-> - path: .env
+> microsoft-rewards-script:
+> env_file:
+> - path: .env
> ```
>
> 另外用**列表式** `environment:`(`- KEY=value`)时值**不要加引号**——引号会成为值的一部分(如 `- CRON_SCHEDULE="0 9 * * *"` 会让 cron 表达式带引号而失效);映射式(`KEY: value`)则按 YAML 规则正常加引号。
@@ -268,20 +268,20 @@ docker compose restart # 重启(不重建)
🔵 Core / 核心配置
-| 设置 | 描述 | 默认值 | Docker 环境变量 |
-| --------------------------- | ----------------------------------- | --------------- | ------------------------------------- |
-| `sessionPath` | 存储浏览器会话的目录 | `sessions` | — |
-| `headless` | 在后台运行浏览器 | `false`(可见) | Docker 强制 `true` |
-| `browserChannel` | `chromium`(内置补丁版,推荐)或 `msedge`(系统真实 Edge;⚠️ 实验性:Edge 152 + Playwright 1.6x 访问 rewards.bing.com 会崩溃,见 [playwright#41438](https://github.com/microsoft/playwright/issues/41438),修复后可重试) | `chromium` | `CONFIG_BROWSER_CHANNEL` |
-| `clusters` | 并发账户集群数 | `1` | `CONFIG_CLUSTERS` |
-| `errorDiagnostics` | 出错时保存诊断信息到 `diagnostics/` | `false` | `CONFIG_ERROR_DIAGNOSTICS` |
-| `ensureStreakProtection` | 确保连击保护已开启 | `true` | `CONFIG_ENSURE_STREAK_PROTECTION` |
-| `autoClaimPunchcardRewards` | 自动领取已完成的打卡奖励 | `false` | `CONFIG_AUTO_CLAIM_PUNCHCARD_REWARDS` |
-| `skipNonPointTasks` | 跳过无积分奖励的任务 | `true` | `CONFIG_SKIP_NON_POINT_TASKS` |
-| `prewarmDesktopLogin` | 移动端登录后立即完成桌面端登录并保存会话(需要手机批准的账户可把两次批准集中在运行开头),之后桌面阶段直接复用会话 | `false` | `CONFIG_PREWARM_DESKTOP_LOGIN` |
-| `accountDelay.min` / `.max` | 下一账户开始前的延迟 | `1min` - `3min` | `CONFIG_ACCOUNT_DELAY_MIN` / `_MAX` |
-| `searchOnBingLocalQueries` | ExploreOnBing 活动使用本地词库 | `false` | `CONFIG_SEARCH_ON_BING_LOCAL` |
-| `globalTimeout` | 所有操作的超时时间 | `30sec` | `CONFIG_GLOBAL_TIMEOUT` |
+| 设置 | 描述 | 默认值 | Docker 环境变量 |
+| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | ------------------------------------- |
+| `sessionPath` | 存储浏览器会话的目录 | `sessions` | — |
+| `headless` | 在后台运行浏览器 | `false`(可见) | Docker 强制 `true` |
+| `browserChannel` | `chromium`(内置补丁版,推荐)或 `msedge`(系统真实 Edge;⚠️ 实验性:Edge 152 + Playwright 1.6x 访问 rewards.bing.com 会崩溃,见 [playwright#41438](https://github.com/microsoft/playwright/issues/41438),修复后可重试) | `chromium` | `CONFIG_BROWSER_CHANNEL` |
+| `clusters` | 并发账户集群数 | `1` | `CONFIG_CLUSTERS` |
+| `errorDiagnostics` | 出错时保存诊断信息到 `diagnostics/` | `false` | `CONFIG_ERROR_DIAGNOSTICS` |
+| `ensureStreakProtection` | 确保连击保护已开启 | `true` | `CONFIG_ENSURE_STREAK_PROTECTION` |
+| `autoClaimPunchcardRewards` | 自动领取已完成的打卡奖励 | `false` | `CONFIG_AUTO_CLAIM_PUNCHCARD_REWARDS` |
+| `skipNonPointTasks` | 跳过无积分奖励的任务 | `true` | `CONFIG_SKIP_NON_POINT_TASKS` |
+| `prewarmDesktopLogin` | 移动端登录后立即完成桌面端登录并保存会话(需要手机批准的账户可把两次批准集中在运行开头),之后桌面阶段直接复用会话 | `false` | `CONFIG_PREWARM_DESKTOP_LOGIN` |
+| `accountDelay.min` / `.max` | 下一账户开始前的延迟 | `1min` - `3min` | `CONFIG_ACCOUNT_DELAY_MIN` / `_MAX` |
+| `searchOnBingLocalQueries` | ExploreOnBing 活动使用本地词库 | `false` | `CONFIG_SEARCH_ON_BING_LOCAL` |
+| `globalTimeout` | 所有操作的超时时间 | `30sec` | `CONFIG_GLOBAL_TIMEOUT` |
@@ -419,13 +419,13 @@ docker compose restart # 重启(不重建)
降低风控特征的运行策略集合。`humanize.enabled=false`(默认)时以下全部不生效,行为与原版一致。
-| 设置 | 描述 | 默认值 | Docker 环境变量 |
-| -------------------------------------------- | -------------------------------------------------------------------- | ----------------- | ----------------------------------------------------- |
-| `humanize.enabled` | 总开关 | `false` | `CONFIG_HUMANIZE_ENABLED` |
-| `humanize.skipWhenCompletedToday` | 当天已成功运行过(`logs/last-success.txt`)则再次启动时直接退出,配合早晚两次定时实现"兜底轮自动跳过" | `false` | `CONFIG_HUMANIZE_SKIP_WHEN_COMPLETED` |
-| `humanize.quietHours` | 静默时段数组;运行中进入时段自动挂起到结束,启动时落在时段内也等待后再跑。支持 `start > end` 跨午夜 | `[]` | 仅 config.json |
-| `humanize.searchTargetRatio.min` / `.max` | 每轮搜索目标完成度随机区间(移动/桌面各自抽取),保留分向下取整到 3 的倍数 | `0.85` - `1.0` | `CONFIG_HUMANIZE_SEARCH_TARGET_RATIO_MIN` / `_MAX` |
-| `humanize.readToEarnArticles.min` / `.max` | Read-to-Earn 每轮随机阅读篇数上限区间 | `7` - `10` | `CONFIG_HUMANIZE_READ_TO_EARN_MIN` / `_MAX` |
+| 设置 | 描述 | 默认值 | Docker 环境变量 |
+| ------------------------------------------ | ----------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------------------- |
+| `humanize.enabled` | 总开关 | `false` | `CONFIG_HUMANIZE_ENABLED` |
+| `humanize.skipWhenCompletedToday` | 当天已成功运行过(`logs/last-success.txt`)则再次启动时直接退出,配合早晚两次定时实现"兜底轮自动跳过" | `false` | `CONFIG_HUMANIZE_SKIP_WHEN_COMPLETED` |
+| `humanize.quietHours` | 静默时段数组;运行中进入时段自动挂起到结束,启动时落在时段内也等待后再跑。支持 `start > end` 跨午夜 | `[]` | 仅 config.json |
+| `humanize.searchTargetRatio.min` / `.max` | 每轮搜索目标完成度随机区间(移动/桌面各自抽取),保留分向下取整到 3 的倍数 | `0.85` - `1.0` | `CONFIG_HUMANIZE_SEARCH_TARGET_RATIO_MIN` / `_MAX` |
+| `humanize.readToEarnArticles.min` / `.max` | Read-to-Earn 每轮随机阅读篇数上限区间 | `7` - `10` | `CONFIG_HUMANIZE_READ_TO_EARN_MIN` / `_MAX` |
`quietHours` 规则示例(days 支持全名或缩写,未列出的天不静默):
diff --git a/config.example.json b/config.example.json
index 9114ed3..6187be2 100644
--- a/config.example.json
+++ b/config.example.json
@@ -40,10 +40,7 @@
"maxBonusSearches": 110,
"parallelSearching": false,
"clusterSearch": true,
- "queryEngines": [
- "china",
- "local"
- ],
+ "queryEngines": ["china", "local"],
"searchResultVisitTime": "20sec",
"searchDelay": {
"min": "6min",
diff --git a/scripts/api/logParser.js b/scripts/api/logParser.js
index bfdb440..8b8c392 100644
--- a/scripts/api/logParser.js
+++ b/scripts/api/logParser.js
@@ -100,14 +100,12 @@ function ensureAccount(state, email) {
// inside the log messages, but the surrounding text is Chinese.
const RE = {
runStart: /^启动微软奖励脚本 \| v(\S+) \| 账户数: (\d+) \| 集群数: (\d+)/,
- accountStart:
- /^开始处理账户: (\S+) \| geoLocale: ([^|]+?)(?: \| locale: (\S+))?(?: \| 缓存区域: (\S+))?\s*$/,
+ accountStart: /^开始处理账户: (\S+) \| geoLocale: ([^|]+?)(?: \| locale: (\S+))?(?: \| 缓存区域: (\S+))?\s*$/,
earnable: /^今日可赚取 \| 移动端: (\d+) \| 浏览器: (\d+) \| App: (\d+) \| (\S+) \| locale: (\S+)\s*$/,
searchSummary: /^搜索汇总 \| 移动端=(-?\d+) \| 桌面端=(-?\d+) \| 额外=(-?\d+) \| 总计=(-?\d+)/,
streakProtection:
/^快照完成 \| offers=(\d+) \| 可上报=(\d+) \| streaks=(\d+) \| 连续保护已启用=(true|false|null) \| 连续保护剩余天数=(\d+|null) \| 连续计数=(\d+|null) \| 等级=([^|]+) \| 账户=(\S+@\S+)$/,
- accountEnd:
- /^账户完成: (\S+) \| 获得积分=(-?\d+) \| 原余额=(\d+) \| 现余额=(\d+) \| 持续秒数=([\d.]+)/,
+ accountEnd: /^账户完成: (\S+) \| 获得积分=(-?\d+) \| 原余额=(\d+) \| 现余额=(\d+) \| 持续秒数=([\d.]+)/,
runEnd: /^全部账户完成 \| 处理账户数=(\d+) \| 获得积分=(-?\d+) \| 原余额=(\d+) \| 现余额=(\d+) \| 运行分钟数=([\d.]+)/,
accountError: /^(\S+@\S+) \| 错误=([\s\S]+)$/,
flowFailed: /(\S+@\S+) 的.*流程失败:/i,
@@ -142,32 +140,34 @@ function pointEventSource(title, message) {
case 'SEARCH-BONUS':
return message.startsWith('必应搜索完成') ? 'bonus' : null
case 'READ-TO-EARN':
- return (message.startsWith('文章后的积分变化') ||
- message.startsWith('未获得积分,停止读文赚积分') ||
- message.startsWith('已阅读第') ||
- message.startsWith('读文赚积分完成')) ? 'read' : null
+ return message.startsWith('文章后的积分变化') ||
+ message.startsWith('未获得积分,停止读文赚积分') ||
+ message.startsWith('已阅读第') ||
+ message.startsWith('读文赚积分完成')
+ ? 'read'
+ : null
case 'DAILY-CHECK-IN':
return message.startsWith('每日签到完成') ? 'checkIn' : null
case 'CLAIM-BONUS-POINTS':
- return (message.startsWith('领取奖励积分完成') || message.startsWith('没有可领取的积分'))
+ return message.startsWith('领取奖励积分完成') || message.startsWith('没有可领取的积分')
? 'claimBonus'
: null
case 'CLAIM-REWARD':
return message.startsWith('奖励已领取') ? 'claimReward' : null
case 'URL-REWARD':
- return (message.startsWith('UrlReward 完成') || message.startsWith('UrlReward 未获得积分'))
+ return message.startsWith('UrlReward 完成') || message.startsWith('UrlReward 未获得积分')
? 'urlReward'
: null
case 'VISUAL-SEARCH':
- return (message.startsWith('每日视觉搜索完成') || message.startsWith('每日视觉搜索已记录'))
+ return message.startsWith('每日视觉搜索完成') || message.startsWith('每日视觉搜索已记录')
? 'visualSearch'
: null
case 'APP-REWARD':
- return (message.startsWith('AppReward 完成') || message.startsWith('AppReward 完成但未获得积分'))
+ return message.startsWith('AppReward 完成') || message.startsWith('AppReward 完成但未获得积分')
? 'appReward'
: null
case 'PUNCHCARD':
- return (message.includes('COMPLETE') || message.includes('in progress')) ? 'punchcard' : null
+ return message.includes('COMPLETE') || message.includes('in progress') ? 'punchcard' : null
case 'SEARCH-ON-BING-SEARCH':
return message.startsWith('SearchOnBing 活动完成') ? 'searchOnBing' : null
default:
@@ -244,9 +244,7 @@ function applyEdgeBrowsing(state, entry) {
if (!account) return null
const message = entry.message ?? ''
- const finalReports = message.startsWith('后台 Edge 浏览活动结束')
- ? numericField(message, 'reports')
- : null
+ const finalReports = message.startsWith('后台 Edge 浏览活动结束') ? numericField(message, 'reports') : null
const progress =
fractionField(message, 'reportsCompleted') ??
fractionField(message, 'report') ??
@@ -303,16 +301,10 @@ function applyEdgeBrowsing(state, entry) {
previous.nextReportInSeconds = null
previous.estimatedRemainingMinutes = 0
previous.waitingForBackground = false
- } else if (
- message === '该账户无法使用 Edge 浏览连击(Browsing Streak)' ||
- message.startsWith('跳过:')
- ) {
+ } else if (message === '该账户无法使用 Edge 浏览连击(Browsing Streak)' || message.startsWith('跳过:')) {
previous.status = 'skipped'
previous.waitingForBackground = false
- } else if (
- message.startsWith('后台 Edge 浏览活动失败') ||
- message.startsWith('意外的后台任务失败')
- ) {
+ } else if (message.startsWith('后台 Edge 浏览活动失败') || message.startsWith('意外的后台任务失败')) {
previous.status = 'failed'
previous.waitingForBackground = false
} else if (message === '后台活动已取消') {
@@ -537,4 +529,4 @@ export function summarizeRunState(state) {
},
accounts
}
-}
\ No newline at end of file
+}
diff --git a/src/browser/Browser.ts b/src/browser/Browser.ts
index f0c8cb9..2a07a83 100644
--- a/src/browser/Browser.ts
+++ b/src/browser/Browser.ts
@@ -131,16 +131,10 @@ class Browser {
this.bot.isMobile,
'SESSION',
`正在恢复已保存的浏览器会话 | Cookie数=${session.storageState.cookies.length} | origins=${session.storageState.origins.length} | 已保存分钟数=${ageMinutes}` +
- (session.expiredCookiesRemoved
- ? ` | 已清除过期Cookie=${session.expiredCookiesRemoved}`
- : '')
+ (session.expiredCookiesRemoved ? ` | 已清除过期Cookie=${session.expiredCookiesRemoved}` : '')
)
} else {
- this.bot.logger.info(
- this.bot.isMobile,
- 'SESSION',
- '未找到已保存的浏览器会话;可能需要登录'
- )
+ this.bot.logger.info(this.bot.isMobile, 'SESSION', '未找到已保存的浏览器会话;可能需要登录')
}
const shouldUseFingerprint = this.bot.isMobile
@@ -181,8 +175,7 @@ class Browser {
}
fingerprint =
- (reuseFingerprint && savedFingerprint) ||
- (await this.generateFingerprint(this.bot.isMobile))
+ (reuseFingerprint && savedFingerprint) || (await this.generateFingerprint(this.bot.isMobile))
const screen = fingerprint.fingerprint.screen
@@ -220,9 +213,7 @@ class Browser {
}
context.on('page', p => {
- p.on('crash', () =>
- this.bot.logger.error(this.bot.isMobile, 'BROWSER', `渲染器崩溃 | ${p.url()}`)
- )
+ p.on('crash', () => this.bot.logger.error(this.bot.isMobile, 'BROWSER', `渲染器崩溃 | ${p.url()}`))
})
context.on('close', () => this.bot.logger.warn(this.bot.isMobile, 'BROWSER', '浏览器上下文已关闭'))
diff --git a/src/browser/BrowserFunc.ts b/src/browser/BrowserFunc.ts
index b664b0d..6c202b9 100644
--- a/src/browser/BrowserFunc.ts
+++ b/src/browser/BrowserFunc.ts
@@ -130,10 +130,9 @@ export default class BrowserFunc {
const firstTime = !this.botMetricsLoggedPlatforms.has(platform)
this.botMetricsLoggedPlatforms.add(platform)
- const message =
- `机器人检测指标 | serpbotscore=${score ?? '未知'} | 更新时间=${
- scoreUpdated ? String(scoreUpdated).slice(0, 16) : '未知'
- } | userWarnings=${warningNames.length > 0 ? warningNames.join(', ') : '无'}`
+ const message = `机器人检测指标 | serpbotscore=${score ?? '未知'} | 更新时间=${
+ scoreUpdated ? String(scoreUpdated).slice(0, 16) : '未知'
+ } | userWarnings=${warningNames.length > 0 ? warningNames.join(', ') : '无'}`
if (warningNames.length > 0) {
this.bot.logger.warn(this.bot.isMobile, 'GET-DASHBOARD-DATA', message)
@@ -589,11 +588,7 @@ export default class BrowserFunc {
if (isBrowserClosedError(error)) {
this.bot.logger.debug(this.bot.isMobile, 'CLOSE-BROWSER', '浏览器已处于关闭状态。')
} else {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'CLOSE-BROWSER',
- '关闭时遇到错误,但进程仍在退出。'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'CLOSE-BROWSER', '关闭时遇到错误,但进程仍在退出。')
}
}
}
@@ -618,11 +613,7 @@ export default class BrowserFunc {
return await response.text()
}
- this.bot.logger.debug(
- this.bot.isMobile,
- 'REWARDS-PAGE',
- `获取 ${route} 失败 | 状态码=${response.status()}`
- )
+ this.bot.logger.debug(this.bot.isMobile, 'REWARDS-PAGE', `获取 ${route} 失败 | 状态码=${response.status()}`)
} catch (error) {
this.bot.logger.debug(
this.bot.isMobile,
@@ -642,11 +633,7 @@ export default class BrowserFunc {
async checkpointActiveSession(source = 'SESSION-CHECKPOINT'): Promise {
const page = this.getActivePage()
if (!page) {
- this.bot.logger.debug(
- this.bot.isMobile,
- source,
- '无法保存会话检查点,因为没有可用的活动浏览器页面'
- )
+ this.bot.logger.debug(this.bot.isMobile, source, '无法保存会话检查点,因为没有可用的活动浏览器页面')
return false
}
diff --git a/src/browser/BrowserUtils.ts b/src/browser/BrowserUtils.ts
index 6a5d97b..a3598dc 100644
--- a/src/browser/BrowserUtils.ts
+++ b/src/browser/BrowserUtils.ts
@@ -50,11 +50,7 @@ export default class BrowserUtils {
if (b) {
const clicked = await this.ghostClick(page, b.selector)
if (clicked) {
- this.bot.logger.debug(
- this.bot.isMobile,
- 'DISMISS-ALL-MESSAGES',
- `已关闭: ${b.label}`
- )
+ this.bot.logger.debug(this.bot.isMobile, 'DISMISS-ALL-MESSAGES', `已关闭: ${b.label}`)
}
}
})
@@ -70,11 +66,7 @@ export default class BrowserUtils {
} else {
const accepted = await this.ghostClick(page, '#bnp_btn_accept')
if (accepted) {
- this.bot.logger.debug(
- this.bot.isMobile,
- 'DISMISS-ALL-MESSAGES',
- '已关闭: Bing Overlay Accept'
- )
+ this.bot.logger.debug(this.bot.isMobile, 'DISMISS-ALL-MESSAGES', '已关闭: Bing Overlay Accept')
}
}
await this.bot.utils.wait(250)
diff --git a/src/browser/MediaBlocker.ts b/src/browser/MediaBlocker.ts
index da7521c..3319b72 100644
--- a/src/browser/MediaBlocker.ts
+++ b/src/browser/MediaBlocker.ts
@@ -30,11 +30,7 @@ export function suspendMediaBlocking(bot: MicrosoftRewardsBot, context: BrowserC
if (!state?.enabled) return
state.enabled = false
- bot.logger.info(
- bot.isMobile,
- 'BROWSER',
- '登录期间媒体加载已放行 | 图片与媒体请求暂不拦截'
- )
+ bot.logger.info(bot.isMobile, 'BROWSER', '登录期间媒体加载已放行 | 图片与媒体请求暂不拦截')
}
export async function configureMediaBlocking(bot: MicrosoftRewardsBot, context: BrowserContext): Promise {
diff --git a/src/browser/auth/Login.ts b/src/browser/auth/Login.ts
index 608c83e..0a6c040 100644
--- a/src/browser/auth/Login.ts
+++ b/src/browser/auth/Login.ts
@@ -133,11 +133,7 @@ export class Login {
`相同状态计数: ${sameStateCount}/4 状态为 "${state}"`
)
if (sameStateCount >= 4) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'LOGIN',
- `在状态 "${state}" 停滞4次循环,刷新页面`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'LOGIN', `在状态 "${state}" 停滞4次循环,刷新页面`)
await page.reload({ waitUntil: 'domcontentloaded' })
await this.bot.utils.wait(3000)
sameStateCount = 0
@@ -265,11 +261,7 @@ export class Login {
results.push('FOOTER_ACTION')
} else {
if (footerAction && footerTargetsSpecificProof) {
- this.bot.logger.debug(
- this.bot.isMobile,
- 'DETECT-STATE',
- '页脚指向具体验证方式;保持主登录方式'
- )
+ this.bot.logger.debug(this.bot.isMobile, 'DETECT-STATE', '页脚指向具体验证方式;保持主登录方式')
}
this.bot.logger.debug(this.bot.isMobile, 'DETECT-STATE', '检测到主无密码登录操作')
results.push('PASSWORDLESS_SEND_CODE')
@@ -473,7 +465,12 @@ export class Login {
const alertCount = await alertEls.count()
let errorMsg = ''
for (let i = 0; i < alertCount; i++) {
- const text = (await alertEls.nth(i).innerText().catch(() => '')).trim()
+ const text = (
+ await alertEls
+ .nth(i)
+ .innerText()
+ .catch(() => '')
+ ).trim()
if (text) {
errorMsg = text
break
@@ -503,11 +500,7 @@ export class Login {
// Enter password - use it only when Microsoft actually presents the password page
case 'PASSWORD_INPUT': {
if (!account.password) {
- this.bot.logger.info(
- this.bot.isMobile,
- 'LOGIN',
- '检测到密码输入页但未配置密码;返回登录方式选择'
- )
+ this.bot.logger.info(this.bot.isMobile, 'LOGIN', '检测到密码输入页但未配置密码;返回登录方式选择')
if (await this.tryClick(page, this.selectors.backButton, 'Back button')) return true
this.bot.logger.warn(this.bot.isMobile, 'LOGIN', '未配置密码且无法返回登录方式选择')
@@ -599,11 +592,7 @@ export class Login {
const confirmed = await this.bot.browser.utils.ghostClick(page, this.selectors.primaryButton)
if (!confirmed) {
this.passwordlessMethodSelected = false
- this.bot.logger.warn(
- this.bot.isMobile,
- 'LOGIN',
- '无法发送Microsoft Authenticator请求'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'LOGIN', '无法发送Microsoft Authenticator请求')
return false
}
await this.waitForIdle(page, 'after Microsoft Authenticator request')
@@ -619,7 +608,6 @@ export class Login {
this.bot.isMobile,
'LOGIN',
'没有可用的非交互登录方式;邮箱验证码回退需要交互式终端输入'
-
)
return false
}
@@ -667,11 +655,7 @@ export class Login {
case 'EMAIL_VERIFICATION_INPUT': {
if (!account.password) {
if (!canPromptForInput()) {
- this.bot.logger.error(
- this.bot.isMobile,
- 'LOGIN',
- '邮箱验证需要已配置的密码或交互式终端输入'
- )
+ this.bot.logger.error(this.bot.isMobile, 'LOGIN', '邮箱验证需要已配置的密码或交互式终端输入')
return false
}
@@ -680,11 +664,7 @@ export class Login {
return true
}
- this.bot.logger.info(
- this.bot.isMobile,
- 'LOGIN',
- '检测到邮箱验证输入;正在检查备选方式'
- )
+ this.bot.logger.info(this.bot.isMobile, 'LOGIN', '检测到邮箱验证输入;正在检查备选方式')
await this.waitForIdle(page, 'on email verification page')
const footerActions = page.locator(this.selectors.footerAction)
@@ -800,11 +780,7 @@ export class Login {
// Enter your code - prefer its alternate-method footer before Back to avoid an email-code loop
case 'OTP_CODE_ENTRY': {
- this.bot.logger.info(
- this.bot.isMobile,
- 'LOGIN',
- '检测到OTP代码输入页面;尝试可用的备选登录方式'
- )
+ this.bot.logger.info(this.bot.isMobile, 'LOGIN', '检测到OTP代码输入页面;尝试可用的备选登录方式')
if (await this.checkSelector(page, this.selectors.footerAction)) {
const clicked = await this.bot.browser.utils.ghostClick(page, this.selectors.footerAction)
@@ -836,11 +812,7 @@ export class Login {
return true
}
- this.bot.logger.debug(
- this.bot.isMobile,
- 'LOGIN',
- 'OTP页脚操作未离开代码输入页;回退到返回按钮'
- )
+ this.bot.logger.debug(this.bot.isMobile, 'LOGIN', 'OTP页脚操作未离开代码输入页;回退到返回按钮')
}
}
@@ -857,11 +829,7 @@ export class Login {
case 'UNKNOWN': {
const rawUrl = page.url()
const url = new URL(rawUrl)
- this.bot.logger.warn(
- this.bot.isMobile,
- 'LOGIN',
- `在 ${url.hostname}${url.pathname} 的未知状态,等待中`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'LOGIN', `在 ${url.hostname}${url.pathname} 的未知状态,等待中`)
if (this.bot.config.errorDiagnostics && !this.capturedUnknownUrls.has(rawUrl)) {
this.capturedUnknownUrls.add(rawUrl)
@@ -1020,11 +988,7 @@ export class Login {
} catch (error) {
const message = error instanceof Error ? error.message : String(error)
- this.bot.logger.error(
- this.bot.isMobile,
- 'GET-REWARD-SESSION',
- `获取奖励上下文失败: ${message}`
- )
+ this.bot.logger.error(this.bot.isMobile, 'GET-REWARD-SESSION', `获取奖励上下文失败: ${message}`)
throw new Error(`获取奖励上下文失败: ${message}`)
}
diff --git a/src/browser/auth/methods/GetACodeLogin.ts b/src/browser/auth/methods/GetACodeLogin.ts
index a71b68c..20adbb6 100644
--- a/src/browser/auth/methods/GetACodeLogin.ts
+++ b/src/browser/auth/methods/GetACodeLogin.ts
@@ -115,17 +115,9 @@ export class CodeLogin {
if (emailProofInput) {
const selectorVariant =
emailProofInput.selector === this.emailVerificationInputSelectors[0] ? 'new' : 'old'
- this.bot.logger.debug(
- this.bot.isMobile,
- 'LOGIN-CODE',
- `使用${selectorVariant}版邮箱验证输入选择器`
- )
+ this.bot.logger.debug(this.bot.isMobile, 'LOGIN-CODE', `使用${selectorVariant}版邮箱验证输入选择器`)
const maskedHint = emailMessage?.match(/[A-Za-z0-9._*+-]+@[A-Za-z0-9.*-]+\.[A-Za-z]{2,}/)?.[0]
- this.bot.logger.info(
- this.bot.isMobile,
- 'LOGIN-CODE',
- '检测到邮箱验证挑战,等待邮箱地址'
- )
+ this.bot.logger.info(this.bot.isMobile, 'LOGIN-CODE', '检测到邮箱验证挑战,等待邮箱地址')
let emailVerified = false
for (let attempt = 1; attempt <= this.maxManualAttempts; attempt++) {
diff --git a/src/browser/auth/methods/MobileAccessLogin.ts b/src/browser/auth/methods/MobileAccessLogin.ts
index 7e60ef8..b4d2eeb 100644
--- a/src/browser/auth/methods/MobileAccessLogin.ts
+++ b/src/browser/auth/methods/MobileAccessLogin.ts
@@ -51,11 +51,7 @@ export class MobileAccessLogin {
}
if (!code) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'LOGIN-APP',
- '无法解析移动OAuth代码 - 本次运行将跳过应用活动'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'LOGIN-APP', '无法解析移动OAuth代码 - 本次运行将跳过应用活动')
return ''
}
diff --git a/src/browser/auth/methods/PasswordlessLogin.ts b/src/browser/auth/methods/PasswordlessLogin.ts
index 5574bbc..7d280f4 100644
--- a/src/browser/auth/methods/PasswordlessLogin.ts
+++ b/src/browser/auth/methods/PasswordlessLogin.ts
@@ -96,11 +96,7 @@ export class PasswordlessLogin {
await this.bot.utils.wait(1000)
}
- this.bot.logger.warn(
- this.bot.isMobile,
- 'LOGIN-PASSWORDLESS',
- `${this.approvalTimeoutSeconds} 秒后批准超时!`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'LOGIN-PASSWORDLESS', `${this.approvalTimeoutSeconds} 秒后批准超时!`)
return 'TIMED_OUT'
}
diff --git a/src/browser/auth/methods/RecoveryEmailLogin.ts b/src/browser/auth/methods/RecoveryEmailLogin.ts
index 269839a..3ec7356 100644
--- a/src/browser/auth/methods/RecoveryEmailLogin.ts
+++ b/src/browser/auth/methods/RecoveryEmailLogin.ts
@@ -71,11 +71,7 @@ export class RecoveryLogin {
throw new Error('Recovery email is required because interactive stdin is unavailable')
}
- this.bot.logger.info(
- this.bot.isMobile,
- 'LOGIN-RECOVERY',
- '未提供恢复邮箱,将提示用户输入'
- )
+ this.bot.logger.info(this.bot.isMobile, 'LOGIN-RECOVERY', '未提供恢复邮箱,将提示用户输入')
for (let attempt = 1; attempt <= this.maxManualAttempts; attempt++) {
this.bot.logger.info(
diff --git a/src/functions/QueryEngine.ts b/src/functions/QueryEngine.ts
index a1edf53..d93851c 100644
--- a/src/functions/QueryEngine.ts
+++ b/src/functions/QueryEngine.ts
@@ -129,11 +129,7 @@ export class QueryCore {
if (!handler) continue
const topics = await Promise.resolve(handler())
- this.bot.logger.debug(
- this.bot.isMobile,
- 'QUERY-MANAGER',
- `源 "${source}" 返回 ${topics.length} 条`
- )
+ this.bot.logger.debug(this.bot.isMobile, 'QUERY-MANAGER', `源 "${source}" 返回 ${topics.length} 条`)
if (!topics.length) continue
// 主源全量纳入;后续源只随机抽样 FALLBACK_LOCAL_SAMPLE 个补充
@@ -169,11 +165,7 @@ export class QueryCore {
if (shuffle) {
this.bot.utils.shuffleArray(topics)
- this.bot.logger.debug(
- this.bot.isMobile,
- 'QUERY-MANAGER',
- `主题词池已打乱 | 首个="${topics[0] ?? ''}"`
- )
+ this.bot.logger.debug(this.bot.isMobile, 'QUERY-MANAGER', `主题词池已打乱 | 首个="${topics[0] ?? ''}"`)
}
this.bot.logger.debug(
@@ -531,7 +523,11 @@ export class QueryCore {
const feeds = RSS_FEEDS[site]
if (!feeds) {
- this.bot.logger.warn(this.bot.isMobile, 'SEARCH-RSS', `未知的 RSS 站点 "${site}"(选择器 "${selector}")`)
+ this.bot.logger.warn(
+ this.bot.isMobile,
+ 'SEARCH-RSS',
+ `未知的 RSS 站点 "${site}"(选择器 "${selector}")`
+ )
continue
}
@@ -693,10 +689,7 @@ export class QueryCore {
await maybeBackoff(backoffMultiplier)
const source = fallback[i]!
try {
- const result = await this.fetchChinaHotWords(
- this.buildChinaApiUrl(baseUrl, source, appkey),
- source
- )
+ const result = await this.fetchChinaHotWords(this.buildChinaApiUrl(baseUrl, source, appkey), source)
if (result.length) {
result.forEach(t => titles.add(t))
this.bot.logger.info(
diff --git a/src/functions/activities/api/ActivateSearchPerk.ts b/src/functions/activities/api/ActivateSearchPerk.ts
index cc1ef87..be15ffb 100644
--- a/src/functions/activities/api/ActivateSearchPerk.ts
+++ b/src/functions/activities/api/ActivateSearchPerk.ts
@@ -49,11 +49,7 @@ export class ActivateSearchPerk extends BaseActivity {
public async activate(data: DashboardData) {
const perk = detectSearchMultiplierPerk(data.dashboard)
if (!perk) {
- this.bot.logger.debug(
- this.bot.isMobile,
- 'ACTIVATE-SEARCH-PERK',
- 'dashboard 上没有搜索倍数加成'
- )
+ this.bot.logger.debug(this.bot.isMobile, 'ACTIVATE-SEARCH-PERK', 'dashboard 上没有搜索倍数加成')
return
}
diff --git a/src/functions/activities/api/ClaimReward.ts b/src/functions/activities/api/ClaimReward.ts
index 4886a58..1d76cf3 100644
--- a/src/functions/activities/api/ClaimReward.ts
+++ b/src/functions/activities/api/ClaimReward.ts
@@ -8,11 +8,7 @@ export class ClaimReward extends BaseActivity {
const actionId = this.bot.nextActions.reportActivity
if (!actionId) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'CLAIM-REWARD',
- `跳过 ${offerId}:bundle 中未发现 "reportActivity"`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'CLAIM-REWARD', `跳过 ${offerId}:bundle 中未发现 "reportActivity"`)
return
}
@@ -21,11 +17,7 @@ export class ClaimReward extends BaseActivity {
return
}
if (!child.reportable) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'CLAIM-REWARD',
- `跳过 ${offerId}:不可上报(已完成/已锁定/已禁用)`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'CLAIM-REWARD', `跳过 ${offerId}:不可上报(已完成/已锁定/已禁用)`)
return
}
diff --git a/src/functions/activities/api/EnsureStreakProtection.ts b/src/functions/activities/api/EnsureStreakProtection.ts
index b9082c4..5b40f0a 100644
--- a/src/functions/activities/api/EnsureStreakProtection.ts
+++ b/src/functions/activities/api/EnsureStreakProtection.ts
@@ -34,11 +34,7 @@ export class EnsureStreakProtection extends BaseActivity {
}
if (before && before.remainingDays === 0) {
- this.bot.logger.info(
- this.bot.isMobile,
- 'ENABLE-STREAK-PROTECTION',
- '没有剩余的保护天数 - 开关已禁用,跳过'
- )
+ this.bot.logger.info(this.bot.isMobile, 'ENABLE-STREAK-PROTECTION', '没有剩余的保护天数 - 开关已禁用,跳过')
return
}
diff --git a/src/functions/activities/api/UrlReward.ts b/src/functions/activities/api/UrlReward.ts
index 704fe6d..af68cf3 100644
--- a/src/functions/activities/api/UrlReward.ts
+++ b/src/functions/activities/api/UrlReward.ts
@@ -12,11 +12,7 @@ export class UrlReward extends BaseActivity {
const actionId = this.bot.nextActions.reportActivity
if (!actionId) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'URL-REWARD',
- `跳过 ${offerId}:bundle 中未发现 "reportActivity"`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'URL-REWARD', `跳过 ${offerId}:bundle 中未发现 "reportActivity"`)
return
}
diff --git a/src/functions/activities/app/AppPromotions.ts b/src/functions/activities/app/AppPromotions.ts
index 43ff8f6..35147c4 100644
--- a/src/functions/activities/app/AppPromotions.ts
+++ b/src/functions/activities/app/AppPromotions.ts
@@ -13,11 +13,7 @@ export class AppPromotions extends BaseActivity {
})
if (!pending.length) {
- this.bot.logger.info(
- this.bot.isMobile,
- 'APP-PROMOTIONS',
- '所有"应用推广"项目已完成'
- )
+ this.bot.logger.info(this.bot.isMobile, 'APP-PROMOTIONS', '所有"应用推广"项目已完成')
return
}
diff --git a/src/functions/activities/app/AppReward.ts b/src/functions/activities/app/AppReward.ts
index 0b4cf67..a795038 100644
--- a/src/functions/activities/app/AppReward.ts
+++ b/src/functions/activities/app/AppReward.ts
@@ -12,11 +12,7 @@ export class AppReward extends BaseActivity {
public async doAppReward(promotion: Promotion) {
if (!this.bot.accessToken) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'APP-REWARD',
- '跳过:应用访问令牌不可用,此活动需要它!'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'APP-REWARD', '跳过:应用访问令牌不可用,此活动需要它!')
return
}
diff --git a/src/functions/activities/app/DailyCheckIn.ts b/src/functions/activities/app/DailyCheckIn.ts
index 3157034..1d64e5a 100644
--- a/src/functions/activities/app/DailyCheckIn.ts
+++ b/src/functions/activities/app/DailyCheckIn.ts
@@ -10,11 +10,7 @@ export class DailyCheckIn extends BaseActivity {
public async doDailyCheckIn() {
if (!this.bot.accessToken) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'DAILY-CHECK-IN',
- '跳过:应用访问令牌不可用,此活动需要它!'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'DAILY-CHECK-IN', '跳过:应用访问令牌不可用,此活动需要它!')
return
}
diff --git a/src/functions/activities/app/ReadToEarn.ts b/src/functions/activities/app/ReadToEarn.ts
index 7762fe3..8518b33 100644
--- a/src/functions/activities/app/ReadToEarn.ts
+++ b/src/functions/activities/app/ReadToEarn.ts
@@ -8,11 +8,7 @@ import { BaseActivity } from '../BaseActivity'
export class ReadToEarn extends BaseActivity {
public async doReadToEarn() {
if (!this.bot.accessToken) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'READ-TO-EARN',
- '跳过:应用访问令牌不可用,此活动需要它!'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'READ-TO-EARN', '跳过:应用访问令牌不可用,此活动需要它!')
return
}
diff --git a/src/functions/activities/experimental/ApiSearch.ts b/src/functions/activities/experimental/ApiSearch.ts
index 30a2b87..83da44f 100644
--- a/src/functions/activities/experimental/ApiSearch.ts
+++ b/src/functions/activities/experimental/ApiSearch.ts
@@ -140,11 +140,7 @@ export class ApiSearch extends BaseActivity {
}
if (stagnant >= STAGNANT_LIMIT) {
- this.bot.logger.warn(
- isMobile,
- 'SEARCH-BING',
- `连续 ${STAGNANT_LIMIT} 次搜索未得分,中止`
- )
+ this.bot.logger.warn(isMobile, 'SEARCH-BING', `连续 ${STAGNANT_LIMIT} 次搜索未得分,中止`)
break
}
diff --git a/src/functions/activities/experimental/ApiSearchOnBing.ts b/src/functions/activities/experimental/ApiSearchOnBing.ts
index f2a1695..c18c653 100644
--- a/src/functions/activities/experimental/ApiSearchOnBing.ts
+++ b/src/functions/activities/experimental/ApiSearchOnBing.ts
@@ -25,11 +25,7 @@ export class ApiSearchOnBing extends BaseActivity {
try {
if (!(await activateSearchOnBing(this.bot, promotion))) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'SEARCH-ON-BING',
- `搜索活动无法激活,中止 | offerId=${offerId}`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'SEARCH-ON-BING', `搜索活动无法激活,中止 | offerId=${offerId}`)
return
}
diff --git a/src/functions/activities/experimental/BingSearchApi.ts b/src/functions/activities/experimental/BingSearchApi.ts
index 321490a..05b74eb 100644
--- a/src/functions/activities/experimental/BingSearchApi.ts
+++ b/src/functions/activities/experimental/BingSearchApi.ts
@@ -57,11 +57,7 @@ export class BingSearchApi {
const ig = this.readIg(searchResponse.data)
if (!ig) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'SEARCH-REPORT',
- `查询 "${query}" 无 IG - SERP 未按预期返回`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'SEARCH-REPORT', `查询 "${query}" 无 IG - SERP 未按预期返回`)
return { ig: null, ...this.emptyReport(), gained: null }
}
diff --git a/src/functions/activities/experimental/EdgeBrowsing.ts b/src/functions/activities/experimental/EdgeBrowsing.ts
index d95bc06..7ebedce 100644
--- a/src/functions/activities/experimental/EdgeBrowsing.ts
+++ b/src/functions/activities/experimental/EdgeBrowsing.ts
@@ -74,11 +74,7 @@ export class EdgeBrowsing extends BaseActivity {
if (signal?.aborted) return
if (activation === 'absent') {
- this.bot.logger.info(
- this.bot.isMobile,
- LOG_TAG,
- '该账户无法使用 Edge 浏览连击(Browsing Streak)'
- )
+ this.bot.logger.info(this.bot.isMobile, LOG_TAG, '该账户无法使用 Edge 浏览连击(Browsing Streak)')
return
}
@@ -228,9 +224,7 @@ export class EdgeBrowsing extends BaseActivity {
this.bot.logger.error(
this.bot.isMobile,
LOG_TAG,
- `后台 Edge 浏览活动失败 | message=${
- error instanceof Error ? error.message : String(error)
- }`
+ `后台 Edge 浏览活动失败 | message=${error instanceof Error ? error.message : String(error)}`
)
}
}
@@ -301,30 +295,18 @@ export class EdgeBrowsing extends BaseActivity {
}
if (!offer.hash) {
- this.bot.logger.warn(
- this.bot.isMobile,
- LOG_TAG,
- `激活 offer 存在但缺少 hash | offerId=${offer.offerId}`
- )
+ this.bot.logger.warn(this.bot.isMobile, LOG_TAG, `激活 offer 存在但缺少 hash | offerId=${offer.offerId}`)
return 'failed'
}
if (!offer.reportable && !offer.isLocked) {
- this.bot.logger.warn(
- this.bot.isMobile,
- LOG_TAG,
- `激活 offer 不可操作 | offerId=${offer.offerId}`
- )
+ this.bot.logger.warn(this.bot.isMobile, LOG_TAG, `激活 offer 不可操作 | offerId=${offer.offerId}`)
return 'failed'
}
const actionId = this.bot.nextActions.reportActivity
if (!actionId) {
- this.bot.logger.warn(
- this.bot.isMobile,
- LOG_TAG,
- '跳过激活:bundle 中未发现 "reportActivity" action id'
- )
+ this.bot.logger.warn(this.bot.isMobile, LOG_TAG, '跳过激活:bundle 中未发现 "reportActivity" action id')
return 'failed'
}
@@ -647,11 +629,7 @@ export class EdgeBrowsing extends BaseActivity {
private resolveSettings(profile: AppDashboardData): EdgeBrowsingSettings | null {
const promotion = this.findPromotion(profile)
if (!promotion) {
- this.bot.logger.info(
- this.bot.isMobile,
- LOG_TAG,
- '该账户无法使用 Edge 浏览连击(Browsing Streak)'
- )
+ this.bot.logger.info(this.bot.isMobile, LOG_TAG, '该账户无法使用 Edge 浏览连击(Browsing Streak)')
return null
}
@@ -661,8 +639,7 @@ export class EdgeBrowsing extends BaseActivity {
this.bot.logger.warn(
this.bot.isMobile,
LOG_TAG,
- `跳过:优惠元数据不完整 | offerId=${offerId || 'missing'}` +
- ` | type=${activityType || 'missing'}`
+ `跳过:优惠元数据不完整 | offerId=${offerId || 'missing'}` + ` | type=${activityType || 'missing'}`
)
return null
}
diff --git a/src/functions/activities/rewards/DailySet.ts b/src/functions/activities/rewards/DailySet.ts
index e55a435..b2337e4 100644
--- a/src/functions/activities/rewards/DailySet.ts
+++ b/src/functions/activities/rewards/DailySet.ts
@@ -13,11 +13,7 @@ export class DailySet extends BaseActivity {
return
}
- this.bot.logger.info(
- this.bot.isMobile,
- 'DAILY-SET',
- `开始解决"每日任务"项目 | remaining=${pending.length}`
- )
+ this.bot.logger.info(this.bot.isMobile, 'DAILY-SET', `开始解决"每日任务"项目 | remaining=${pending.length}`)
await new PromotionActivityRunner(this.bot).run(pending)
this.bot.logger.info(this.bot.isMobile, 'DAILY-SET', '"每日任务"项目处理完毕')
}
diff --git a/src/functions/activities/rewards/MorePromotions.ts b/src/functions/activities/rewards/MorePromotions.ts
index 907d731..40ea675 100644
--- a/src/functions/activities/rewards/MorePromotions.ts
+++ b/src/functions/activities/rewards/MorePromotions.ts
@@ -17,11 +17,7 @@ export class MorePromotions extends BaseActivity {
const pending = promotions.filter(promotion => this.isActionable(promotion))
if (!pending.length) {
- this.bot.logger.info(
- this.bot.isMobile,
- 'MORE-PROMOTIONS',
- '所有"更多推广"项目已完成'
- )
+ this.bot.logger.info(this.bot.isMobile, 'MORE-PROMOTIONS', '所有"更多推广"项目已完成')
return
}
diff --git a/src/functions/activities/rewards/PromotionActivityRunner.ts b/src/functions/activities/rewards/PromotionActivityRunner.ts
index 9f2299d..391cdb3 100644
--- a/src/functions/activities/rewards/PromotionActivityRunner.ts
+++ b/src/functions/activities/rewards/PromotionActivityRunner.ts
@@ -36,9 +36,7 @@ export class PromotionActivityRunner extends BaseActivity {
this.bot.logger.warn(
this.bot.isMobile,
'ACTIVITY',
- `跳过活动 "${promotion.title}" | offerId=${offerId} | 原因:不支持的类型 "${
- promotion.promotionType
- }"`
+ `跳过活动 "${promotion.title}" | offerId=${offerId} | 原因:不支持的类型 "${promotion.promotionType}"`
)
return
}
@@ -73,10 +71,6 @@ export class PromotionActivityRunner extends BaseActivity {
}
private logDisabled(activity: string, offerId: string): void {
- this.bot.logger.info(
- this.bot.isMobile,
- 'ACTIVITY',
- `跳过 "${activity}"(配置中已禁用) | offerId=${offerId}`
- )
+ this.bot.logger.info(this.bot.isMobile, 'ACTIVITY', `跳过 "${activity}"(配置中已禁用) | offerId=${offerId}`)
}
}
diff --git a/src/functions/activities/rewards/PunchCards.ts b/src/functions/activities/rewards/PunchCards.ts
index 92152db..36fcf2a 100644
--- a/src/functions/activities/rewards/PunchCards.ts
+++ b/src/functions/activities/rewards/PunchCards.ts
@@ -236,11 +236,7 @@ export class PunchCards extends BaseActivity {
private async reportQuestChild(child: QuestChild, parentId: string): Promise {
const actionId = this.bot.nextActions.reportActivity
if (!actionId) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'PUNCHCARD',
- `跳过 ${child.offerId}:未发现 "reportActivity"`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'PUNCHCARD', `跳过 ${child.offerId}:未发现 "reportActivity"`)
return
}
if (!child.hash) {
diff --git a/src/functions/activities/search/BrowserSearch.ts b/src/functions/activities/search/BrowserSearch.ts
index 1ae2bd2..3e08924 100644
--- a/src/functions/activities/search/BrowserSearch.ts
+++ b/src/functions/activities/search/BrowserSearch.ts
@@ -281,18 +281,10 @@ class PointsTracker implements SearchTracker {
if (this.missing.totalPoints <= 0) {
if (!this.runOnZeroPoints) {
- this.bot.logger.info(
- this.isMobile,
- this.context,
- '无可赚搜索积分,跳过(runOnZeroPoints 已禁用)'
- )
+ this.bot.logger.info(this.isMobile, this.context, '无可赚搜索积分,跳过(runOnZeroPoints 已禁用)')
return false
}
- this.bot.logger.info(
- this.isMobile,
- this.context,
- '未报告搜索积分,但 runOnZeroPoints 已启用,仍继续搜索'
- )
+ this.bot.logger.info(this.isMobile, this.context, '未报告搜索积分,但 runOnZeroPoints 已启用,仍继续搜索')
}
return true
}
diff --git a/src/functions/activities/search/BrowserSearchOnBing.ts b/src/functions/activities/search/BrowserSearchOnBing.ts
index d1d3d66..1b5eb6f 100644
--- a/src/functions/activities/search/BrowserSearchOnBing.ts
+++ b/src/functions/activities/search/BrowserSearchOnBing.ts
@@ -25,11 +25,7 @@ export class SearchOnBing extends BaseActivity {
try {
const activated = await activateSearchOnBing(this.bot, promotion)
if (!activated) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'SEARCH-ON-BING',
- `搜索活动无法激活,中止 | offerId=${offerId}`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'SEARCH-ON-BING', `搜索活动无法激活,中止 | offerId=${offerId}`)
return
}
diff --git a/src/functions/activities/search/SearchOnBingShared.ts b/src/functions/activities/search/SearchOnBingShared.ts
index 1c91383..1f90a46 100644
--- a/src/functions/activities/search/SearchOnBingShared.ts
+++ b/src/functions/activities/search/SearchOnBingShared.ts
@@ -15,22 +15,14 @@ export async function activateSearchOnBing(bot: MicrosoftRewardsBot, promotion:
const actionId = bot.nextActions.reportActivity
if (!actionId) {
- bot.logger.warn(
- bot.isMobile,
- 'SEARCH-ON-BING-ACTIVATE',
- `跳过 ${offerId}: 未在 bundle 中发现 "reportActivity"`
- )
+ bot.logger.warn(bot.isMobile, 'SEARCH-ON-BING-ACTIVATE', `跳过 ${offerId}: 未在 bundle 中发现 "reportActivity"`)
return false
}
const live = await bot.browser.func.ensureOffer(offerId)
const hash = live?.hash ?? promotion.hash ?? null
if (!hash) {
- bot.logger.warn(
- bot.isMobile,
- 'SEARCH-ON-BING-ACTIVATE',
- `跳过 ${offerId}: 激活活动无可用 hash`
- )
+ bot.logger.warn(bot.isMobile, 'SEARCH-ON-BING-ACTIVATE', `跳过 ${offerId}: 激活活动无可用 hash`)
return false
}
diff --git a/src/functions/activities/visualSearch/VisualSearch.ts b/src/functions/activities/visualSearch/VisualSearch.ts
index 912e76a..783c1f6 100644
--- a/src/functions/activities/visualSearch/VisualSearch.ts
+++ b/src/functions/activities/visualSearch/VisualSearch.ts
@@ -53,11 +53,7 @@ export class VisualSearch extends BaseActivity {
const available = streak?.isEnabled === true || activation === 'activated' || activation === 'already-active'
if (!available) {
- this.bot.logger.info(
- this.bot.isMobile,
- 'VISUAL-SEARCH',
- '该账户无法使用视觉搜索,跳过'
- )
+ this.bot.logger.info(this.bot.isMobile, 'VISUAL-SEARCH', '该账户无法使用视觉搜索,跳过')
return 0
}
@@ -79,11 +75,7 @@ export class VisualSearch extends BaseActivity {
private logStreakState(streak: StreakState | undefined): void {
if (!streak) {
- this.bot.logger.info(
- this.bot.isMobile,
- 'VISUAL-SEARCH',
- '快照中没有视觉搜索连击 - 回退到激活优惠'
- )
+ this.bot.logger.info(this.bot.isMobile, 'VISUAL-SEARCH', '快照中没有视觉搜索连击 - 回退到激活优惠')
return
}
@@ -94,11 +86,7 @@ export class VisualSearch extends BaseActivity {
)
if (!streak.isEnabled) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'VISUAL-SEARCH',
- '连击存在但未启用 - 开启前搜索不会被记录'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'VISUAL-SEARCH', '连击存在但未启用 - 开启前搜索不会被记录')
}
}
@@ -133,11 +121,7 @@ export class VisualSearch extends BaseActivity {
}
if (!offer.reportable && !offer.isLocked) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'VISUAL-SEARCH',
- `激活优惠无法执行 | offerId=${offer.offerId}`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'VISUAL-SEARCH', `激活优惠无法执行 | offerId=${offer.offerId}`)
return 'failed'
}
@@ -461,11 +445,7 @@ export class VisualSearch extends BaseActivity {
await this.bot.utils.wait(this.bot.utils.randomDelay(3000, 6000))
}
- this.bot.logger.warn(
- this.bot.isMobile,
- 'VISUAL-SEARCH',
- `尝试 ${MAX_ATTEMPTS} 次后每日视觉搜索仍未记分`
- )
+ this.bot.logger.warn(this.bot.isMobile, 'VISUAL-SEARCH', `尝试 ${MAX_ATTEMPTS} 次后每日视觉搜索仍未记分`)
return 0
}
diff --git a/src/functions/activities/visualSearch/VisualSearchBrowser.ts b/src/functions/activities/visualSearch/VisualSearchBrowser.ts
index dc21897..6943f1d 100644
--- a/src/functions/activities/visualSearch/VisualSearchBrowser.ts
+++ b/src/functions/activities/visualSearch/VisualSearchBrowser.ts
@@ -113,11 +113,7 @@ export class VisualSearchBrowser {
try {
const page = this.bot.mainDesktopPage
if (!page || page.isClosed()) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'VISUAL-SEARCH-BCID',
- '桌面端页面不可用 - 无法获取视觉搜索'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'VISUAL-SEARCH-BCID', '桌面端页面不可用 - 无法获取视觉搜索')
return null
}
@@ -191,11 +187,7 @@ export class VisualSearchBrowser {
public async getSeedUrls(): Promise {
const page = this.bot.mainDesktopPage
if (!page || page.isClosed()) {
- this.bot.logger.warn(
- this.bot.isMobile,
- 'VISUAL-SEARCH-BCID',
- '桌面端页面不可用 - 使用静态视觉搜索种子'
- )
+ this.bot.logger.warn(this.bot.isMobile, 'VISUAL-SEARCH-BCID', '桌面端页面不可用 - 使用静态视觉搜索种子')
return [STATIC_SEED_URL]
}
diff --git a/src/index.ts b/src/index.ts
index 494496e..a4b3274 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -177,20 +177,12 @@ export class MicrosoftRewardsBot {
let refreshSucceeded = false
if (!account?.email) {
- this.logger.debug(
- this.isMobile,
- 'CONTEXT-REFRESH',
- `无法刷新奖励上下文 | 原因=${reason} | 账户=不可用`
- )
+ this.logger.debug(this.isMobile, 'CONTEXT-REFRESH', `无法刷新奖励上下文 | 原因=${reason} | 账户=不可用`)
return false
}
try {
- this.logger.warn(
- this.isMobile,
- 'CONTEXT-REFRESH',
- `请求失败后正在刷新奖励浏览器上下文 | 原因=${reason}`
- )
+ this.logger.warn(this.isMobile, 'CONTEXT-REFRESH', `请求失败后正在刷新奖励浏览器上下文 | 原因=${reason}`)
if (!page || page.isClosed()) {
recoverySession = await this.browserFactory.createBrowser(account)
@@ -595,9 +587,10 @@ export class MicrosoftRewardsBot {
)
}
} else {
- const errorDetail = flowError && flowError !== 'undefined'
- ? flowError.replace(/\r?\n/g, ' ').slice(0, 120)
- : '流程失败(未捕获到错误详情)'
+ const errorDetail =
+ flowError && flowError !== 'undefined'
+ ? flowError.replace(/\r?\n/g, ' ').slice(0, 120)
+ : '流程失败(未捕获到错误详情)'
accountStats.push({
email: accountEmail,
@@ -674,9 +667,7 @@ export class MicrosoftRewardsBot {
this.logger.info(
'main',
'ACCOUNT-DELAY',
- `等待 ${(delayMs / 1000).toFixed(1)} 秒后开始下一个账户${
- nextEmail ? ` (${nextEmail})` : ''
- }`
+ `等待 ${(delayMs / 1000).toFixed(1)} 秒后开始下一个账户${nextEmail ? ` (${nextEmail})` : ''}`
)
await this.utils.wait(delayMs)
}
@@ -785,11 +776,7 @@ export class MicrosoftRewardsBot {
desktopSession = await this.createDesktopSession(account)
})
await closeDesktopSession()
- this.logger.info(
- 'main',
- 'FLOW',
- '桌面会话预热完成 | 后续桌面阶段将直接复用已保存会话'
- )
+ this.logger.info('main', 'FLOW', '桌面会话预热完成 | 后续桌面阶段将直接复用已保存会话')
} catch (error) {
this.logger.warn(
'main',
@@ -803,11 +790,7 @@ export class MicrosoftRewardsBot {
if (fullApi) {
await closeMobileSession()
- this.logger.info(
- 'main',
- 'FLOW',
- '移动端登录浏览器已关闭;继续使用已保存的会话和 HTTP 请求'
- )
+ this.logger.info('main', 'FLOW', '移动端登录浏览器已关闭;继续使用已保存的会话和 HTTP 请求')
}
const data: DashboardData = await this.browser.func.getDashboardData()
@@ -926,9 +909,7 @@ export class MicrosoftRewardsBot {
this.logger.error(
this.isMobile,
'EDGE-BROWSING',
- `意外的后台任务失败 | 信息=${
- error instanceof Error ? error.message : String(error)
- }`
+ `意外的后台任务失败 | 信息=${error instanceof Error ? error.message : String(error)}`
)
})
.finally(() => {
@@ -1104,11 +1085,7 @@ export class MicrosoftRewardsBot {
if (edgeBrowsingTask) {
if (!edgeBrowsingFinished) {
- this.logger.info(
- this.isMobile,
- 'EDGE-BROWSING',
- '前台活动已完成;正在等待后台 Edge 浏览活动'
- )
+ this.logger.info(this.isMobile, 'EDGE-BROWSING', '前台活动已完成;正在等待后台 Edge 浏览活动')
}
await edgeBrowsingTask
edgeBrowsingTask = null
diff --git a/src/logging/ClawBot.ts b/src/logging/ClawBot.ts
index 067149d..e5e754f 100644
--- a/src/logging/ClawBot.ts
+++ b/src/logging/ClawBot.ts
@@ -37,7 +37,9 @@ export async function sendClawBot(config: WebhookClawBotConfig, content: string)
// context_token 缺失或失效(ret=-2):清除后等待下次启动时重新激活
auth.contextToken = undefined
saveClawBotAuth(auth, config.authFile)
- console.warn('[ClawBot] 推送上下文失效,本次跳过;下次运行时请在微信给「微信 ClawBot」发一条消息完成激活')
+ console.warn(
+ '[ClawBot] 推送上下文失效,本次跳过;下次运行时请在微信给「微信 ClawBot」发一条消息完成激活'
+ )
} else if (result === 'error') {
console.warn('[ClawBot] 发送失败,已跳过(不影响任务运行)')
}
diff --git a/src/util/ClawBotClient.ts b/src/util/ClawBotClient.ts
index e93007d..3f8ec96 100644
--- a/src/util/ClawBotClient.ts
+++ b/src/util/ClawBotClient.ts
@@ -47,7 +47,8 @@ export function loadClawBotAuth(customPath?: string): ClawBotAuth | null {
accountId: typeof raw.accountId === 'string' ? raw.accountId : '',
userId: raw.userId,
contextToken: typeof raw.contextToken === 'string' && raw.contextToken ? raw.contextToken : undefined,
- getUpdatesBuf: typeof raw.getUpdatesBuf === 'string' && raw.getUpdatesBuf ? raw.getUpdatesBuf : undefined,
+ getUpdatesBuf:
+ typeof raw.getUpdatesBuf === 'string' && raw.getUpdatesBuf ? raw.getUpdatesBuf : undefined,
savedAt: typeof raw.savedAt === 'string' ? raw.savedAt : new Date().toISOString()
}
}
@@ -99,11 +100,7 @@ async function iLinkPost(url: string, data: unknown, opts: { token?: string;
return response.data
}
-async function iLinkGet(
- url: string,
- params: Record,
- opts: { timeout?: number } = {}
-): Promise {
+async function iLinkGet(url: string, params: Record, opts: { timeout?: number } = {}): Promise {
const response = await httpRequest({
method: 'GET',
url,
@@ -221,7 +218,10 @@ export interface ClawBotLoginResult {
* 交互式扫码登录:终端展示二维码,等待手机微信确认。
* 总超时默认 5 分钟;期间处理数字配对码、二维码过期刷新与 IDC 重定向。
*/
-export async function loginClawBotInteractive(customAuthPath?: string, timeoutMs = DEFAULT_LOGIN_TIMEOUT_MS): Promise {
+export async function loginClawBotInteractive(
+ customAuthPath?: string,
+ timeoutMs = DEFAULT_LOGIN_TIMEOUT_MS
+): Promise {
const existing = loadClawBotAuth(customAuthPath)
const localTokenList = existing?.token ? [existing.token] : []
@@ -275,7 +275,9 @@ export async function loginClawBotInteractive(customAuthPath?: string, timeoutMs
}
break
case 'need_verifycode': {
- const prompt = pendingVerifyCode ? '❌ 数字不匹配,请重新输入手机微信显示的数字:' : '请输入手机微信上显示的数字以继续:'
+ const prompt = pendingVerifyCode
+ ? '❌ 数字不匹配,请重新输入手机微信显示的数字:'
+ : '请输入手机微信上显示的数字以继续:'
pendingVerifyCode = await readVerifyCodeFromStdin(prompt)
continue
}
diff --git a/src/util/Humanize.ts b/src/util/Humanize.ts
index c99e6f2..e1ca7f1 100644
--- a/src/util/Humanize.ts
+++ b/src/util/Humanize.ts
@@ -110,11 +110,7 @@ export async function waitForQuietHours(): Promise {
if (waitMs <= 0) return
const resumeAt = new Date(Date.now() + waitMs)
- bot?.logger.info(
- 'main',
- 'HUMANIZE',
- `当前处于静默时段,挂起到 ${formatClock(resumeAt)}(humanize.quietHours)`
- )
+ bot?.logger.info('main', 'HUMANIZE', `当前处于静默时段,挂起到 ${formatClock(resumeAt)}(humanize.quietHours)`)
await new Promise(resolve => setTimeout(resolve, waitMs))
}
}
From 4bafdfb2ef17e13b8c39a1ffb077b4420fe4a28c Mon Sep 17 00:00:00 2001
From: GoldenSection0618 <172290907+GoldenSection0618@users.noreply.github.com>
Date: Sat, 24 Oct 2026 05:38:56 +0000
Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E5=B0=86=E7=BC=BA=E5=A4=B1=E6=90=9C?=
=?UTF-8?q?=E7=B4=A2=E8=AE=A1=E6=95=B0=E4=BF=9D=E7=95=99=E4=B8=BA=E6=9C=AA?=
=?UTF-8?q?=E7=9F=A5=E5=B9=B6=E4=BF=AE=E6=AD=A3=E5=89=A9=E4=BD=99=E9=A2=9D?=
=?UTF-8?q?=E5=BA=A6=E4=B8=8E=E5=AE=8C=E6=88=90=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
scripts/api/rewardsPoints.fixture.cjs | 59 ++++++++++++
scripts/api/searchCounterState.test.cjs | 91 +++++++++++++++++++
src/browser/BrowserFunc.ts | 32 ++++---
.../activities/search/SearchManager.ts | 1 +
src/index.ts | 18 ++--
src/interface/Points.ts | 6 +-
6 files changed, 182 insertions(+), 25 deletions(-)
create mode 100644 scripts/api/rewardsPoints.fixture.cjs
create mode 100644 scripts/api/searchCounterState.test.cjs
diff --git a/scripts/api/rewardsPoints.fixture.cjs b/scripts/api/rewardsPoints.fixture.cjs
new file mode 100644
index 0000000..0906385
--- /dev/null
+++ b/scripts/api/rewardsPoints.fixture.cjs
@@ -0,0 +1,59 @@
+const { MicrosoftRewardsBot } = require('../../src/index.ts')
+
+function createBot(t) {
+ const bot = Object.create(MicrosoftRewardsBot.prototype)
+ const dashboard = {
+ dashboard: {
+ userStatus: { availablePoints: 100, counters: {} },
+ userProfile: { attributes: { country: 'CN' } },
+ dailySetPromotions: {},
+ morePromotions: [],
+ userWarnings: []
+ }
+ }
+ bot.userData = { currentPoints: 100, gainedPoints: 0, geoLocale: 'CN', langCode: 'zh-CN' }
+ bot.nextActions = {}
+ bot.accessToken = ''
+ bot.cookies = { mobile: [], desktop: [] }
+ bot.accountLocale = { country: 'CN' }
+ bot.config = {
+ workers: {},
+ experimental: { apiSearch: false, apiSearchOnBing: false, edgeBrowsing: false },
+ activities: { searchOnBing: false },
+ searchSettings: { parallelSearching: false }
+ }
+ bot.utils = { getFormattedDate: () => '2026-10-24', randomDelay: min => min, wait: t.mock.fn(async () => {}) }
+ bot.logger = Object.fromEntries(['info', 'warn', 'error', 'debug'].map(level => [level, t.mock.fn()]))
+ bot.http = {
+ request: t.mock.fn(async () => {
+ throw new Error('Unexpected HTTP request')
+ }),
+ setDefaultHeaders: () => {}
+ }
+ bot.login = { login: async () => {}, getAppAccessToken: async () => 'test-token' }
+ bot.browserFactory = {
+ createBrowser: async () => ({
+ context: {
+ newPage: async () => ({}),
+ cookies: async () => []
+ },
+ fingerprint: {}
+ })
+ }
+ bot.browser = {
+ func: {
+ getDashboardData: async () => dashboard,
+ getAppDashboardData: async () => ({ response: { promotions: [] } }),
+ getCurrentPoints: t.mock.fn(async () => 100),
+ checkpointActiveSession: async () => {},
+ closeBrowser: async () => {},
+ getBrowserEarnablePoints: async () => ({ desktopSearchPoints: 0, mobileSearchPoints: 0 }),
+ getAppEarnablePoints: async () => ({ totalEarnablePoints: 0 })
+ }
+ }
+ bot.searchManager = { getSearchPoints: async () => ({ doMobile: false, doDesktop: false }) }
+ bot.activities = { doDailyCheckIn: async () => {} }
+ return { bot, dashboard }
+}
+
+module.exports = { createBot, account: { email: 'test@example.invalid', geoLocale: 'CN', langCode: 'zh-CN' } }
diff --git a/scripts/api/searchCounterState.test.cjs b/scripts/api/searchCounterState.test.cjs
new file mode 100644
index 0000000..a770921
--- /dev/null
+++ b/scripts/api/searchCounterState.test.cjs
@@ -0,0 +1,91 @@
+const assert = require('node:assert/strict')
+const test = require('node:test')
+require('../../node_modules/ts-node/register/transpile-only.js')
+const BrowserFunc = require('../../src/browser/BrowserFunc.ts').default
+const { SearchManager } = require('../../src/functions/activities/search/SearchManager.ts')
+const { mapFlyoutToDashboard } = require('../../src/browser/FlyoutDashboard.ts')
+const { createBot, account } = require('./rewardsPoints.fixture.cjs')
+
+for (const [name, counters, desktop, mobile] of [
+ ['missing mobile counter', { pcSearch: [{ pointProgress: 60, pointProgressMax: 60 }] }, 0, null],
+ ['empty counters', { pcSearch: [], mobileSearch: [] }, null, null],
+ [
+ 'explicit zero quota',
+ {
+ pcSearch: [{ pointProgress: 50, pointProgressMax: 60 }],
+ mobileSearch: [{ pointProgress: 0, pointProgressMax: 0 }]
+ },
+ 10,
+ 0
+ ],
+ ['invalid progress', { pcSearch: [{ pointProgress: NaN, pointProgressMax: 60 }] }, null, null],
+ ['invalid maximum', { pcSearch: [{ pointProgress: 5, pointProgressMax: NaN }] }, null, null],
+ ['over-completed counter', { pcSearch: [{ pointProgress: 65, pointProgressMax: 60 }] }, 0, null],
+ [
+ 'partial counters on both platforms',
+ {
+ pcSearch: [{ pointProgress: 10, pointProgressMax: 60 }],
+ mobileSearch: [{ pointProgress: 5, pointProgressMax: 30 }]
+ },
+ 50,
+ 25
+ ]
+]) {
+ test(`${name} preserves the distinction between unknown and zero remaining points`, async t => {
+ const { bot, dashboard } = createBot(t)
+ dashboard.dashboard.userStatus.counters = counters
+ const points = await new BrowserFunc(bot).getBrowserEarnablePoints(dashboard)
+ assert.equal(points.desktopSearchPoints, desktop)
+ assert.equal(points.mobileSearchPoints, mobile)
+ assert.equal(points.totalEarnablePoints, desktop === null || mobile === null ? null : desktop + mobile)
+ assert.equal(bot.http.request.mock.callCount(), 0)
+ })
+}
+
+test('a partial flyout response does not make a missing mobile counter complete', async t => {
+ const { bot } = createBot(t)
+ const data = mapFlyoutToDashboard({
+ userInfo: { isRewardsUser: true, balance: 100, profile: { attributes: { country: 'CN' } } },
+ flyoutResult: {
+ userStatus: {
+ isRewardsUser: true,
+ availablePoints: 100,
+ counters: { PCSearch: [{ pointProgress: 60, pointProgressMax: 60 }] }
+ }
+ }
+ })
+ const points = await new BrowserFunc(bot).getBrowserEarnablePoints(data)
+ assert.equal(points.desktopSearchPoints, 0)
+ assert.equal(points.mobileSearchPoints, null)
+})
+
+test('search planning describes an absent quota separately from a completed quota', async t => {
+ const { bot, dashboard } = createBot(t)
+ bot.config.workers.doMobileSearch = true
+ bot.config.workers.doDesktopSearch = true
+ dashboard.dashboard.userStatus.counters = {
+ pcSearch: [{ pointProgress: 60, pointProgressMax: 60 }],
+ mobileSearch: []
+ }
+ const plan = await new SearchManager(bot).getSearchPoints()
+ assert.equal(plan.doMobile, false)
+ assert.equal(plan.doDesktop, false)
+ const message = bot.logger.info.mock.calls.at(-1).arguments[2]
+ assert.match(message, /移动端: skip \(quota not provided\)/)
+ assert.match(message, /桌面端: skip \(complete, 60\/60\)/)
+})
+
+for (const desktopAvailable of [true, false]) {
+ test(`Main logs ${desktopAvailable ? 'confirmed desktop completion' : 'missing desktop data'} accurately`, async t => {
+ const { bot } = createBot(t)
+ bot.browser.func.getBrowserEarnablePoints = async () => ({
+ desktopSearchPoints: desktopAvailable ? 0 : null,
+ mobileSearchPoints: null
+ })
+ await bot.Main(account)
+ const message = bot.logger.info.mock.calls.find(call => call.arguments[1] === 'POINTS').arguments[2]
+ assert.match(message, /移动端: 未提供/)
+ assert.ok(message.includes(`浏览器: ${desktopAvailable ? '0' : '未提供'}`))
+ assert.equal(bot.http.request.mock.callCount(), 0)
+ })
+}
diff --git a/src/browser/BrowserFunc.ts b/src/browser/BrowserFunc.ts
index 6c202b9..a617c8c 100644
--- a/src/browser/BrowserFunc.ts
+++ b/src/browser/BrowserFunc.ts
@@ -177,19 +177,20 @@ export default class BrowserFunc {
try {
data ??= await this.getDashboardData()
- const desktopSearchPoints =
- data.dashboard.userStatus.counters.pcSearch?.reduce(
- (sum: number, x: { pointProgressMax: number; pointProgress: number }) =>
- sum + (x.pointProgressMax - x.pointProgress),
- 0
- ) ?? 0
-
- const mobileSearchPoints =
- data.dashboard.userStatus.counters.mobileSearch?.reduce(
- (sum: number, x: { pointProgressMax: number; pointProgress: number }) =>
- sum + (x.pointProgressMax - x.pointProgress),
- 0
- ) ?? 0
+ const remaining = (
+ counters: { pointProgressMax: number; pointProgress: number }[] | undefined
+ ): number | null => {
+ if (!counters?.length) return null
+ if (
+ counters.some(
+ item => !Number.isFinite(item.pointProgressMax) || !Number.isFinite(item.pointProgress)
+ )
+ )
+ return null
+ return counters.reduce((sum, item) => sum + Math.max(0, item.pointProgressMax - item.pointProgress), 0)
+ }
+ const desktopSearchPoints = remaining(data.dashboard.userStatus.counters.pcSearch)
+ const mobileSearchPoints = remaining(data.dashboard.userStatus.counters.mobileSearch)
const todayDate = this.bot.utils.getFormattedDate()
const dailySetPoints =
@@ -207,7 +208,10 @@ export default class BrowserFunc {
return sum
}, 0) ?? 0
- const totalEarnablePoints = desktopSearchPoints + mobileSearchPoints + dailySetPoints + morePromotionsPoints
+ const totalEarnablePoints =
+ desktopSearchPoints === null || mobileSearchPoints === null
+ ? null
+ : desktopSearchPoints + mobileSearchPoints + dailySetPoints + morePromotionsPoints
return {
dailySetPoints,
diff --git a/src/functions/activities/search/SearchManager.ts b/src/functions/activities/search/SearchManager.ts
index e35c001..30f8233 100644
--- a/src/functions/activities/search/SearchManager.ts
+++ b/src/functions/activities/search/SearchManager.ts
@@ -51,6 +51,7 @@ export class SearchManager {
private describeQuota(enabled: boolean, quota: SearchQuota): string {
if (!enabled) return `skip (disabled, ${quota.earned}/${quota.max})`
+ if (quota.max <= 0) return 'skip (quota not provided)'
if (quota.remaining <= 0) return `skip (complete, ${quota.earned}/${quota.max})`
return `run (${quota.earned}/${quota.max}, missing ${quota.remaining})`
}
diff --git a/src/index.ts b/src/index.ts
index a4b3274..0fd26f0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -889,8 +889,8 @@ export class MicrosoftRewardsBot {
this.logger.info(
'main',
'POINTS',
- `今日可赚取 | 移动端: ${browserEarnable.mobileSearchPoints} | 浏览器: ${
- browserEarnable.desktopSearchPoints
+ `今日可赚取 | 移动端: ${browserEarnable.mobileSearchPoints ?? '未提供'} | 浏览器: ${
+ browserEarnable.desktopSearchPoints ?? '未提供'
} | App: ${appEarnable?.totalEarnablePoints ?? 0} | ${accountEmail} | locale: ${this.accountLocale.locale}`
)
@@ -1195,9 +1195,11 @@ async function main(): Promise {
}
}
-main().catch(async error => {
- const tmpBot = new MicrosoftRewardsBot()
- tmpBot.logger.error('main', 'MAIN-ERROR', error as Error)
- await flushAllWebhooks()
- process.exit(1)
-})
+if (require.main === module) {
+ main().catch(async error => {
+ const tmpBot = new MicrosoftRewardsBot()
+ tmpBot.logger.error('main', 'MAIN-ERROR', error as Error)
+ await flushAllWebhooks()
+ process.exit(1)
+ })
+}
diff --git a/src/interface/Points.ts b/src/interface/Points.ts
index e502056..621ad47 100644
--- a/src/interface/Points.ts
+++ b/src/interface/Points.ts
@@ -1,9 +1,9 @@
export interface BrowserEarnablePoints {
- desktopSearchPoints: number
- mobileSearchPoints: number
+ desktopSearchPoints: number | null
+ mobileSearchPoints: number | null
dailySetPoints: number
morePromotionsPoints: number
- totalEarnablePoints: number
+ totalEarnablePoints: number | null
}
export interface AppEarnablePoints {
From 732f40bac5ed8fa3b6134ab893a838d360ed4b0f Mon Sep 17 00:00:00 2001
From: GoldenSection0618 <172290907+GoldenSection0618@users.noreply.github.com>
Date: Sat, 24 Oct 2026 16:21:53 +0800
Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E9=A2=9D=E5=BA=A6?=
=?UTF-8?q?=E6=9C=89=E6=95=88=E6=80=A7=E5=88=A4=E6=96=AD=E4=BB=A5=E5=8C=BA?=
=?UTF-8?q?=E5=88=86=E7=9C=9F=E5=AE=9E=E9=9B=B6=E9=A2=9D=E5=BA=A6=E4=B8=8E?=
=?UTF-8?q?=E6=9C=AA=E7=9F=A5=E8=BF=9B=E5=BA=A6=E5=B9=B6=E5=90=8C=E6=AD=A5?=
=?UTF-8?q?=E6=97=A5=E5=BF=97=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
scripts/api/logParser.js | 8 ++-
scripts/api/searchCounterState.test.cjs | 72 +++++++++++++++++++
src/browser/BrowserFunc.ts | 21 ++----
.../activities/search/SearchManager.ts | 19 ++---
.../activities/search/SearchProgress.ts | 19 +++--
5 files changed, 103 insertions(+), 36 deletions(-)
diff --git a/scripts/api/logParser.js b/scripts/api/logParser.js
index 8b8c392..55c8992 100644
--- a/scripts/api/logParser.js
+++ b/scripts/api/logParser.js
@@ -101,7 +101,8 @@ function ensureAccount(state, email) {
const RE = {
runStart: /^启动微软奖励脚本 \| v(\S+) \| 账户数: (\d+) \| 集群数: (\d+)/,
accountStart: /^开始处理账户: (\S+) \| geoLocale: ([^|]+?)(?: \| locale: (\S+))?(?: \| 缓存区域: (\S+))?\s*$/,
- earnable: /^今日可赚取 \| 移动端: (\d+) \| 浏览器: (\d+) \| App: (\d+) \| (\S+) \| locale: (\S+)\s*$/,
+ earnable:
+ /^今日可赚取 \| 移动端: (\d+|未提供|未知) \| 浏览器: (\d+|未提供|未知) \| App: (\d+|未提供|未知) \| (\S+) \| locale: (\S+)\s*$/,
searchSummary: /^搜索汇总 \| 移动端=(-?\d+) \| 桌面端=(-?\d+) \| 额外=(-?\d+) \| 总计=(-?\d+)/,
streakProtection:
/^快照完成 \| offers=(\d+) \| 可上报=(\d+) \| streaks=(\d+) \| 连续保护已启用=(true|false|null) \| 连续保护剩余天数=(\d+|null) \| 连续计数=(\d+|null) \| 等级=([^|]+) \| 账户=(\S+@\S+)$/,
@@ -414,7 +415,10 @@ export function applyLogToRunState(state, entry) {
const email = m[4]
const acc = ensureAccount(state, email)
if (acc) {
- acc.earnable = { mobile: Number(m[1]), browser: Number(m[2]), app: Number(m[3]) }
+ const [mobile, browser, app] = m
+ .slice(1, 4)
+ .map(value => (/^\d+$/.test(value) ? Number(value) : null))
+ acc.earnable = { mobile, browser, app }
acc.locale ??= m[5]
}
state.currentEmail = email
diff --git a/scripts/api/searchCounterState.test.cjs b/scripts/api/searchCounterState.test.cjs
index a770921..8ac9298 100644
--- a/scripts/api/searchCounterState.test.cjs
+++ b/scripts/api/searchCounterState.test.cjs
@@ -89,3 +89,75 @@ for (const desktopAvailable of [true, false]) {
assert.equal(bot.http.request.mock.callCount(), 0)
})
}
+
+test('an explicit zero allowance remains a confirmed quota in the search plan', async t => {
+ const { bot, dashboard } = createBot(t)
+ bot.config.workers = { doMobileSearch: true, doDesktopSearch: true }
+ dashboard.dashboard.userStatus.counters = {
+ pcSearch: [{ pointProgress: 0, pointProgressMax: 0 }],
+ mobileSearch: [{ pointProgress: 0, pointProgressMax: 0 }]
+ }
+ const points = await new BrowserFunc(bot).getBrowserEarnablePoints(dashboard)
+ const plan = await new SearchManager(bot).getSearchPoints()
+ const message = bot.logger.info.mock.calls.at(-1).arguments[2]
+ assert.equal(points.desktopSearchPoints, 0)
+ assert.equal(points.mobileSearchPoints, 0)
+ assert.equal(plan.doDesktop, false)
+ assert.equal(plan.doMobile, false)
+ assert.doesNotMatch(message, /quota not provided/)
+ assert.match(message, /complete, 0\/0/)
+})
+
+test('invalid search progress stays unknown in both display and planning', async t => {
+ const { bot, dashboard } = createBot(t)
+ bot.config.workers = { doDesktopSearch: true }
+ dashboard.dashboard.userStatus.counters = {
+ pcSearch: [{ pointProgress: NaN, pointProgressMax: 60 }]
+ }
+ const points = await new BrowserFunc(bot).getBrowserEarnablePoints(dashboard)
+ const plan = await new SearchManager(bot).getSearchPoints()
+ assert.equal(points.desktopSearchPoints, null)
+ assert.equal(plan.doDesktop, false)
+ assert.equal(plan.desktopMissing, 0)
+ assert.match(bot.logger.info.mock.calls.at(-1).arguments[2], /quota not provided/)
+})
+
+test('valid desktop and Edge counters retain their combined remaining allowance', async t => {
+ const { bot, dashboard } = createBot(t)
+ bot.config.workers = { doMobileSearch: true, doDesktopSearch: true }
+ dashboard.dashboard.userStatus.counters = {
+ pcSearch: [
+ { pointProgress: 10, pointProgressMax: 60 },
+ { pointProgress: 0, pointProgressMax: 20, name: 'daily_edge_bonus' }
+ ],
+ mobileSearch: [{ pointProgress: 20, pointProgressMax: 30 }]
+ }
+ const points = await new BrowserFunc(bot).getBrowserEarnablePoints(dashboard)
+ const plan = await new SearchManager(bot).getSearchPoints()
+ assert.equal(points.desktopSearchPoints, 70)
+ assert.equal(points.mobileSearchPoints, 10)
+ assert.equal(plan.desktopMissing, 70)
+ assert.equal(plan.mobileMissing, 10)
+ assert.equal(plan.doDesktop, true)
+ assert.equal(plan.doMobile, true)
+})
+
+for (const [mobile, browser, expected] of [
+ ['未提供', '0', { mobile: null, browser: 0, app: 0 }],
+ ['0', '未提供', { mobile: 0, browser: null, app: 0 }],
+ ['0', '0', { mobile: 0, browser: 0, app: 0 }]
+]) {
+ test('log parser retains known and unknown browser quotas: ' + mobile + '/' + browser, async () => {
+ const { createRunState, parseLogLine, applyLogToRunState, summarizeRunState } = await import('./logParser.js')
+ const state = createRunState()
+ const entry = parseLogLine(
+ '[2026/10/24 13:00:00] [test] [INFO] MAIN [POINTS] 今日可赚取 | 移动端: ' +
+ mobile +
+ ' | 浏览器: ' +
+ browser +
+ ' | App: 0 | test@example.invalid | locale: zh-CN'
+ )
+ applyLogToRunState(state, entry)
+ assert.deepEqual(summarizeRunState(state).accounts[0]?.earnable, expected)
+ })
+}
diff --git a/src/browser/BrowserFunc.ts b/src/browser/BrowserFunc.ts
index a617c8c..5e7feb6 100644
--- a/src/browser/BrowserFunc.ts
+++ b/src/browser/BrowserFunc.ts
@@ -1,3 +1,4 @@
+import { SearchProgress } from '../functions/activities/search/SearchProgress'
import { URLs } from '../constants/urls'
import { BING_APP_USER_AGENT } from '../constants/userAgents'
import type { BrowserContext, Cookie, Page } from 'patchright'
@@ -177,20 +178,12 @@ export default class BrowserFunc {
try {
data ??= await this.getDashboardData()
- const remaining = (
- counters: { pointProgressMax: number; pointProgress: number }[] | undefined
- ): number | null => {
- if (!counters?.length) return null
- if (
- counters.some(
- item => !Number.isFinite(item.pointProgressMax) || !Number.isFinite(item.pointProgress)
- )
- )
- return null
- return counters.reduce((sum, item) => sum + Math.max(0, item.pointProgressMax - item.pointProgress), 0)
- }
- const desktopSearchPoints = remaining(data.dashboard.userStatus.counters.pcSearch)
- const mobileSearchPoints = remaining(data.dashboard.userStatus.counters.mobileSearch)
+ const progress = new SearchProgress(this.bot)
+ const counters = data.dashboard.userStatus.counters
+ const desktop = progress.calculateQuota(counters.pcSearch)
+ const mobile = progress.calculateQuota(counters.mobileSearch)
+ const desktopSearchPoints = desktop.known ? desktop.remaining : null
+ const mobileSearchPoints = mobile.known ? mobile.remaining : null
const todayDate = this.bot.utils.getFormattedDate()
const dailySetPoints =
diff --git a/src/functions/activities/search/SearchManager.ts b/src/functions/activities/search/SearchManager.ts
index 30f8233..168ca04 100644
--- a/src/functions/activities/search/SearchManager.ts
+++ b/src/functions/activities/search/SearchManager.ts
@@ -21,11 +21,11 @@ export class SearchManager {
const counters = await this.progress.getCounters()
const quotas = this.progress.calculateQuotas(counters)
const mobileMissing = quotas.mobile.remaining
- const desktopQuota = this.combineQuotas(quotas.desktop, quotas.edge)
+ const desktopQuota = this.progress.calculateQuota(counters.pcSearch)
const desktopMissing = desktopQuota.remaining
- const doMobile = this.bot.config.workers.doMobileSearch && mobileMissing > 0
- const doDesktop = this.bot.config.workers.doDesktopSearch && desktopMissing > 0
+ const doMobile = this.bot.config.workers.doMobileSearch && quotas.mobile.known && mobileMissing > 0
+ const doDesktop = this.bot.config.workers.doDesktopSearch && desktopQuota.known && desktopMissing > 0
this.bot.logger.info(
'main',
@@ -38,20 +38,9 @@ export class SearchManager {
return { doMobile, doDesktop, mobileMissing, desktopMissing }
}
- private combineQuotas(...quotas: SearchQuota[]): SearchQuota {
- return quotas.reduce(
- (total, quota) => ({
- earned: total.earned + quota.earned,
- max: total.max + quota.max,
- remaining: total.remaining + quota.remaining
- }),
- { earned: 0, max: 0, remaining: 0 }
- )
- }
-
private describeQuota(enabled: boolean, quota: SearchQuota): string {
if (!enabled) return `skip (disabled, ${quota.earned}/${quota.max})`
- if (quota.max <= 0) return 'skip (quota not provided)'
+ if (!quota.known) return 'skip (quota not provided)'
if (quota.remaining <= 0) return `skip (complete, ${quota.earned}/${quota.max})`
return `run (${quota.earned}/${quota.max}, missing ${quota.remaining})`
}
diff --git a/src/functions/activities/search/SearchProgress.ts b/src/functions/activities/search/SearchProgress.ts
index af3ec33..fa59501 100644
--- a/src/functions/activities/search/SearchProgress.ts
+++ b/src/functions/activities/search/SearchProgress.ts
@@ -3,6 +3,7 @@ import type { Counters, DashboardImpression } from '../../../interface/Dashboard
import type { MissingSearchPoints } from '../../../interface/Points'
export interface SearchQuota {
+ known: boolean
earned: number
max: number
remaining: number
@@ -48,13 +49,21 @@ export class SearchProgress {
: pcCounters
return {
- mobile: this.summarize(counters.mobileSearch ?? []),
- desktop: this.summarize(desktopCounters),
- edge: this.summarize(explicitEdgeCounters)
+ mobile: this.calculateQuota(counters.mobileSearch ?? []),
+ desktop: this.calculateQuota(desktopCounters),
+ edge: this.calculateQuota(explicitEdgeCounters)
}
}
- private summarize(counters: DashboardImpression[]): SearchQuota {
+ public calculateQuota(counters: DashboardImpression[] | undefined): SearchQuota {
+ if (
+ !counters?.length ||
+ counters.some(
+ counter => !Number.isFinite(counter.pointProgressMax) || !Number.isFinite(counter.pointProgress)
+ )
+ ) {
+ return { known: false, earned: 0, max: 0, remaining: 0 }
+ }
return counters.reduce(
(quota, counter) => {
const max = Math.max(0, Number(counter.pointProgressMax) || 0)
@@ -64,7 +73,7 @@ export class SearchProgress {
quota.remaining += max - earned
return quota
},
- { earned: 0, max: 0, remaining: 0 }
+ { known: true, earned: 0, max: 0, remaining: 0 }
)
}