feat: 添加步骤 5 提交状态验证和重试页面恢复逻辑,更新相关测试用例

This commit is contained in:
QLHazyCoder
2026-05-12 00:26:54 +08:00
parent c6a37005e3
commit 745010d6c9
6 changed files with 457 additions and 5 deletions
+60 -1
View File
@@ -27,8 +27,10 @@ if (document.documentElement.getAttribute(SIGNUP_PAGE_LISTENER_SENTINEL) !== '1'
|| message.type === 'STEP8_TRIGGER_CONTINUE'
|| message.type === 'GET_LOGIN_AUTH_STATE'
|| message.type === 'SUBMIT_ADD_EMAIL'
|| message.type === 'GET_STEP5_SUBMIT_STATE'
|| message.type === 'PREPARE_SIGNUP_VERIFICATION'
|| message.type === 'RECOVER_AUTH_RETRY_PAGE'
|| message.type === 'RECOVER_STEP5_SUBMIT_RETRY_PAGE'
|| message.type === 'RESEND_VERIFICATION_CODE'
|| message.type === 'SUBMIT_PHONE_NUMBER'
|| message.type === 'SUBMIT_PHONE_VERIFICATION_CODE'
@@ -88,10 +90,14 @@ async function handleCommand(message) {
return serializeLoginAuthState(inspectLoginAuthState());
case 'SUBMIT_ADD_EMAIL':
return await submitAddEmailAndContinue(message.payload);
case 'GET_STEP5_SUBMIT_STATE':
return getStep5SubmitState();
case 'PREPARE_SIGNUP_VERIFICATION':
return await prepareSignupVerificationFlow(message.payload);
case 'RECOVER_AUTH_RETRY_PAGE':
return await recoverCurrentAuthRetryPage(message.payload);
case 'RECOVER_STEP5_SUBMIT_RETRY_PAGE':
return await recoverStep5SubmitRetryPage(message.payload);
case 'RESEND_VERIFICATION_CODE':
return await resendVerificationCode(message.step);
case 'SUBMIT_PHONE_NUMBER':
@@ -2820,7 +2826,7 @@ function isSignupProfilePageUrl(rawUrl = location.href) {
if (!['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com'].includes(host)) {
return false;
}
return /\/(?:create-account\/profile|u\/signup\/profile|signup\/profile)(?:[/?#]|$)/i.test(String(parsed.pathname || ''));
return /\/(?:create-account\/profile|u\/signup\/profile|signup\/profile|about-you)(?:[/?#]|$)/i.test(String(parsed.pathname || ''));
} catch {
return false;
}
@@ -6422,6 +6428,7 @@ function getStep5ProfilePathPatterns() {
/\/create-account\/profile(?:[/?#]|$)/i,
/\/u\/signup\/profile(?:[/?#]|$)/i,
/\/signup\/profile(?:[/?#]|$)/i,
/\/about-you(?:[/?#]|$)/i,
];
}
@@ -6535,6 +6542,15 @@ function getStep5PostSubmitSuccessState() {
}
if (!isStep5ProfileStillVisible()) {
try {
const parsed = new URL(String(location.href || '').trim());
const host = String(parsed.hostname || '').toLowerCase();
if (['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com'].includes(host)) {
return null;
}
} catch {
// Fall through to the generic "left_profile" success state.
}
return {
state: 'left_profile',
url: location.href,
@@ -6544,6 +6560,49 @@ function getStep5PostSubmitSuccessState() {
return null;
}
function getStep5SubmitState() {
const retryState = getStep5AuthRetryPageState();
const successState = getStep5PostSubmitSuccessState();
const errorText = typeof getStep5ErrorText === 'function' ? getStep5ErrorText() : '';
let signupAuthHost = false;
try {
const parsed = new URL(String(location.href || '').trim());
signupAuthHost = ['auth.openai.com', 'auth0.openai.com', 'accounts.openai.com']
.includes(String(parsed.hostname || '').toLowerCase());
} catch {
signupAuthHost = false;
}
return {
url: location.href,
retryPage: Boolean(retryState),
retryEnabled: Boolean(retryState?.retryEnabled),
maxCheckAttemptsBlocked: Boolean(retryState?.maxCheckAttemptsBlocked),
userAlreadyExistsBlocked: Boolean(retryState?.userAlreadyExistsBlocked),
successState: successState?.state || '',
profileVisible: isStep5ProfileStillVisible(),
errorText,
unknownAuthPage: Boolean(
signupAuthHost
&& !retryState
&& !successState
&& !isStep5ProfileStillVisible()
),
};
}
async function recoverStep5SubmitRetryPage(payload = {}) {
return recoverCurrentAuthRetryPage({
...payload,
flow: 'signup',
logLabel: payload?.logLabel || '步骤 5:资料提交后检测到认证重试页,正在点击“重试”恢复',
maxClickAttempts: payload?.maxClickAttempts ?? 2,
pathPatterns: Array.isArray(payload?.pathPatterns) ? payload.pathPatterns : getStep5AuthRetryPathPatterns(),
step: 5,
timeoutMs: payload?.timeoutMs ?? 12000,
});
}
function installStep5NavigationCompletionReporter(completeOnce) {
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') {
return () => {};