fix: 输入提示词后加 1-3 秒随机延迟再发送(模拟人类停顿)

This commit is contained in:
2026-05-15 23:54:31 +08:00
parent 45c2d42905
commit d3cb3d6c25
2 changed files with 5 additions and 8 deletions
@@ -348,14 +348,6 @@ close 参数:
emit('progress', { step: 'connect', message: `Continuing session: ${sessionId} (mode: ${mode})` });
// Don't navigate — stay on the current chat page for multi-round
continuedSession = true;
// AIMD anti-ban delay: break fixed-interval pattern between successive requests
const baseDelay = parseInt(process.env.GEMINI_BASE_DELAY, 10) || 15;
const maxDelay = parseInt(process.env.GEMINI_MAX_DELAY, 10) || 120;
const jitter = Math.random() * 5;
const delaySec = Math.min(maxDelay, baseDelay * 0.7 + jitter);
emit('progress', { step: 'anti-ban', message: `AIMD delay ${delaySec.toFixed(1)}s (breaking fixed-interval pattern)` });
await sleep(delaySec * 1000);
} else if (args.chatUrl) {
emit('progress', { step: 'navigate', message: `Navigating to chat URL: ${args.chatUrl}` });
await page.goto(args.chatUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
@@ -432,6 +432,11 @@ export async function generate(page, { prompt, images, timeout, isContinuedSessi
emit({ type: 'progress', step: 'typing', message: 'Typing prompt...' });
await typePrompt(page, prompt);
// Human-like pause: wait 1-3 seconds before sending (simulates human reading/reviewing)
const pauseMs = 1000 + Math.random() * 2000;
log(`Human-like pause: ${(pauseMs / 1000).toFixed(1)}s before sending`);
await sleep(pauseMs);
// Step 4: Send
emit({ type: 'progress', step: 'sending', message: 'Sending prompt...' });
await sendPrompt(page);