feat: 优化步骤 5 提交逻辑,点击后立即上报完成状态,避免等待页面结果
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
addLog,
|
||||
generateRandomBirthday,
|
||||
generateRandomName,
|
||||
getState,
|
||||
getTabId,
|
||||
handleChatgptOnboardingSkip,
|
||||
isRetryableContentScriptTransportError,
|
||||
@@ -14,6 +15,14 @@
|
||||
waitForStep5ChatgptRedirect,
|
||||
} = deps;
|
||||
|
||||
async function isStepAlreadyCompleted(step) {
|
||||
if (typeof getState !== 'function') {
|
||||
return false;
|
||||
}
|
||||
const latestState = await getState().catch(() => null);
|
||||
return latestState?.stepStatuses?.[step] === 'completed';
|
||||
}
|
||||
|
||||
async function executeStep5() {
|
||||
const { firstName, lastName } = generateRandomName();
|
||||
const { year, month, day } = generateRandomBirthday();
|
||||
@@ -39,6 +48,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (step5TransportError && await isStepAlreadyCompleted(5)) {
|
||||
await addLog('步骤 5:提交后的页面跳转打断了响应,但已收到完成信号,直接结束当前步骤。', 'info');
|
||||
return;
|
||||
}
|
||||
|
||||
if (step5Result?.chatgptOnboarding) {
|
||||
await addLog('步骤 5:检测到 ChatGPT 引导页跳转,正在处理引导页跳过...');
|
||||
await handleChatgptOnboardingSkip();
|
||||
|
||||
Reference in New Issue
Block a user