MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / executeStep2

Function executeStep2

background/steps/submit-signup-email.js:19–66  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

17 } = deps;
18
19 async function executeStep2(state) {
20 const resolvedEmail = await resolveSignupEmailForFlow(state);
21
22 let signupTabId = await getTabId('signup-page');
23 if (!signupTabId || !(await isTabAlive('signup-page'))) {
24 await addLog('步骤 2:未发现可用的注册页标签,正在重新打开 ChatGPT 官网...', 'warn');
25 signupTabId = (await ensureSignupEntryPageReady(2)).tabId;
26 } else {
27 await chrome.tabs.update(signupTabId, { active: true });
28 await ensureContentScriptReadyOnTab('signup-page', signupTabId, {
29 inject: SIGNUP_PAGE_INJECT_FILES,
30 injectSource: 'signup-page',
31 timeoutMs: 45000,
32 retryDelayMs: 900,
33 logMessage: '步骤 2:注册入口页内容脚本未就绪,正在等待页面恢复...',
34 });
35 }
36
37 const step2Result = await sendToContentScriptResilient('signup-page', {
38 type: 'EXECUTE_STEP',
39 step: 2,
40 source: 'background',
41 payload: { email: resolvedEmail },
42 }, {
43 timeoutMs: 20000,
44 retryDelayMs: 700,
45 logMessage: '步骤 2:官网注册入口正在切换,等待页面恢复后继续输入邮箱...',
46 });
47
48 if (step2Result?.error) {
49 throw new Error(step2Result.error);
50 }
51
52 if (!step2Result?.alreadyOnPasswordPage) {
53 await addLog(`步骤 2:邮箱 ${resolvedEmail} 已提交,正在等待页面加载并确认下一步入口...`);
54 }
55
56 const landingResult = await ensureSignupPostEmailPageReadyInTab(signupTabId, 2, {
57 skipUrlWait: Boolean(step2Result?.alreadyOnPasswordPage),
58 });
59
60 await completeStepFromBackground(2, {
61 email: resolvedEmail,
62 nextSignupState: landingResult?.state || 'password_page',
63 nextSignupUrl: landingResult?.url || step2Result?.url || '',
64 skippedPasswordStep: landingResult?.state === 'verification_page',
65 });
66 }
67
68 return { executeStep2 };
69 }

Callers

nothing calls this directly

Calls 9

getTabIdFunction · 0.50
isTabAliveFunction · 0.50
addLogFunction · 0.50

Tested by

no test coverage detected