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

Function resendVerificationCode

content/signup-page.js:198–249  ·  view source on GitHub ↗
(step, timeout = 45000)

Source from the content-addressed store, hash-verified

196}
197
198async function resendVerificationCode(step, timeout = 45000) {
199 if (step === 7) {
200 await waitForLoginVerificationPageReady();
201 }
202
203 const start = Date.now();
204 let action = null;
205 let loggedWaiting = false;
206
207 while (Date.now() - start < timeout) {
208 throwIfStopped();
209
210 // Check for 405 error page and recover by clicking "Try again"
211 if (is405MethodNotAllowedPage()) {
212 await handle405ResendError(step, timeout - (Date.now() - start));
213 // After recovery, loop back to find the resend button again
214 loggedWaiting = false;
215 continue;
216 }
217
218 action = findResendVerificationCodeTrigger({ allowDisabled: true });
219
220 if (action && isActionEnabled(action)) {
221 log(`步骤 ${step}:重新发送验证码按钮已可用。`);
222 await humanPause(350, 900);
223 simulateClick(action);
224 await sleep(1200);
225
226 // After clicking resend, check if 405 error appeared
227 if (is405MethodNotAllowedPage()) {
228 log(`步骤 ${step}:点击重新发送后出现 405 错误,正在恢复...`, 'warn');
229 await handle405ResendError(step, timeout - (Date.now() - start));
230 loggedWaiting = false;
231 continue;
232 }
233
234 return {
235 resent: true,
236 buttonText: getActionText(action),
237 };
238 }
239
240 if (action && !loggedWaiting) {
241 loggedWaiting = true;
242 log(`步骤 ${step}:正在等待重新发送验证码按钮变为可点击...`);
243 }
244
245 await sleep(250);
246 }
247
248 throw new Error('无法点击重新发送验证码按钮。URL: ' + location.href);
249}
250
251function is405MethodNotAllowedPage() {
252 const pageText = document.body?.textContent || '';

Callers 1

handleCommandFunction · 0.85

Calls 11

handle405ResendErrorFunction · 0.85
isActionEnabledFunction · 0.85
logFunction · 0.85
humanPauseFunction · 0.85
simulateClickFunction · 0.85
sleepFunction · 0.85
throwIfStoppedFunction · 0.70
getActionTextFunction · 0.70

Tested by

no test coverage detected