优化步骤在日志中的显示
This commit is contained in:
+96
-65
@@ -42,7 +42,7 @@ if (document.documentElement.getAttribute(SIGNUP_PAGE_LISTENER_SENTINEL) !== '1'
|
||||
}
|
||||
|
||||
if (message.type === 'STEP8_FIND_AND_CLICK') {
|
||||
log(`步骤 9:${err.message}`, 'error');
|
||||
log(err.message, 'error', { step: reportedStep || 9, stepKey: 'confirm-oauth' });
|
||||
sendResponse({ error: err.message });
|
||||
return;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ async function handleCommand(message) {
|
||||
case 'ENSURE_SIGNUP_PASSWORD_PAGE_READY':
|
||||
return await ensureSignupPasswordPageReady();
|
||||
case 'STEP8_FIND_AND_CLICK':
|
||||
return await step8_findAndClick();
|
||||
return await step8_findAndClick(message.payload);
|
||||
case 'STEP8_GET_STATE':
|
||||
return getStep8State();
|
||||
case 'STEP8_TRIGGER_CONTINUE':
|
||||
@@ -102,6 +102,15 @@ async function handleCommand(message) {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveVisibleStep(payload = {}, fallback = 0) {
|
||||
const step = Math.floor(Number(payload?.visibleStep) || 0);
|
||||
return step > 0 ? step : fallback;
|
||||
}
|
||||
|
||||
function stepLog(step, message, level = 'info', stepKey = '') {
|
||||
return log(message, level, { step, stepKey });
|
||||
}
|
||||
|
||||
const VERIFICATION_CODE_INPUT_SELECTOR = [
|
||||
'input[name="code"]',
|
||||
'input[name="otp"]',
|
||||
@@ -224,7 +233,7 @@ function isEmailVerificationPage() {
|
||||
|
||||
async function resendVerificationCode(step, timeout = 45000) {
|
||||
if (step === 8) {
|
||||
await waitForLoginVerificationPageReady();
|
||||
await waitForLoginVerificationPageReady(10000, step);
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
@@ -1915,7 +1924,11 @@ async function waitForKnownLoginAuthState(timeout = 15000) {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
async function waitForLoginVerificationPageReady(timeout = 10000) {
|
||||
function getAuthLoginStepForLoginCodeStep(step = 8) {
|
||||
return Number(step) >= 11 ? 10 : 7;
|
||||
}
|
||||
|
||||
async function waitForLoginVerificationPageReady(timeout = 10000, visibleStep = 8) {
|
||||
const start = Date.now();
|
||||
let snapshot = inspectLoginAuthState();
|
||||
|
||||
@@ -1932,7 +1945,7 @@ async function waitForLoginVerificationPageReady(timeout = 10000) {
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`当前未进入登录验证码页面,请先重新完成步骤 7。当前状态:${getLoginAuthStateLabel(snapshot)}。URL: ${snapshot?.url || location.href}`
|
||||
`当前未进入登录验证码页面,请先重新完成步骤 ${Number(visibleStep) >= 11 ? 10 : 7}。当前状态:${getLoginAuthStateLabel(snapshot)}。URL: ${snapshot?.url || location.href}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1979,6 +1992,7 @@ function createStep6RecoverableResult(reason, snapshot, options = {}) {
|
||||
async function createStep6LoginTimeoutRecoveryTransition(reason, snapshot, message, options = {}) {
|
||||
const {
|
||||
loginVerificationRequestedAt = null,
|
||||
visibleStep = 7,
|
||||
via = 'login_timeout_recovered',
|
||||
} = options;
|
||||
let resolvedSnapshot = normalizeStep6Snapshot(snapshot || inspectLoginAuthState());
|
||||
@@ -1987,19 +2001,19 @@ async function createStep6LoginTimeoutRecoveryTransition(reason, snapshot, messa
|
||||
try {
|
||||
const recoveryResult = await recoverCurrentAuthRetryPage({
|
||||
flow: 'login',
|
||||
logLabel: '步骤 7:检测到登录超时报错,正在点击“重试”恢复当前页面',
|
||||
step: 7,
|
||||
logLabel: `步骤 ${visibleStep}:检测到登录超时报错,正在点击“重试”恢复当前页面`,
|
||||
step: visibleStep,
|
||||
timeoutMs: 12000,
|
||||
});
|
||||
recovered = Boolean(recoveryResult?.recovered);
|
||||
if (recovered) {
|
||||
log('步骤 7:登录超时报错页已点击“重试”,正在按恢复后的页面状态继续当前流程。', 'warn');
|
||||
log('登录超时报错页已点击“重试”,正在按恢复后的页面状态继续当前流程。', 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
}
|
||||
} catch (error) {
|
||||
if (/CF_SECURITY_BLOCKED::/i.test(String(error?.message || error || ''))) {
|
||||
throw error;
|
||||
}
|
||||
log(`步骤 7:登录超时报错页自动点击“重试”失败:${error.message}`, 'warn');
|
||||
log(`登录超时报错页自动点击“重试”失败:${error.message}`, 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2027,12 +2041,12 @@ async function createStep6LoginTimeoutRecoveryTransition(reason, snapshot, messa
|
||||
}
|
||||
|
||||
if (resolvedSnapshot.state === 'password_page') {
|
||||
log('步骤 7:登录超时报错页恢复后已进入密码页,继续当前登录流程。', 'warn');
|
||||
log('登录超时报错页恢复后已进入密码页,继续当前登录流程。', 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return { action: 'password', snapshot: resolvedSnapshot };
|
||||
}
|
||||
|
||||
if (resolvedSnapshot.state === 'email_page') {
|
||||
log('步骤 7:登录超时报错页恢复后已回到邮箱输入页,继续当前登录流程。', 'warn');
|
||||
log('登录超时报错页恢复后已回到邮箱输入页,继续当前登录流程。', 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return { action: 'email', snapshot: resolvedSnapshot };
|
||||
}
|
||||
|
||||
@@ -2045,8 +2059,8 @@ async function createStep6LoginTimeoutRecoveryTransition(reason, snapshot, messa
|
||||
};
|
||||
}
|
||||
|
||||
async function createStep6LoginTimeoutRecoverableResult(reason, snapshot, message) {
|
||||
const transition = await createStep6LoginTimeoutRecoveryTransition(reason, snapshot, message);
|
||||
async function createStep6LoginTimeoutRecoverableResult(reason, snapshot, message, options = {}) {
|
||||
const transition = await createStep6LoginTimeoutRecoveryTransition(reason, snapshot, message, options);
|
||||
if (transition?.action === 'done' || transition?.action === 'recoverable') {
|
||||
return transition.result;
|
||||
}
|
||||
@@ -2058,7 +2072,8 @@ async function createStep6LoginTimeoutRecoverableResult(reason, snapshot, messag
|
||||
|
||||
async function finalizeStep6VerificationReady(options = {}) {
|
||||
const {
|
||||
logLabel = '步骤 7 收尾',
|
||||
visibleStep = 7,
|
||||
logLabel = `步骤 ${visibleStep} 收尾`,
|
||||
loginVerificationRequestedAt = null,
|
||||
timeout = 12000,
|
||||
via = 'verification_page_ready',
|
||||
@@ -2071,14 +2086,14 @@ async function finalizeStep6VerificationReady(options = {}) {
|
||||
while (Date.now() - start < timeout && round < maxRounds) {
|
||||
throwIfStopped();
|
||||
round += 1;
|
||||
log(`${logLabel}:确认页面是否稳定停留在登录验证码阶段(第 ${round}/${maxRounds} 轮,先等待 3 秒)...`, 'info');
|
||||
log(`确认页面是否稳定停留在登录验证码阶段(第 ${round}/${maxRounds} 轮,先等待 3 秒)...`, 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
await sleep(settleDelayMs);
|
||||
|
||||
const rawSnapshot = inspectLoginAuthState();
|
||||
const snapshot = normalizeStep6Snapshot(rawSnapshot);
|
||||
|
||||
if (snapshot.state === 'verification_page') {
|
||||
log(`${logLabel}:登录验证码页面已稳定就绪。`, 'ok');
|
||||
log('登录验证码页面已稳定就绪。', 'ok', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6SuccessResult(snapshot, {
|
||||
via,
|
||||
loginVerificationRequestedAt,
|
||||
@@ -2086,24 +2101,25 @@ async function finalizeStep6VerificationReady(options = {}) {
|
||||
}
|
||||
|
||||
if (snapshot.state === 'oauth_consent_page') {
|
||||
log(`${logLabel}:认证页已直接进入 OAuth 授权页,跳过登录验证码步骤。`, 'ok');
|
||||
log('认证页已直接进入 OAuth 授权页,跳过登录验证码步骤。', 'ok', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6OAuthConsentSuccessResult(snapshot, {
|
||||
via: `${via}_oauth_consent`,
|
||||
});
|
||||
}
|
||||
|
||||
if (snapshot.state === 'login_timeout_error_page') {
|
||||
log(`${logLabel}:页面进入登录超时报错页,准备自动恢复后重试步骤 7。`, 'warn');
|
||||
log(`页面进入登录超时报错页,准备自动恢复后重试步骤 ${visibleStep}。`, 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6LoginTimeoutRecoverableResult(
|
||||
'login_timeout_error_page',
|
||||
snapshot,
|
||||
'登录验证码页面准备就绪前进入登录超时报错页。'
|
||||
'登录验证码页面准备就绪前进入登录超时报错页。',
|
||||
{ visibleStep }
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.state === 'password_page' || snapshot.state === 'email_page') {
|
||||
return createStep6RecoverableResult('verification_page_unstable', snapshot, {
|
||||
message: `页面曾进入登录验证码阶段,但又回到了${getLoginAuthStateLabel(snapshot)},准备重新执行步骤 7。`,
|
||||
message: `页面曾进入登录验证码阶段,但又回到了${getLoginAuthStateLabel(snapshot)},准备重新执行步骤 ${visibleStep}。`,
|
||||
loginVerificationRequestedAt,
|
||||
});
|
||||
}
|
||||
@@ -2116,35 +2132,36 @@ async function finalizeStep6VerificationReady(options = {}) {
|
||||
const rawSnapshot = inspectLoginAuthState();
|
||||
const snapshot = normalizeStep6Snapshot(rawSnapshot);
|
||||
if (snapshot.state === 'verification_page') {
|
||||
log(`${logLabel}:登录验证码页面已稳定就绪。`, 'ok');
|
||||
log('登录验证码页面已稳定就绪。', 'ok', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6SuccessResult(snapshot, {
|
||||
via,
|
||||
loginVerificationRequestedAt,
|
||||
});
|
||||
}
|
||||
if (snapshot.state === 'oauth_consent_page') {
|
||||
log(`${logLabel}:认证页已直接进入 OAuth 授权页,跳过登录验证码步骤。`, 'ok');
|
||||
log('认证页已直接进入 OAuth 授权页,跳过登录验证码步骤。', 'ok', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6OAuthConsentSuccessResult(snapshot, {
|
||||
via: `${via}_oauth_consent`,
|
||||
});
|
||||
}
|
||||
if (snapshot.state === 'login_timeout_error_page') {
|
||||
log(`${logLabel}:页面进入登录超时报错页,准备自动恢复后重试步骤 7。`, 'warn');
|
||||
log(`页面进入登录超时报错页,准备自动恢复后重试步骤 ${visibleStep}。`, 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6LoginTimeoutRecoverableResult(
|
||||
'login_timeout_error_page',
|
||||
snapshot,
|
||||
'登录验证码页面准备就绪前进入登录超时报错页。'
|
||||
'登录验证码页面准备就绪前进入登录超时报错页。',
|
||||
{ visibleStep }
|
||||
);
|
||||
}
|
||||
if (snapshot.state === 'password_page' || snapshot.state === 'email_page') {
|
||||
return createStep6RecoverableResult('verification_page_unstable', snapshot, {
|
||||
message: `页面曾进入登录验证码阶段,但又回到了${getLoginAuthStateLabel(snapshot)},准备重新执行步骤 7。`,
|
||||
message: `页面曾进入登录验证码阶段,但又回到了${getLoginAuthStateLabel(snapshot)},准备重新执行步骤 ${visibleStep}。`,
|
||||
loginVerificationRequestedAt,
|
||||
});
|
||||
}
|
||||
|
||||
return createStep6RecoverableResult('verification_page_finalize_unknown', snapshot, {
|
||||
message: '登录验证码页面状态在收尾确认阶段未稳定,准备重新执行步骤 7。',
|
||||
message: `登录验证码页面状态在收尾确认阶段未稳定,准备重新执行步骤 ${visibleStep}。`,
|
||||
loginVerificationRequestedAt,
|
||||
});
|
||||
}
|
||||
@@ -2153,13 +2170,13 @@ function normalizeStep6Snapshot(snapshot) {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
function throwForStep6FatalState(snapshot) {
|
||||
function throwForStep6FatalState(snapshot, visibleStep = 7) {
|
||||
snapshot = normalizeStep6Snapshot(snapshot);
|
||||
switch (snapshot?.state) {
|
||||
case 'oauth_consent_page':
|
||||
return;
|
||||
case 'add_phone_page':
|
||||
throw new Error(`当前页面已进入手机号页面,未经过登录验证码页,无法完成步骤 7。URL: ${snapshot.url}`);
|
||||
throw new Error(`当前页面已进入手机号页面,未经过登录验证码页,无法完成步骤 ${visibleStep}。URL: ${snapshot.url}`);
|
||||
case 'unknown':
|
||||
throw new Error(`无法识别当前登录页面状态。URL: ${snapshot?.url || location.href}`);
|
||||
default:
|
||||
@@ -2573,7 +2590,7 @@ async function fillVerificationCode(step, payload) {
|
||||
log(`步骤 ${step}:正在填写验证码:${code}`);
|
||||
|
||||
if (step === 8) {
|
||||
await waitForLoginVerificationPageReady();
|
||||
await waitForLoginVerificationPageReady(10000, step);
|
||||
}
|
||||
|
||||
const combinedSignupProfilePage = step === 4
|
||||
@@ -2731,6 +2748,7 @@ async function resolveStep6PostSubmitSnapshot(snapshot, options = {}) {
|
||||
allowFinalPasswordAction = false,
|
||||
allowFinalEmailAction = false,
|
||||
allowFinalSwitchAction = false,
|
||||
visibleStep = 7,
|
||||
final = false,
|
||||
addPhoneMessage,
|
||||
} = options;
|
||||
@@ -2760,6 +2778,7 @@ async function resolveStep6PostSubmitSnapshot(snapshot, options = {}) {
|
||||
normalizedSnapshot,
|
||||
timeoutRecoveryMessage,
|
||||
{
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt,
|
||||
via: timeoutRecoveryVia,
|
||||
}
|
||||
@@ -2844,9 +2863,10 @@ async function waitForStep6PostSubmitTransition(options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
async function waitForStep6EmailSubmitTransition(emailSubmittedAt, timeout = 12000) {
|
||||
async function waitForStep6EmailSubmitTransition(emailSubmittedAt, timeout = 12000, options = {}) {
|
||||
return waitForStep6PostSubmitTransition({
|
||||
timeout,
|
||||
visibleStep: Math.floor(Number(options?.visibleStep) || 0) || 7,
|
||||
via: 'email_submit',
|
||||
oauthConsentVia: 'email_submit_oauth_consent',
|
||||
loginVerificationRequestedAt: emailSubmittedAt,
|
||||
@@ -2859,9 +2879,10 @@ async function waitForStep6EmailSubmitTransition(emailSubmittedAt, timeout = 120
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForStep6PasswordSubmitTransition(passwordSubmittedAt, timeout = 10000) {
|
||||
async function waitForStep6PasswordSubmitTransition(passwordSubmittedAt, timeout = 10000, options = {}) {
|
||||
return waitForStep6PostSubmitTransition({
|
||||
timeout,
|
||||
visibleStep: Math.floor(Number(options?.visibleStep) || 0) || 7,
|
||||
via: 'password_submit',
|
||||
oauthConsentVia: 'password_submit_oauth_consent',
|
||||
loginVerificationRequestedAt: passwordSubmittedAt,
|
||||
@@ -2874,9 +2895,10 @@ async function waitForStep6PasswordSubmitTransition(passwordSubmittedAt, timeout
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForStep6SwitchTransition(loginVerificationRequestedAt, timeout = 10000) {
|
||||
async function waitForStep6SwitchTransition(loginVerificationRequestedAt, timeout = 10000, options = {}) {
|
||||
const transition = await waitForStep6PostSubmitTransition({
|
||||
timeout,
|
||||
visibleStep: Math.floor(Number(options?.visibleStep) || 0) || 7,
|
||||
via: 'switch_to_one_time_code_login',
|
||||
oauthConsentVia: 'switch_to_one_time_code_oauth_consent',
|
||||
loginVerificationRequestedAt,
|
||||
@@ -2910,6 +2932,7 @@ async function waitForLoginEntryOpenTransition(timeout = 10000) {
|
||||
}
|
||||
|
||||
async function step6OpenLoginEntry(payload, snapshot) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 7;
|
||||
const currentSnapshot = normalizeStep6Snapshot(snapshot || inspectLoginAuthState());
|
||||
const trigger = currentSnapshot.loginEntryTrigger || findLoginEntryTrigger();
|
||||
if (!trigger || !isActionEnabled(trigger)) {
|
||||
@@ -2918,7 +2941,7 @@ async function step6OpenLoginEntry(payload, snapshot) {
|
||||
});
|
||||
}
|
||||
|
||||
log(`步骤 7:检测到登录入口页,正在点击 "${getActionText(trigger).slice(0, 80)}"...`);
|
||||
log(`检测到登录入口页,正在点击 "${getActionText(trigger).slice(0, 80)}"...`, 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
await humanPause(350, 900);
|
||||
simulateClick(trigger);
|
||||
const nextSnapshot = await waitForLoginEntryOpenTransition();
|
||||
@@ -2931,7 +2954,7 @@ async function step6OpenLoginEntry(payload, snapshot) {
|
||||
}
|
||||
if (nextSnapshot.state === 'verification_page') {
|
||||
return finalizeStep6VerificationReady({
|
||||
logLabel: '步骤 7 收尾',
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: null,
|
||||
via: 'entry_open_verification_page',
|
||||
});
|
||||
@@ -2945,7 +2968,8 @@ async function step6OpenLoginEntry(payload, snapshot) {
|
||||
const transition = await createStep6LoginTimeoutRecoveryTransition(
|
||||
'login_timeout_after_entry_open',
|
||||
nextSnapshot,
|
||||
'点击登录入口后进入登录超时报错页。'
|
||||
'点击登录入口后进入登录超时报错页。',
|
||||
{ visibleStep }
|
||||
);
|
||||
if (transition.action === 'done') return transition.result;
|
||||
if (transition.action === 'email') return step6LoginFromEmailPage(payload, transition.snapshot);
|
||||
@@ -2959,6 +2983,7 @@ async function step6OpenLoginEntry(payload, snapshot) {
|
||||
}
|
||||
|
||||
async function step6SwitchToOneTimeCodeLogin(payload, snapshot) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 7;
|
||||
const switchTrigger = snapshot?.switchTrigger || findOneTimeCodeLoginTrigger();
|
||||
if (!switchTrigger || !isActionEnabled(switchTrigger)) {
|
||||
return createStep6RecoverableResult('missing_one_time_code_trigger', normalizeStep6Snapshot(inspectLoginAuthState()), {
|
||||
@@ -2966,19 +2991,19 @@ async function step6SwitchToOneTimeCodeLogin(payload, snapshot) {
|
||||
});
|
||||
}
|
||||
|
||||
log('步骤 7:已检测到一次性验证码登录入口,准备切换...');
|
||||
log('已检测到一次性验证码登录入口,准备切换...', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
const loginVerificationRequestedAt = Date.now();
|
||||
await humanPause(350, 900);
|
||||
simulateClick(switchTrigger);
|
||||
log('步骤 7:已点击一次性验证码登录');
|
||||
log('已点击一次性验证码登录', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
await sleep(1200);
|
||||
const result = await waitForStep6SwitchTransition(loginVerificationRequestedAt);
|
||||
const result = await waitForStep6SwitchTransition(loginVerificationRequestedAt, 10000, { visibleStep });
|
||||
if (result?.step6Outcome === 'success') {
|
||||
if (result.skipLoginVerificationStep) {
|
||||
return result;
|
||||
}
|
||||
return finalizeStep6VerificationReady({
|
||||
logLabel: '步骤 7 收尾',
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: result.loginVerificationRequestedAt || loginVerificationRequestedAt,
|
||||
via: result.via || 'switch_to_one_time_code_login',
|
||||
});
|
||||
@@ -2993,13 +3018,14 @@ async function step6SwitchToOneTimeCodeLogin(payload, snapshot) {
|
||||
}
|
||||
|
||||
async function step6LoginFromPasswordPage(payload, snapshot) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 7;
|
||||
const currentSnapshot = normalizeStep6Snapshot(snapshot || inspectLoginAuthState());
|
||||
const hasPassword = Boolean(String(payload?.password || '').trim());
|
||||
|
||||
if (currentSnapshot.passwordInput) {
|
||||
if (!hasPassword) {
|
||||
if (currentSnapshot.switchTrigger) {
|
||||
log('步骤 7:当前未提供密码,改走一次性验证码登录。', 'warn');
|
||||
log('当前未提供密码,改走一次性验证码登录。', 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return step6SwitchToOneTimeCodeLogin(payload, currentSnapshot);
|
||||
}
|
||||
|
||||
@@ -3008,29 +3034,29 @@ async function step6LoginFromPasswordPage(payload, snapshot) {
|
||||
});
|
||||
}
|
||||
|
||||
log('步骤 7:已进入密码页,准备填写密码...');
|
||||
log('已进入密码页,准备填写密码...', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
await humanPause(550, 1450);
|
||||
fillInput(currentSnapshot.passwordInput, payload.password);
|
||||
log('步骤 7:已填写密码');
|
||||
log('已填写密码', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
|
||||
await sleep(500);
|
||||
const passwordSubmittedAt = Date.now();
|
||||
await triggerLoginSubmitAction(currentSnapshot.submitButton, currentSnapshot.passwordInput);
|
||||
log('步骤 7:已提交密码');
|
||||
log('已提交密码', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
|
||||
const transition = await waitForStep6PasswordSubmitTransition(passwordSubmittedAt);
|
||||
const transition = await waitForStep6PasswordSubmitTransition(passwordSubmittedAt, 10000, { visibleStep });
|
||||
if (transition.action === 'done') {
|
||||
if (transition.result?.skipLoginVerificationStep) {
|
||||
return transition.result;
|
||||
}
|
||||
return finalizeStep6VerificationReady({
|
||||
logLabel: '步骤 7 收尾',
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: transition.result.loginVerificationRequestedAt || passwordSubmittedAt,
|
||||
via: transition.result.via || 'password_submit',
|
||||
});
|
||||
}
|
||||
if (transition.action === 'recoverable') {
|
||||
log(`步骤 7:${transition.result.message || '提交密码后仍未进入登录验证码页面,准备重新执行步骤 7。'}`, 'warn');
|
||||
log(transition.result.message || `提交密码后仍未进入登录验证码页面,准备重新执行步骤 ${visibleStep}。`, 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return transition.result;
|
||||
}
|
||||
if (transition.action === 'password') {
|
||||
@@ -3058,6 +3084,7 @@ async function step6LoginFromPasswordPage(payload, snapshot) {
|
||||
}
|
||||
|
||||
async function step6LoginFromEmailPage(payload, snapshot) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 7;
|
||||
const currentSnapshot = normalizeStep6Snapshot(snapshot || inspectLoginAuthState());
|
||||
const emailInput = currentSnapshot.emailInput || getLoginEmailInput();
|
||||
if (!emailInput) {
|
||||
@@ -3067,29 +3094,29 @@ async function step6LoginFromEmailPage(payload, snapshot) {
|
||||
if ((emailInput.value || '').trim() !== payload.email) {
|
||||
await humanPause(500, 1400);
|
||||
fillInput(emailInput, payload.email);
|
||||
log('步骤 7:已填写邮箱');
|
||||
log('已填写邮箱', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
} else {
|
||||
log('步骤 7:邮箱已在输入框中,准备提交...');
|
||||
log('邮箱已在输入框中,准备提交...', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
}
|
||||
|
||||
await sleep(500);
|
||||
const emailSubmittedAt = Date.now();
|
||||
await triggerLoginSubmitAction(currentSnapshot.submitButton, emailInput);
|
||||
log('步骤 7:已提交邮箱');
|
||||
log('已提交邮箱', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
|
||||
const transition = await waitForStep6EmailSubmitTransition(emailSubmittedAt);
|
||||
const transition = await waitForStep6EmailSubmitTransition(emailSubmittedAt, 12000, { visibleStep });
|
||||
if (transition.action === 'done') {
|
||||
if (transition.result?.skipLoginVerificationStep) {
|
||||
return transition.result;
|
||||
}
|
||||
return finalizeStep6VerificationReady({
|
||||
logLabel: '步骤 7 收尾',
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: transition.result.loginVerificationRequestedAt || emailSubmittedAt,
|
||||
via: transition.result.via || 'email_submit',
|
||||
});
|
||||
}
|
||||
if (transition.action === 'recoverable') {
|
||||
log(`步骤 7:${transition.result.message || '提交邮箱后仍未进入目标页面,准备重新执行步骤 7。'}`, 'warn');
|
||||
log(transition.result.message || `提交邮箱后仍未进入目标页面,准备重新执行步骤 ${visibleStep}。`, 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return transition.result;
|
||||
}
|
||||
if (transition.action === 'email') {
|
||||
@@ -3105,34 +3132,36 @@ async function step6LoginFromEmailPage(payload, snapshot) {
|
||||
}
|
||||
|
||||
async function step6_login(payload) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 7;
|
||||
const { email } = payload;
|
||||
if (!email) throw new Error('登录时缺少邮箱地址。');
|
||||
|
||||
const snapshot = normalizeStep6Snapshot(await waitForKnownLoginAuthState(15000));
|
||||
|
||||
if (snapshot.state === 'verification_page') {
|
||||
log('步骤 7:认证页已在登录验证码页,开始确认页面是否稳定。');
|
||||
log('认证页已在登录验证码页,开始确认页面是否稳定。', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return finalizeStep6VerificationReady({
|
||||
logLabel: '步骤 7 收尾',
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: null,
|
||||
via: 'already_on_verification_page',
|
||||
});
|
||||
}
|
||||
|
||||
if (snapshot.state === 'oauth_consent_page') {
|
||||
log('步骤 7:认证页已直接进入 OAuth 授权页,跳过登录验证码步骤。', 'ok');
|
||||
log('认证页已直接进入 OAuth 授权页,跳过登录验证码步骤。', 'ok', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return createStep6OAuthConsentSuccessResult(snapshot, {
|
||||
via: 'already_on_oauth_consent_page',
|
||||
});
|
||||
}
|
||||
|
||||
if (snapshot.state === 'login_timeout_error_page') {
|
||||
log('步骤 7:检测到登录超时报错页,先尝试恢复当前页面。', 'warn');
|
||||
log('检测到登录超时报错页,先尝试恢复当前页面。', 'warn', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
const transition = await createStep6LoginTimeoutRecoveryTransition(
|
||||
'login_timeout_error_page',
|
||||
snapshot,
|
||||
'当前页面处于登录超时报错页。',
|
||||
{
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: null,
|
||||
via: 'login_timeout_initial_recovered',
|
||||
}
|
||||
@@ -3142,7 +3171,7 @@ async function step6_login(payload) {
|
||||
return transition.result;
|
||||
}
|
||||
return finalizeStep6VerificationReady({
|
||||
logLabel: '步骤 7 收尾',
|
||||
visibleStep,
|
||||
loginVerificationRequestedAt: transition.result.loginVerificationRequestedAt || null,
|
||||
via: transition.result.via || 'login_timeout_initial_recovered',
|
||||
});
|
||||
@@ -3157,12 +3186,12 @@ async function step6_login(payload) {
|
||||
}
|
||||
|
||||
if (snapshot.state === 'email_page') {
|
||||
log(`步骤 7:正在使用 ${email} 登录...`);
|
||||
log(`正在使用 ${email} 登录...`, 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return step6LoginFromEmailPage(payload, snapshot);
|
||||
}
|
||||
|
||||
if (snapshot.state === 'password_page') {
|
||||
log('步骤 7:认证页已在密码页,继续当前登录流程。');
|
||||
log('认证页已在密码页,继续当前登录流程。', 'info', { step: visibleStep, stepKey: 'oauth-login' });
|
||||
return step6LoginFromPasswordPage(payload, snapshot);
|
||||
}
|
||||
|
||||
@@ -3170,7 +3199,7 @@ async function step6_login(payload) {
|
||||
return step6OpenLoginEntry(payload, snapshot);
|
||||
}
|
||||
|
||||
throwForStep6FatalState(snapshot);
|
||||
throwForStep6FatalState(snapshot, visibleStep);
|
||||
throw new Error(`无法识别当前登录页面状态。URL: ${snapshot?.url || location.href}`);
|
||||
}
|
||||
|
||||
@@ -3181,13 +3210,14 @@ async function step6_login(payload) {
|
||||
// "使用 ChatGPT 登录到 Codex" with a "继续" submit button.
|
||||
// Background performs the actual click through the debugger Input API.
|
||||
|
||||
async function step8_findAndClick() {
|
||||
log('步骤 9:正在查找 OAuth 同意页的“继续”按钮...');
|
||||
async function step8_findAndClick(payload = {}) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 9;
|
||||
log('正在查找 OAuth 同意页的“继续”按钮...', 'info', { step: visibleStep, stepKey: 'confirm-oauth' });
|
||||
|
||||
const continueBtn = await prepareStep8ContinueButton();
|
||||
|
||||
const rect = getSerializableRect(continueBtn);
|
||||
log('步骤 9:已找到“继续”按钮并准备好调试器点击坐标。');
|
||||
log('已找到“继续”按钮并准备好调试器点击坐标。', 'info', { step: visibleStep, stepKey: 'confirm-oauth' });
|
||||
return {
|
||||
rect,
|
||||
buttonText: (continueBtn.textContent || '').trim(),
|
||||
@@ -3227,6 +3257,7 @@ function getStep8State() {
|
||||
}
|
||||
|
||||
async function step8_triggerContinue(payload = {}) {
|
||||
const visibleStep = Math.floor(Number(payload?.visibleStep) || 0) || 9;
|
||||
const strategy = payload?.strategy || 'requestSubmit';
|
||||
const continueBtn = await prepareStep8ContinueButton({
|
||||
findTimeoutMs: payload?.findTimeoutMs,
|
||||
@@ -3248,10 +3279,10 @@ async function step8_triggerContinue(payload = {}) {
|
||||
simulateClick(continueBtn);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`未知的 Step 9 触发策略:${strategy}`);
|
||||
throw new Error(`未知的 Step ${visibleStep} 触发策略:${strategy}`);
|
||||
}
|
||||
|
||||
log(`Step 9: continue button triggered via ${strategy}.`);
|
||||
log(`continue button triggered via ${strategy}.`, 'info', { step: visibleStep, stepKey: 'confirm-oauth' });
|
||||
return {
|
||||
strategy,
|
||||
...getStep8State(),
|
||||
|
||||
@@ -24,7 +24,7 @@ if (document.documentElement.getAttribute(SUB2API_PANEL_LISTENER_SENTINEL) !== '
|
||||
}).catch((err) => {
|
||||
if (isStopError(err)) {
|
||||
if (message.step) {
|
||||
log(`步骤 ${message.step}:已被用户停止。`, 'warn');
|
||||
log('已被用户停止。', 'warn', { step: message.step });
|
||||
}
|
||||
sendResponse({ stopped: true, error: err.message });
|
||||
return;
|
||||
@@ -352,7 +352,7 @@ function extractStateFromAuthUrl(authUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseLocalhostCallback(rawUrl) {
|
||||
function parseLocalhostCallback(rawUrl, visibleStep = 10) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = new URL(rawUrl);
|
||||
@@ -364,7 +364,7 @@ function parseLocalhostCallback(rawUrl) {
|
||||
throw new Error('回调 URL 协议不正确。');
|
||||
}
|
||||
if (!['localhost', '127.0.0.1'].includes(parsed.hostname)) {
|
||||
throw new Error('步骤 10 只接受 localhost / 127.0.0.1 回调地址。');
|
||||
throw new Error(`步骤 ${visibleStep} 只接受 localhost / 127.0.0.1 回调地址。`);
|
||||
}
|
||||
if (parsed.pathname !== '/auth/callback') {
|
||||
throw new Error('回调 URL 路径必须是 /auth/callback。');
|
||||
@@ -504,7 +504,7 @@ async function step1_generateOpenAiAuthUrl(payload = {}, options = {}) {
|
||||
|
||||
async function step9_submitOpenAiCallback(payload = {}) {
|
||||
const visibleStep = Number(payload?.visibleStep) || 10;
|
||||
const callback = parseLocalhostCallback(payload.localhostUrl || '');
|
||||
const callback = parseLocalhostCallback(payload.localhostUrl || '', visibleStep);
|
||||
const backgroundState = await getBackgroundState();
|
||||
const flowEmail = String(backgroundState.email || '').trim();
|
||||
|
||||
@@ -528,11 +528,11 @@ async function step9_submitOpenAiCallback(payload = {}) {
|
||||
throw new Error('本次 localhost 回调中的 state 与步骤 1 生成的 state 不一致,请重新执行步骤 1。');
|
||||
}
|
||||
|
||||
log(`步骤 ${visibleStep}:正在向 SUB2API 交换 OpenAI 授权码...`);
|
||||
log('正在向 SUB2API 交换 OpenAI 授权码...', 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
if (proxy) {
|
||||
log(`步骤 ${visibleStep}:使用 SUB2API 默认代理 ${buildProxyDisplayName(proxy)}。`);
|
||||
log(`使用 SUB2API 默认代理 ${buildProxyDisplayName(proxy)}。`, 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
} else {
|
||||
log(`步骤 ${visibleStep}:未配置 SUB2API 默认代理,本次将不使用代理。`);
|
||||
log('未配置 SUB2API 默认代理,本次将不使用代理。', 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
}
|
||||
const exchangeRequestBody = {
|
||||
session_id: sessionId,
|
||||
@@ -579,7 +579,7 @@ async function step9_submitOpenAiCallback(payload = {}) {
|
||||
createPayload.extra = extra;
|
||||
}
|
||||
|
||||
log(`步骤 ${visibleStep}:授权码交换成功,正在创建 SUB2API 账号(名称:${accountName})...`);
|
||||
log(`授权码交换成功,正在创建 SUB2API 账号(名称:${accountName})...`, 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
const createdAccount = await requestJson(origin, '/api/v1/admin/accounts', {
|
||||
method: 'POST',
|
||||
token,
|
||||
@@ -587,7 +587,7 @@ async function step9_submitOpenAiCallback(payload = {}) {
|
||||
});
|
||||
|
||||
const verifiedStatus = `SUB2API 已创建账号 #${createdAccount?.id || 'unknown'}`;
|
||||
log(`步骤 ${visibleStep}:${verifiedStatus}`, 'ok');
|
||||
log(verifiedStatus, 'ok', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
reportComplete(visibleStep, {
|
||||
localhostUrl: callback.url,
|
||||
verifiedStatus,
|
||||
|
||||
+18
-5
@@ -262,17 +262,30 @@ function fillSelect(el, value) {
|
||||
log(`已选择 [${el.name || el.id || '未知'}] = ${value}`);
|
||||
}
|
||||
|
||||
function normalizeLogStep(value) {
|
||||
const step = Math.floor(Number(value) || 0);
|
||||
return step > 0 ? step : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a log message to Side Panel via Background.
|
||||
* @param {string} message
|
||||
* @param {string} level - 'info' | 'ok' | 'warn' | 'error'
|
||||
* @param {{ step?: number, stepKey?: string }} options
|
||||
*/
|
||||
function log(message, level = 'info') {
|
||||
function log(message, level = 'info', options = {}) {
|
||||
const step = normalizeLogStep(options?.step);
|
||||
chrome.runtime.sendMessage({
|
||||
type: 'LOG',
|
||||
source: getRuntimeScriptSource(),
|
||||
step: null,
|
||||
payload: { message, level, timestamp: Date.now() },
|
||||
step,
|
||||
payload: {
|
||||
message: String(message || ''),
|
||||
level,
|
||||
timestamp: Date.now(),
|
||||
step,
|
||||
stepKey: String(options?.stepKey || '').trim(),
|
||||
},
|
||||
error: null,
|
||||
});
|
||||
}
|
||||
@@ -305,7 +318,7 @@ function reportReady() {
|
||||
*/
|
||||
function reportComplete(step, data = {}) {
|
||||
console.log(LOG_PREFIX, `步骤 ${step} 已完成`, data);
|
||||
log(`步骤 ${step} 已成功完成`, 'ok');
|
||||
log('已成功完成', 'ok', { step });
|
||||
const message = {
|
||||
type: 'STEP_COMPLETE',
|
||||
source: getRuntimeScriptSource(),
|
||||
@@ -336,7 +349,7 @@ function reportComplete(step, data = {}) {
|
||||
*/
|
||||
function reportError(step, errorMessage) {
|
||||
console.error(LOG_PREFIX, `步骤 ${step} 失败: ${errorMessage}`);
|
||||
log(`步骤 ${step} 失败:${errorMessage}`, 'error');
|
||||
log(`失败:${errorMessage}`, 'error', { step });
|
||||
const message = {
|
||||
type: 'STEP_ERROR',
|
||||
source: getRuntimeScriptSource(),
|
||||
|
||||
+20
-17
@@ -66,7 +66,7 @@ if (document.documentElement.getAttribute(VPS_PANEL_LISTENER_SENTINEL) !== '1')
|
||||
});
|
||||
if (isStopError(err)) {
|
||||
if (message.step) {
|
||||
log(`步骤 ${message.step}:已被用户停止。`, 'warn');
|
||||
log('已被用户停止。', 'warn', { step: message.step });
|
||||
}
|
||||
sendResponse({ stopped: true, error: err.message });
|
||||
return;
|
||||
@@ -88,6 +88,7 @@ async function handleStep(step, payload) {
|
||||
case 1: return await step1_getOAuthLink(payload);
|
||||
case 10:
|
||||
case 12:
|
||||
case 13:
|
||||
return await step9_vpsVerify({ ...(payload || {}), visibleStep: step });
|
||||
default:
|
||||
throw new Error(`vps-panel.js 不处理步骤 ${step}`);
|
||||
@@ -618,7 +619,7 @@ function explainStep10Failure(statusText, sourceKind = 'unknown') {
|
||||
{
|
||||
code: 'oauth_state_mismatch',
|
||||
pattern: /state code error/i,
|
||||
message: 'CPA 校验到回调里的 state 与当前 OAuth 会话不一致,通常是步骤 1 已刷新过新的授权链接,但步骤 10 仍提交旧回调。',
|
||||
message: 'CPA 校验到回调里的 state 与当前 OAuth 会话不一致,通常是授权链接已刷新,但平台回调验证仍提交旧回调。',
|
||||
},
|
||||
{
|
||||
code: 'oauth_code_exchange_failed',
|
||||
@@ -666,7 +667,7 @@ function explainStep10Failure(statusText, sourceKind = 'unknown') {
|
||||
};
|
||||
}
|
||||
|
||||
async function waitForExactSuccessBadge(timeout = STEP9_SUCCESS_BADGE_TIMEOUT_MS) {
|
||||
async function waitForExactSuccessBadge(timeout = STEP9_SUCCESS_BADGE_TIMEOUT_MS, visibleStep = 10) {
|
||||
const start = Date.now();
|
||||
let lastDiagnosticsSignature = '';
|
||||
let lastHeartbeatLoggedAt = 0;
|
||||
@@ -681,11 +682,11 @@ async function waitForExactSuccessBadge(timeout = STEP9_SUCCESS_BADGE_TIMEOUT_MS
|
||||
if (diagnostics.signature !== lastDiagnosticsSignature) {
|
||||
lastDiagnosticsSignature = diagnostics.signature;
|
||||
lastHeartbeatLoggedAt = elapsed;
|
||||
log(`步骤 10:认证状态检测中,${diagnostics.summary}`);
|
||||
log(`认证状态检测中,${diagnostics.summary}`, 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
console.log(LOG_PREFIX, '[Step 9] status badge diagnostics changed', diagnostics);
|
||||
} else if (elapsed - lastHeartbeatLoggedAt >= 10000) {
|
||||
lastHeartbeatLoggedAt = elapsed;
|
||||
log(`步骤 10:仍在等待认证成功,${diagnostics.summary}`);
|
||||
log(`仍在等待认证成功,${diagnostics.summary}`, 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
console.log(LOG_PREFIX, '[Step 9] still waiting for success badge', diagnostics);
|
||||
}
|
||||
|
||||
@@ -697,8 +698,9 @@ async function waitForExactSuccessBadge(timeout = STEP9_SUCCESS_BADGE_TIMEOUT_MS
|
||||
if (callbackSubmittedSignature !== lastCallbackSubmittedSignature) {
|
||||
lastCallbackSubmittedSignature = callbackSubmittedSignature;
|
||||
log(
|
||||
`步骤 10:CPA 已接受 localhost 回调,正在等待后台完成认证。回调提示=${formatStep10StatusSummaryValue(diagnostics.callbackStatusText)};主状态=${formatStep10StatusSummaryValue(diagnostics.mainStatusText)}`,
|
||||
'info'
|
||||
`CPA 已接受 localhost 回调,正在等待后台完成认证。回调提示=${formatStep10StatusSummaryValue(diagnostics.callbackStatusText)};主状态=${formatStep10StatusSummaryValue(diagnostics.mainStatusText)}`,
|
||||
'info',
|
||||
{ step: visibleStep, stepKey: 'platform-verify' }
|
||||
);
|
||||
console.info(LOG_PREFIX, '[Step 9] callback accepted and waiting for auth completion', diagnostics);
|
||||
}
|
||||
@@ -706,7 +708,7 @@ async function waitForExactSuccessBadge(timeout = STEP9_SUCCESS_BADGE_TIMEOUT_MS
|
||||
|
||||
if (isStep10BrowserSwitchRequiredConflict(diagnostics)) {
|
||||
const browserSwitchMessage = getStep10BrowserSwitchRequiredMessage(diagnostics);
|
||||
log(`步骤 10:${browserSwitchMessage}`, 'error');
|
||||
log(browserSwitchMessage, 'error', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
console.error(LOG_PREFIX, '[Step 9] browser-switch conflict detected', diagnostics);
|
||||
throw new Error(`BROWSER_SWITCH_REQUIRED::${browserSwitchMessage}`);
|
||||
}
|
||||
@@ -723,8 +725,9 @@ async function waitForExactSuccessBadge(timeout = STEP9_SUCCESS_BADGE_TIMEOUT_MS
|
||||
? diagnostics.pageErrorSummary
|
||||
: diagnostics.failureSummary;
|
||||
log(
|
||||
`步骤 10:同时检测到成功徽标和失败提示,本轮不判定成功。成功徽标:${diagnostics.exactSuccessSummary};失败提示:${failureSummary}`,
|
||||
'warn'
|
||||
`同时检测到成功徽标和失败提示,本轮不判定成功。成功徽标:${diagnostics.exactSuccessSummary};失败提示:${failureSummary}`,
|
||||
'warn',
|
||||
{ step: visibleStep, stepKey: 'platform-verify' }
|
||||
);
|
||||
console.warn(LOG_PREFIX, '[Step 9] success badge is blocked by visible failure', diagnostics);
|
||||
}
|
||||
@@ -1021,7 +1024,7 @@ async function step9_vpsVerify(payload) {
|
||||
throw new Error(`步骤 ${visibleStep} 只接受真实的 localhost OAuth 回调地址,请重新执行步骤 ${confirmStep}。`);
|
||||
}
|
||||
if (!localhostUrl) {
|
||||
log(`步骤 ${visibleStep}:payload 中没有 localhostUrl,正在从状态中读取...`);
|
||||
log('payload 中没有 localhostUrl,正在从状态中读取...', 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
const state = await chrome.runtime.sendMessage({ type: 'GET_STATE' });
|
||||
localhostUrl = state.localhostUrl;
|
||||
if (localhostUrl && !isLocalhostOAuthCallbackUrl(localhostUrl)) {
|
||||
@@ -1031,9 +1034,9 @@ async function step9_vpsVerify(payload) {
|
||||
if (!localhostUrl) {
|
||||
throw new Error(`未找到 localhost 回调地址,请先完成步骤 ${confirmStep}。`);
|
||||
}
|
||||
log(`步骤 ${visibleStep}:已获取 localhostUrl:${localhostUrl.slice(0, 60)}...`);
|
||||
log(`已获取 localhostUrl:${localhostUrl.slice(0, 60)}...`, 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
|
||||
log(`步骤 ${visibleStep}:正在查找回调地址输入框...`);
|
||||
log('正在查找回调地址输入框...', 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
|
||||
// Find the callback URL input
|
||||
// Actual DOM: <input class="input" placeholder="http://localhost:1455/auth/callback?code=...&state=...">
|
||||
@@ -1050,7 +1053,7 @@ async function step9_vpsVerify(payload) {
|
||||
|
||||
await humanPause(600, 1500);
|
||||
fillInput(urlInput, localhostUrl);
|
||||
log(`步骤 ${visibleStep}:已填写回调地址:${localhostUrl.slice(0, 80)}...`);
|
||||
log(`已填写回调地址:${localhostUrl.slice(0, 80)}...`, 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
|
||||
// Find and click the callback submit button in supported UI languages.
|
||||
const callbackSubmitPattern = /提交回调\s*URL|Submit\s+Callback\s+URL|Отправить\s+Callback\s+URL/i;
|
||||
@@ -1071,9 +1074,9 @@ async function step9_vpsVerify(payload) {
|
||||
|
||||
await humanPause(450, 1200);
|
||||
simulateClick(submitBtn);
|
||||
log(`步骤 ${visibleStep}:已点击回调提交按钮,正在等待认证结果...`);
|
||||
log('已点击回调提交按钮,正在等待认证结果...', 'info', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
|
||||
const verifiedStatus = await waitForExactSuccessBadge();
|
||||
log(`步骤 ${visibleStep}:${verifiedStatus}`, 'ok');
|
||||
const verifiedStatus = await waitForExactSuccessBadge(STEP9_SUCCESS_BADGE_TIMEOUT_MS, visibleStep);
|
||||
log(verifiedStatus, 'ok', { step: visibleStep, stepKey: 'platform-verify' });
|
||||
reportComplete(visibleStep, { localhostUrl, verifiedStatus });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user