(options = {})
| 366 | } |
| 367 | |
| 368 | async function waitForSignupEntryState(options = {}) { |
| 369 | const { |
| 370 | timeout = 15000, |
| 371 | autoOpenEntry = false, |
| 372 | } = options; |
| 373 | const start = Date.now(); |
| 374 | let lastTriggerClickAt = 0; |
| 375 | |
| 376 | while (Date.now() - start < timeout) { |
| 377 | throwIfStopped(); |
| 378 | const snapshot = inspectSignupEntryState(); |
| 379 | |
| 380 | if (snapshot.state === 'password_page' || snapshot.state === 'email_entry') { |
| 381 | return snapshot; |
| 382 | } |
| 383 | |
| 384 | if (snapshot.state === 'entry_home') { |
| 385 | if (!autoOpenEntry) { |
| 386 | return snapshot; |
| 387 | } |
| 388 | |
| 389 | if (Date.now() - lastTriggerClickAt >= 1500) { |
| 390 | lastTriggerClickAt = Date.now(); |
| 391 | log('步骤 2:正在点击官网注册入口...'); |
| 392 | await humanPause(350, 900); |
| 393 | simulateClick(snapshot.signupTrigger); |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | await sleep(250); |
| 398 | } |
| 399 | |
| 400 | return inspectSignupEntryState(); |
| 401 | } |
| 402 | |
| 403 | async function ensureSignupEntryReady(timeout = 15000) { |
| 404 | const snapshot = await waitForSignupEntryState({ timeout, autoOpenEntry: false }); |
no test coverage detected