feat: 统一验证码重发次数配置,优化相关逻辑和界面
This commit is contained in:
@@ -1259,6 +1259,11 @@ header {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.setting-inline-right {
|
||||
min-width: 196px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.toggle-switch {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
|
||||
+29
-22
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
@@ -243,25 +243,6 @@
|
||||
<button id="btn-fetch-email" class="btn btn-outline btn-sm data-inline-btn" type="button">获取</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">自动重试</span>
|
||||
<div class="data-inline fallback-inline">
|
||||
<label class="toggle-switch" for="input-auto-skip-failures">
|
||||
<input type="checkbox" id="input-auto-skip-failures" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="timing-field timing-field-labeled timing-field-right fallback-thread-interval">
|
||||
<span class="auto-delay-caption">线程间隔</span>
|
||||
<div class="auto-delay-controls">
|
||||
<input type="number" id="input-auto-skip-failures-thread-interval-minutes" class="data-input auto-delay-input" value="0"
|
||||
min="0" max="1440" step="1" title="兜底模式下,两轮线程之间的等待分钟数" />
|
||||
<span class="data-unit">分钟</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">延迟</span>
|
||||
<div class="data-inline auto-delay-inline">
|
||||
@@ -288,16 +269,42 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">自动重试</span>
|
||||
<div class="data-inline fallback-inline">
|
||||
<label class="toggle-switch" for="input-auto-skip-failures">
|
||||
<input type="checkbox" id="input-auto-skip-failures" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="timing-field timing-field-labeled timing-field-right fallback-thread-interval">
|
||||
<span class="auto-delay-caption">线程间隔</span>
|
||||
<div class="auto-delay-controls">
|
||||
<input type="number" id="input-auto-skip-failures-thread-interval-minutes" class="data-input auto-delay-input" value="0"
|
||||
min="0" max="1440" step="1" title="兜底模式下,两轮线程之间的等待分钟数" />
|
||||
<span class="data-unit">分钟</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">本地留档</span>
|
||||
<div class="data-inline">
|
||||
<div class="data-inline auto-delay-inline">
|
||||
<label class="toggle-switch" for="input-account-run-history-text-enabled">
|
||||
<input type="checkbox" id="input-account-run-history-text-enabled" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
</label>
|
||||
<span class="data-value">同步写入账号运行历史 txt</span>
|
||||
<div class="timing-field timing-field-right setting-inline-right">
|
||||
<span class="auto-delay-caption">验证码重发</span>
|
||||
<div class="auto-delay-controls">
|
||||
<input type="number" id="input-verification-resend-count" class="data-input auto-delay-input" value="4"
|
||||
min="0" max="20" step="1" title="自动点击重新发送验证码的次数" />
|
||||
<span class="data-unit">次</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-account-run-history-helper-base-url" style="display:none;">
|
||||
|
||||
@@ -164,6 +164,7 @@ const inputAutoSkipFailuresThreadIntervalMinutes = document.getElementById('inpu
|
||||
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 inputVerificationResendCount = document.getElementById('input-verification-resend-count');
|
||||
const inputAccountRunHistoryTextEnabled = document.getElementById('input-account-run-history-text-enabled');
|
||||
const rowAccountRunHistoryHelperBaseUrl = document.getElementById('row-account-run-history-helper-base-url');
|
||||
const inputAccountRunHistoryHelperBaseUrl = document.getElementById('input-account-run-history-helper-base-url');
|
||||
@@ -193,6 +194,9 @@ const AUTO_FALLBACK_THREAD_INTERVAL_DEFAULT_MINUTES = 0;
|
||||
const AUTO_RUN_MAX_RETRIES_PER_ROUND = 3;
|
||||
const AUTO_STEP_DELAY_MIN_SECONDS = 0;
|
||||
const AUTO_STEP_DELAY_MAX_SECONDS = 600;
|
||||
const VERIFICATION_RESEND_COUNT_MIN = 0;
|
||||
const VERIFICATION_RESEND_COUNT_MAX = 20;
|
||||
const DEFAULT_VERIFICATION_RESEND_COUNT = 4;
|
||||
const DEFAULT_LOCAL_CPA_STEP9_MODE = 'submit';
|
||||
const DEFAULT_CPA_CALLBACK_MODE = 'step9';
|
||||
const MAIL_2925_MODE_PROVIDE = 'provide';
|
||||
@@ -976,6 +980,23 @@ function normalizeAutoStepDelaySeconds(value) {
|
||||
return Math.min(AUTO_STEP_DELAY_MAX_SECONDS, Math.max(AUTO_STEP_DELAY_MIN_SECONDS, Math.floor(numeric)));
|
||||
}
|
||||
|
||||
function normalizeVerificationResendCount(value, fallback) {
|
||||
const rawValue = String(value ?? '').trim();
|
||||
if (!rawValue) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const numeric = Number(rawValue);
|
||||
if (!Number.isFinite(numeric)) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
return Math.min(
|
||||
VERIFICATION_RESEND_COUNT_MAX,
|
||||
Math.max(VERIFICATION_RESEND_COUNT_MIN, Math.floor(numeric))
|
||||
);
|
||||
}
|
||||
|
||||
function formatAutoStepDelayInputValue(value) {
|
||||
const normalized = normalizeAutoStepDelaySeconds(value);
|
||||
return normalized === null ? '' : String(normalized);
|
||||
@@ -1310,6 +1331,10 @@ function collectSettingsPayload() {
|
||||
autoRunDelayEnabled: inputAutoDelayEnabled.checked,
|
||||
autoRunDelayMinutes: normalizeAutoDelayMinutes(inputAutoDelayMinutes.value),
|
||||
autoStepDelaySeconds: normalizeAutoStepDelaySeconds(inputAutoStepDelaySeconds.value),
|
||||
verificationResendCount: normalizeVerificationResendCount(
|
||||
inputVerificationResendCount?.value,
|
||||
DEFAULT_VERIFICATION_RESEND_COUNT
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1729,6 +1754,14 @@ function applySettingsState(state) {
|
||||
inputAutoDelayEnabled.checked = Boolean(state?.autoRunDelayEnabled);
|
||||
inputAutoDelayMinutes.value = String(normalizeAutoDelayMinutes(state?.autoRunDelayMinutes));
|
||||
inputAutoStepDelaySeconds.value = formatAutoStepDelayInputValue(state?.autoStepDelaySeconds);
|
||||
if (inputVerificationResendCount) {
|
||||
const restoredVerificationResendCount = state?.verificationResendCount !== undefined
|
||||
? state.verificationResendCount
|
||||
: (state?.signupVerificationResendCount ?? state?.loginVerificationResendCount);
|
||||
inputVerificationResendCount.value = String(
|
||||
normalizeVerificationResendCount(restoredVerificationResendCount, DEFAULT_VERIFICATION_RESEND_COUNT)
|
||||
);
|
||||
}
|
||||
if (state?.autoRunTotalRuns) {
|
||||
inputRunCount.value = String(state.autoRunTotalRuns);
|
||||
}
|
||||
@@ -3992,6 +4025,20 @@ inputAutoStepDelaySeconds.addEventListener('blur', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputVerificationResendCount?.addEventListener('input', () => {
|
||||
markSettingsDirty(true);
|
||||
scheduleSettingsAutoSave();
|
||||
});
|
||||
inputVerificationResendCount?.addEventListener('blur', () => {
|
||||
inputVerificationResendCount.value = String(
|
||||
normalizeVerificationResendCount(
|
||||
inputVerificationResendCount.value,
|
||||
DEFAULT_VERIFICATION_RESEND_COUNT
|
||||
)
|
||||
);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// Listen for Background broadcasts
|
||||
// ============================================================
|
||||
@@ -4192,6 +4239,24 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
if (message.payload.autoStepDelaySeconds !== undefined) {
|
||||
inputAutoStepDelaySeconds.value = formatAutoStepDelayInputValue(message.payload.autoStepDelaySeconds);
|
||||
}
|
||||
if (
|
||||
(
|
||||
message.payload.verificationResendCount !== undefined
|
||||
|| message.payload.signupVerificationResendCount !== undefined
|
||||
|| message.payload.loginVerificationResendCount !== undefined
|
||||
)
|
||||
&& inputVerificationResendCount
|
||||
) {
|
||||
const nextVerificationResendCount = message.payload.verificationResendCount !== undefined
|
||||
? message.payload.verificationResendCount
|
||||
: (message.payload.signupVerificationResendCount ?? message.payload.loginVerificationResendCount);
|
||||
inputVerificationResendCount.value = String(
|
||||
normalizeVerificationResendCount(
|
||||
nextVerificationResendCount,
|
||||
DEFAULT_VERIFICATION_RESEND_COUNT
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user