Files
FlowPilot/background/steps/step3.js
T
QLHazyCoder 4f12d67d9f feat: implement multi-step background process for user registration
- Add step 1: Open ChatGPT homepage and prepare for signup.
- Add step 2: Handle email submission and ensure the signup entry page is ready.
- Add step 3: Fill in the password using either a custom or generated password.
- Add step 4: Confirm the registration verification page and handle email verification.
- Add step 5: Generate random user details and handle onboarding redirection.
- Add step 6: Manage OAuth login process and handle login verification.
- Add step 7: Retrieve verification code from email and manage retries.
- Add step 8: Handle consent page interactions and manage callback URLs.
- Add step 9: Submit callback information to CPA or SUB2API based on user settings.
- Implement tests to ensure all steps are correctly imported and functional.
2026-04-16 23:38:43 +08:00

61 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function attachBackgroundStep3(root, factory) {
root.MultiPageBackgroundStep3 = factory();
})(typeof self !== 'undefined' ? self : globalThis, function createBackgroundStep3Module() {
function createStep3Executor(deps = {}) {
const {
addLog,
chrome,
ensureContentScriptReadyOnTab,
generatePassword,
getTabId,
isTabAlive,
sendToContentScript,
setPasswordState,
setState,
SIGNUP_PAGE_INJECT_FILES,
} = deps;
async function executeStep3(state) {
const resolvedEmail = state.email;
if (!resolvedEmail) {
throw new Error('缺少邮箱地址,请先完成步骤 2。');
}
const signupTabId = await getTabId('signup-page');
if (!signupTabId || !(await isTabAlive('signup-page'))) {
throw new Error('认证页面标签页已关闭,请先重新完成步骤 2。');
}
const password = state.customPassword || generatePassword();
await setPasswordState(password);
const accounts = state.accounts || [];
accounts.push({ email: resolvedEmail, password, createdAt: new Date().toISOString() });
await setState({ accounts });
await chrome.tabs.update(signupTabId, { active: true });
await ensureContentScriptReadyOnTab('signup-page', signupTabId, {
inject: SIGNUP_PAGE_INJECT_FILES,
injectSource: 'signup-page',
timeoutMs: 45000,
retryDelayMs: 900,
logMessage: '步骤 3:密码页内容脚本未就绪,正在等待页面恢复...',
});
await addLog(
`步骤 3:正在填写密码,邮箱为 ${resolvedEmail},密码为${state.customPassword ? '自定义' : '自动生成'}${password.length} 位)`
);
await sendToContentScript('signup-page', {
type: 'EXECUTE_STEP',
step: 3,
source: 'background',
payload: { email: resolvedEmail, password },
});
}
return { executeStep3 };
}
return { createStep3Executor };
});