feat: 添加浏览器切换所需错误处理,增强步骤 10 的诊断信息
This commit is contained in:
@@ -147,6 +147,7 @@ const HOTMAIL_MAILBOXES = ['INBOX', 'Junk'];
|
||||
const STOP_ERROR_MESSAGE = '流程已被用户停止。';
|
||||
const CLOUDFLARE_SECURITY_BLOCK_ERROR_PREFIX = 'CF_SECURITY_BLOCKED::';
|
||||
const CLOUDFLARE_SECURITY_BLOCK_USER_MESSAGE = '您已触发Cloudflare 安全防护系统,已完全停止流程,请不要短时间内多次进行重新发送验证码,连续刷新、反复点击重试会加重风控;请先关闭页面等待 15-30 分钟,让系统的临时限制自动解除。或者更换浏览器';
|
||||
const BROWSER_SWITCH_REQUIRED_ERROR_PREFIX = 'BROWSER_SWITCH_REQUIRED::';
|
||||
const HUMAN_STEP_DELAY_MIN = 700;
|
||||
const HUMAN_STEP_DELAY_MAX = 2200;
|
||||
const STEP6_MAX_ATTEMPTS = 3;
|
||||
@@ -4000,6 +4001,17 @@ function getTerminalSecurityBlockedTitle(error) {
|
||||
return 'Cloudflare 风控拦截';
|
||||
}
|
||||
|
||||
function isBrowserSwitchRequiredError(error) {
|
||||
return getErrorMessage(error).startsWith(BROWSER_SWITCH_REQUIRED_ERROR_PREFIX);
|
||||
}
|
||||
|
||||
function getBrowserSwitchRequiredMessage(error) {
|
||||
const message = getErrorMessage(error);
|
||||
return message.startsWith(BROWSER_SWITCH_REQUIRED_ERROR_PREFIX)
|
||||
? message.slice(BROWSER_SWITCH_REQUIRED_ERROR_PREFIX.length).trim()
|
||||
: message;
|
||||
}
|
||||
|
||||
function broadcastSecurityBlockedAlert(title = '流程已完全停止', message = CLOUDFLARE_SECURITY_BLOCK_USER_MESSAGE, alertText = '检测到 Cloudflare 风控,请暂停当前操作。') {
|
||||
chrome.runtime.sendMessage({
|
||||
type: 'SECURITY_BLOCKED_ALERT',
|
||||
@@ -4023,6 +4035,13 @@ async function handleCloudflareSecurityBlocked(error) {
|
||||
return message;
|
||||
}
|
||||
|
||||
async function handleBrowserSwitchRequired(error) {
|
||||
const message = getBrowserSwitchRequiredMessage(error)
|
||||
|| '检测到第 10 步的特殊冲突状态,请更换浏览器后重新进行注册登录。';
|
||||
await requestStop({ logMessage: message });
|
||||
return message;
|
||||
}
|
||||
|
||||
function isVerificationMailPollingError(error) {
|
||||
if (typeof loggingStatus !== 'undefined' && loggingStatus?.isVerificationMailPollingError) {
|
||||
return loggingStatus.isVerificationMailPollingError(error);
|
||||
@@ -5326,6 +5345,10 @@ async function executeStep(step, options = {}) {
|
||||
await handleCloudflareSecurityBlocked(err);
|
||||
throw new Error(STOP_ERROR_MESSAGE);
|
||||
}
|
||||
if (isBrowserSwitchRequiredError(err)) {
|
||||
await handleBrowserSwitchRequired(err);
|
||||
throw new Error(STOP_ERROR_MESSAGE);
|
||||
}
|
||||
if (!(deferRetryableTransportError && doesStepUseCompletionSignal(step) && isRetryableContentScriptTransportError(err))) {
|
||||
await setStepStatus(step, 'failed');
|
||||
await addLog(`步骤 ${step} 失败:${err.message}`, 'error');
|
||||
|
||||
Reference in New Issue
Block a user