diff --git a/README.md b/README.md index 8662040..63ab01f 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ 当前版本基于侧边栏控制,支持单步执行、整套自动执行、停止当前流程、保存常用配置,以及通过 DuckDuckGo / QQ / 163 / Inbucket / Hotmail 协助获取验证码。 -## 最新版本测试结果 +## 插件效果 -最新版本实测了一个 5 轮自动,0 次失重试;睡前挂了一个十轮自动,1次重试: +一百五十个号,一个401:
- 最新版本五轮测试结果 + QQ交流群,便于大家交流 最新版本运行日志 @@ -326,7 +326,7 @@ Cloudflare 模式下,插件不会再调用 Cloudflare API 创建路由。 `延迟` 里的“启动前倒计时”只控制整轮 Auto 开始前要不要先倒计时多少分钟。 -`步间随机` 控制 Auto 流程里**每一步真正执行前**的随机等待秒数,默认是 `12 ~ 18` 秒。这个设置只影响 Auto,不影响你手动单步点击执行。 +`步间随机` 控制 Auto 流程里**每一步真正执行前**的额外等待秒数。这个设置只影响 Auto,不影响你手动单步点击执行;填 `0` 或留空表示不延迟。 如果当前面板里已经存在未完成进度,点击 `Auto` 时会弹出选择: @@ -370,7 +370,7 @@ Cloudflare 模式下,插件不会再调用 Cloudflare API 创建路由。 - Auto 的暂停状态会保存在会话状态中,重新打开侧边栏后仍可继续 - 如果你在 Auto 暂停时改为手动点步骤或跳过步骤,面板会先确认并停止 Auto,再切回手动控制 - 选择 `继续当前` 时,后台不会先做大而全的前置校验,而是从当前步骤状态直接继续;缺什么条件,就在运行到那一步时再报错或暂停 -- 除了现有的页面切换等待外,Auto 还会在每一步执行前额外随机等待一段时间;默认是 `12 ~ 18` 秒,可在侧边栏 `步间随机` 中改成你自己的范围 +- 除了现有的页面切换等待外,Auto 还会在每一步执行前按 `步间随机` 的秒数额外等待;填 `0` 或留空表示不延迟 ## 详细步骤说明 diff --git a/background.js b/background.js index 3621c99..d9b0ac9 100644 --- a/background.js +++ b/background.js @@ -39,10 +39,9 @@ const DEFAULT_SUB2API_REDIRECT_URI = 'http://localhost:1455/auth/callback'; const AUTO_RUN_ALARM_NAME = 'scheduled-auto-run'; const AUTO_RUN_DELAY_MIN_MINUTES = 1; const AUTO_RUN_DELAY_MAX_MINUTES = 1440; -const AUTO_STEP_RANDOM_DELAY_MIN_ALLOWED_SECONDS = 0; -const AUTO_STEP_RANDOM_DELAY_MAX_ALLOWED_SECONDS = 600; -const AUTO_STEP_RANDOM_DELAY_DEFAULT_MIN_SECONDS = 12; -const AUTO_STEP_RANDOM_DELAY_DEFAULT_MAX_SECONDS = 18; +const AUTO_STEP_DELAY_MIN_ALLOWED_SECONDS = 0; +const AUTO_STEP_DELAY_MAX_ALLOWED_SECONDS = 600; +const LEGACY_AUTO_STEP_DELAY_KEYS = ['autoStepRandomDelayMinSeconds', 'autoStepRandomDelayMaxSeconds']; const DEFAULT_LOCAL_CPA_STEP9_MODE = 'submit'; initializeSessionStorageAccess(); @@ -64,8 +63,7 @@ const PERSISTED_SETTING_DEFAULTS = { autoRunSkipFailures: false, // 自动运行遇到失败步骤后,是否继续执行后续流程。 autoRunDelayEnabled: false, // 自动运行是否启用启动前倒计时。 autoRunDelayMinutes: 30, // 自动运行倒计时分钟数。 - autoStepRandomDelayMinSeconds: AUTO_STEP_RANDOM_DELAY_DEFAULT_MIN_SECONDS, // 自动运行每一步执行前的最小随机等待秒数。 - autoStepRandomDelayMaxSeconds: AUTO_STEP_RANDOM_DELAY_DEFAULT_MAX_SECONDS, // 自动运行每一步执行前的最大随机等待秒数。 + autoStepDelaySeconds: null, // 自动运行每一步执行前的额外等待秒数;0 或空表示不延迟。 mailProvider: '163', // 验证码邮箱来源(163 / 163-vip / qq / inbucket)。 emailGenerator: 'duck', // 注册邮箱生成方式:duck / cloudflare。 inbucketHost: '', // 仅当 mailProvider 为 inbucket 时填写 Inbucket 地址,其他情况保持为空。 @@ -125,30 +123,42 @@ function normalizeAutoRunDelayMinutes(value) { ); } -function normalizeAutoStepRandomDelaySeconds(value, fallback = AUTO_STEP_RANDOM_DELAY_DEFAULT_MIN_SECONDS) { - const numeric = Number(value); +function normalizeAutoStepDelaySeconds(value, fallback = null) { + const rawValue = String(value ?? '').trim(); + if (!rawValue) { + return fallback; + } + + const numeric = Number(rawValue); if (!Number.isFinite(numeric)) { return fallback; } + return Math.min( - AUTO_STEP_RANDOM_DELAY_MAX_ALLOWED_SECONDS, - Math.max(AUTO_STEP_RANDOM_DELAY_MIN_ALLOWED_SECONDS, Math.floor(numeric)) + AUTO_STEP_DELAY_MAX_ALLOWED_SECONDS, + Math.max(AUTO_STEP_DELAY_MIN_ALLOWED_SECONDS, Math.floor(numeric)) ); } -function normalizeAutoStepRandomDelayRange(settings = {}) { - const minSeconds = normalizeAutoStepRandomDelaySeconds( - settings.autoStepRandomDelayMinSeconds, - PERSISTED_SETTING_DEFAULTS.autoStepRandomDelayMinSeconds - ); - const maxSeconds = Math.max( - minSeconds, - normalizeAutoStepRandomDelaySeconds( - settings.autoStepRandomDelayMaxSeconds, - PERSISTED_SETTING_DEFAULTS.autoStepRandomDelayMaxSeconds - ) - ); - return { minSeconds, maxSeconds }; +function resolveLegacyAutoStepDelaySeconds(input = {}) { + const hasLegacyMin = input.autoStepRandomDelayMinSeconds !== undefined; + const hasLegacyMax = input.autoStepRandomDelayMaxSeconds !== undefined; + if (!hasLegacyMin && !hasLegacyMax) { + return undefined; + } + + const minSeconds = normalizeAutoStepDelaySeconds(input.autoStepRandomDelayMinSeconds, null); + const maxSeconds = normalizeAutoStepDelaySeconds(input.autoStepRandomDelayMaxSeconds, null); + if (minSeconds === null && maxSeconds === null) { + return null; + } + if (minSeconds === null) { + return maxSeconds; + } + if (maxSeconds === null) { + return minSeconds; + } + return Math.round((minSeconds + maxSeconds) / 2); } function normalizeRunCount(value) { @@ -248,16 +258,8 @@ function normalizePersistentSettingValue(key, value) { return Boolean(value); case 'autoRunDelayMinutes': return normalizeAutoRunDelayMinutes(value); - case 'autoStepRandomDelayMinSeconds': - return normalizeAutoStepRandomDelaySeconds( - value, - PERSISTED_SETTING_DEFAULTS.autoStepRandomDelayMinSeconds - ); - case 'autoStepRandomDelayMaxSeconds': - return normalizeAutoStepRandomDelaySeconds( - value, - PERSISTED_SETTING_DEFAULTS.autoStepRandomDelayMaxSeconds - ); + case 'autoStepDelaySeconds': + return normalizeAutoStepDelaySeconds(value, PERSISTED_SETTING_DEFAULTS.autoStepDelaySeconds); case 'mailProvider': return normalizeMailProvider(value); case 'emailGenerator': @@ -283,11 +285,19 @@ function buildPersistentSettingsPayload(input = {}, options = {}) { throw new Error('\u914d\u7f6e\u5185\u5bb9\u683c\u5f0f\u65e0\u6548\u3002'); } + const normalizedInput = { ...input }; + if (normalizedInput.autoStepDelaySeconds === undefined) { + const legacyAutoStepDelaySeconds = resolveLegacyAutoStepDelaySeconds(normalizedInput); + if (legacyAutoStepDelaySeconds !== undefined) { + normalizedInput.autoStepDelaySeconds = legacyAutoStepDelaySeconds; + } + } + const payload = {}; let matchedKeyCount = 0; for (const key of PERSISTED_SETTING_KEYS) { - if (input[key] !== undefined) { - payload[key] = normalizePersistentSettingValue(key, input[key]); + if (normalizedInput[key] !== undefined) { + payload[key] = normalizePersistentSettingValue(key, normalizedInput[key]); matchedKeyCount += 1; } else if (fillDefaults) { payload[key] = normalizePersistentSettingValue(key, PERSISTED_SETTING_DEFAULTS[key]); @@ -306,20 +316,11 @@ function buildPersistentSettingsPayload(input = {}, options = {}) { payload.cloudflareDomains = domains; } - if (payload.autoStepRandomDelayMinSeconds !== undefined || payload.autoStepRandomDelayMaxSeconds !== undefined) { - const normalizedDelayRange = normalizeAutoStepRandomDelayRange({ - autoStepRandomDelayMinSeconds: payload.autoStepRandomDelayMinSeconds, - autoStepRandomDelayMaxSeconds: payload.autoStepRandomDelayMaxSeconds, - }); - payload.autoStepRandomDelayMinSeconds = normalizedDelayRange.minSeconds; - payload.autoStepRandomDelayMaxSeconds = normalizedDelayRange.maxSeconds; - } - return payload; } async function getPersistedSettings() { - const stored = await chrome.storage.local.get(PERSISTED_SETTING_KEYS); + const stored = await chrome.storage.local.get([...PERSISTED_SETTING_KEYS, ...LEGACY_AUTO_STEP_DELAY_KEYS]); return buildPersistentSettingsPayload(stored, { fillDefaults: true }); } @@ -2473,12 +2474,6 @@ async function humanStepDelay(min = HUMAN_STEP_DELAY_MIN, max = HUMAN_STEP_DELAY await sleepWithStop(duration); } -function getAutoStepRandomDelayMs(min, max) { - const normalizedMin = Math.max(0, Math.floor(Number(min) || 0)); - const normalizedMax = Math.max(normalizedMin, Math.floor(Number(max) || normalizedMin)); - return Math.floor(Math.random() * (normalizedMax - normalizedMin + 1)) + normalizedMin; -} - async function clickWithDebugger(tabId, rect) { throwIfStopped(); if (!tabId) { @@ -3085,17 +3080,13 @@ async function executeStep(step) { async function executeStepAndWait(step, delayAfter = 2000) { throwIfStopped(); - const delaySettings = normalizeAutoStepRandomDelayRange(await getState()); - const randomDelayMs = getAutoStepRandomDelayMs( - delaySettings.minSeconds * 1000, - delaySettings.maxSeconds * 1000 - ); - if (randomDelayMs > 0) { + const delaySeconds = normalizeAutoStepDelaySeconds((await getState()).autoStepDelaySeconds, null); + if (delaySeconds > 0) { await addLog( - `自动运行:步骤 ${step} 执行前随机等待 ${delaySettings.minSeconds}-${delaySettings.maxSeconds} 秒,本次约 ${Math.round(randomDelayMs / 1000)} 秒,避免节奏过快。`, + `自动运行:步骤 ${step} 执行前额外等待 ${delaySeconds} 秒,避免节奏过快。`, 'info' ); - await sleepWithStop(randomDelayMs); + await sleepWithStop(delaySeconds * 1000); } if (AUTO_RUN_BACKGROUND_COMPLETED_STEPS.has(step)) { @@ -3446,8 +3437,7 @@ async function autoRunLoop(totalRuns, options = {}) { autoRunSkipFailures: prevState.autoRunSkipFailures, autoRunDelayEnabled: prevState.autoRunDelayEnabled, autoRunDelayMinutes: prevState.autoRunDelayMinutes, - autoStepRandomDelayMinSeconds: prevState.autoStepRandomDelayMinSeconds, - autoStepRandomDelayMaxSeconds: prevState.autoStepRandomDelayMaxSeconds, + autoStepDelaySeconds: prevState.autoStepDelaySeconds, mailProvider: prevState.mailProvider, emailGenerator: prevState.emailGenerator, inbucketHost: prevState.inbucketHost, diff --git a/docs/images/五轮结果.jpg b/docs/images/五轮结果.jpg deleted file mode 100644 index 2df81a8..0000000 Binary files a/docs/images/五轮结果.jpg and /dev/null differ diff --git a/docs/images/五轮自动.png b/docs/images/五轮自动.png deleted file mode 100644 index b2967cf..0000000 Binary files a/docs/images/五轮自动.png and /dev/null differ diff --git a/docs/images/交流群.jpg b/docs/images/交流群.jpg new file mode 100644 index 0000000..a82eefd Binary files /dev/null and b/docs/images/交流群.jpg differ diff --git a/manifest.json b/manifest.json index cfc31cc..a735209 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "多页面自动化", - "version": "6.4.0", + "version": "7.0.0", "description": "用于自动执行多步骤 OAuth 注册流程", "permissions": [ "sidePanel", diff --git a/sidepanel/sidepanel.css b/sidepanel/sidepanel.css index b627d9d..64e7c00 100644 --- a/sidepanel/sidepanel.css +++ b/sidepanel/sidepanel.css @@ -496,10 +496,10 @@ header { box-shadow: 0 0 0 1px var(--blue-glow); } -#btn-fetch-email, -#btn-save-settings { - padding-inline: 10px; +.data-inline-btn { flex-shrink: 0; + min-width: 56px; + justify-content: center; } .hotmail-card { @@ -724,10 +724,37 @@ header { .auto-delay-inline { justify-content: space-between; gap: 12px; + flex-wrap: nowrap; +} + +.auto-delay-side { + display: flex; + align-items: center; + gap: 12px; + flex: 0 1 auto; + min-width: 0; +} + +.auto-delay-side-right { + margin-left: auto; + justify-content: flex-end; } .auto-delay-check { - flex: 0 1 auto; + flex: 0 0 auto; + align-items: center; +} + +.auto-delay-check span { + white-space: nowrap; +} + +.auto-delay-caption { + font-size: 12px; + font-weight: 600; + color: var(--text-muted); + flex: 0 0 auto; + white-space: nowrap; } .auto-delay-controls { diff --git a/sidepanel/sidepanel.html b/sidepanel/sidepanel.html index c1f0e84..4d0363a 100644 --- a/sidepanel/sidepanel.html +++ b/sidepanel/sidepanel.html @@ -90,7 +90,8 @@
管理密钥
- +
@@ -104,7 +105,8 @@
- codex密码 + 账户密码
- + placeholder="codex密码,留空则自动生成" /> +
@@ -133,11 +134,11 @@ - +
@@ -153,7 +154,7 @@ - +
@@ -181,42 +182,39 @@
延迟
- -
- - 分钟 +
+ +
+ + 分钟 +
+
+
+ 步间间隔 +
+ + +
-
- 步间随机 -
-
- - ~ - - -
-
-
-
- OAuth - 等待中... -
-
- 回调 -
- 等待中... - -
+
+
+ OAuth + 等待中... +
+
+ 回调 +
+ 等待中... +
+