feat: 固定操作间延迟设置并更新相关文档和测试

This commit is contained in:
QLHazyCoder
2026-05-18 01:29:24 +08:00
parent 7564481868
commit e5dc675369
10 changed files with 79 additions and 152 deletions
+20 -35
View File
@@ -596,26 +596,6 @@
<button id="btn-fetch-email" class="btn btn-outline btn-sm data-inline-btn" type="button">获取</button>
</div>
</div>
<div class="data-row" id="row-step-execution-range">
<span class="data-label">执行范围</span>
<div class="data-inline setting-pair step-execution-range-setting">
<div class="setting-group setting-group-primary">
<label class="toggle-switch" for="input-step-execution-range-enabled" title="开启后,只执行指定起止步骤,范围外步骤禁用">
<input type="checkbox" id="input-step-execution-range-enabled" />
<span class="toggle-switch-track" aria-hidden="true">
<span class="toggle-switch-thumb"></span>
</span>
<span>启用</span>
</label>
</div>
<div class="setting-group setting-group-secondary step-range-controls">
<span class="setting-caption">步骤</span>
<input type="number" id="input-step-execution-range-from" class="data-input auto-delay-input step-range-input" value="1" min="1" step="1" title="允许执行的起始步骤" />
<span class="data-unit"></span>
<input type="number" id="input-step-execution-range-to" class="data-input auto-delay-input step-range-input" value="1" min="1" step="1" title="允许执行的结束步骤" />
</div>
</div>
</div>
<div class="data-row module-divider-start" id="row-auto-delay-settings">
<span class="data-label">第六步</span>
<div class="data-inline setting-pair auto-delay-setting-pair">
@@ -644,21 +624,6 @@
</div>
</div>
</div>
<div class="data-row" id="row-operation-delay-settings">
<span class="data-label">操作间延迟</span>
<div class="data-inline setting-pair operation-delay-setting-pair">
<div class="setting-group setting-group-primary operation-delay-setting">
<label class="toggle-switch" for="input-operation-delay-enabled" title="开启后,页面输入、选择、点击、提交、继续、授权操作完成后等待 2 秒">
<input type="checkbox" id="input-operation-delay-enabled" checked />
<span class="toggle-switch-track" aria-hidden="true">
<span class="toggle-switch-thumb"></span>
</span>
<span>启用</span>
</label>
<span class="setting-caption">页面输入、选择、点击、提交、继续、授权后等待 2 秒</span>
</div>
</div>
</div>
<div class="data-row">
<span class="data-label">自动重试</span>
<div class="data-inline setting-pair">
@@ -704,6 +669,26 @@
</div>
</div>
</div>
<div class="data-row" id="row-step-execution-range">
<span class="data-label">执行范围</span>
<div class="data-inline setting-pair step-execution-range-setting">
<div class="setting-group setting-group-primary">
<label class="toggle-switch" for="input-step-execution-range-enabled" title="开启后,只执行指定起止步骤,范围外步骤禁用">
<input type="checkbox" id="input-step-execution-range-enabled" />
<span class="toggle-switch-track" aria-hidden="true">
<span class="toggle-switch-thumb"></span>
</span>
<span>启用</span>
</label>
</div>
<div class="setting-group setting-group-secondary step-range-controls">
<span class="setting-caption">步骤</span>
<input type="number" id="input-step-execution-range-from" class="data-input auto-delay-input step-range-input" value="1" min="1" step="1" title="允许执行的起始步骤" />
<span class="data-unit"></span>
<input type="number" id="input-step-execution-range-to" class="data-input auto-delay-input step-range-input" value="1" min="1" step="1" title="允许执行的结束步骤" />
</div>
</div>
</div>
<div class="data-row module-divider-start" id="row-oauth-display">
<span class="data-label">OAuth</span>
<span id="display-oauth-url" class="data-value mono truncate">等待中...</span>
+5 -11
View File
@@ -399,7 +399,6 @@ const inputStep6CookieCleanupEnabled = document.getElementById('input-step6-cook
const inputAutoDelayEnabled = document.getElementById('input-auto-delay-enabled');
const inputAutoDelayMinutes = document.getElementById('input-auto-delay-minutes');
const inputAutoStepDelaySeconds = document.getElementById('input-auto-step-delay-seconds');
const inputOperationDelayEnabled = document.getElementById('input-operation-delay-enabled');
const inputOAuthFlowTimeoutEnabled = document.getElementById('input-oauth-flow-timeout-enabled');
const rowStepExecutionRange = document.getElementById('row-step-execution-range');
const inputStepExecutionRangeEnabled = document.getElementById('input-step-execution-range-enabled');
@@ -554,7 +553,6 @@ let currentSignupMethod = DEFAULT_SIGNUP_METHOD;
let currentPhoneSignupReloginAfterBindEmailEnabled = DEFAULT_PHONE_SIGNUP_RELOGIN_AFTER_BIND_EMAIL_ENABLED;
let currentStepDefinitionFlowId = DEFAULT_ACTIVE_FLOW_ID;
let phoneSignupReuseUiWasLocked = false;
let lastConfirmedOperationDelayEnabled = true;
let heroSmsCountrySelectionOrder = [];
let phoneSmsProviderOrderSelection = [];
let heroSmsCountryMenuSearchKeyword = '';
@@ -2634,7 +2632,7 @@ function scheduleAccountRunHistoryRefresh(delayMs = 150) {
}
function normalizeOperationDelayEnabled(value) {
return typeof value === 'boolean' ? value : true;
return true;
}
function appendOperationDelayLog(enabled, level = 'info', message = '') {
@@ -2642,15 +2640,13 @@ function appendOperationDelayLog(enabled, level = 'info', message = '') {
timestamp: Date.now(),
level,
message: message || (enabled
? '操作间延迟已开启:页面输入、选择、点击、提交、继续、授权后等待 2 秒。'
: '操作间延迟已关闭:页面操作将连续执行。'),
? '操作间延迟已固定开启。'
: '操作间延迟保持固定开启。'),
});
}
function applyOperationDelayState(state = latestState, options = {}) {
const enabled = options.restoreFailed ? true : normalizeOperationDelayEnabled(state?.operationDelayEnabled);
lastConfirmedOperationDelayEnabled = enabled;
if (inputOperationDelayEnabled) inputOperationDelayEnabled.checked = enabled;
if (typeof syncLatestState === 'function') {
syncLatestState({ operationDelayEnabled: enabled });
}
@@ -2660,6 +2656,8 @@ function applyOperationDelayState(state = latestState, options = {}) {
}
async function persistOperationDelayToggle() {
applyOperationDelayState({ operationDelayEnabled: true });
return true;
const nextEnabled = normalizeOperationDelayEnabled(inputOperationDelayEnabled?.checked);
try {
const response = await chrome.runtime.sendMessage({
@@ -13741,10 +13739,6 @@ inputPlusModeEnabled?.addEventListener('change', () => {
saveSettings({ silent: true }).catch(() => { });
});
inputOperationDelayEnabled?.addEventListener('change', () => {
persistOperationDelayToggle().catch(() => { });
});
selectPlusPaymentMethod?.addEventListener('change', () => {
selectPlusPaymentMethod.value = normalizePlusPaymentMethod(selectPlusPaymentMethod.value);
updatePlusModeUI();