diff --git a/README.md b/README.md index 2ae6dd0..73215f4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ SMSBower Phone Fill Tool 本版已集成 FlowPilot 同款自动切号机制: - 悬浮窗打开后默认开启“自动切号:开”。 -- 页面提示“该电话/手机号已被使用、已绑定、已注册”时,插件会自动识别并切换下一个号码;旧号按被拒原因释放,新号自动填入并复制。 +- 页面提示“该电话/手机号已被使用、已绑定、已注册”时,只要确认是当前新号码触发的错误,插件会自动切换下一个号码;旧号按被拒原因释放,新号自动填入并复制。 - 页面提示“无法向此电话号码发送验证码”等发送失败时,插件会自动按可恢复失败换号。 - “检测报错换号”和“已使用换号”仍保留为手动兜底按钮。 - 仍然只负责填号/查码/复制,不自动点击目标页面继续按钮。 diff --git a/content.js b/content.js index 0aa1c2b..872fc34 100644 --- a/content.js +++ b/content.js @@ -33,10 +33,8 @@ let autoRotateTimer = null; let autoRotateInFlight = false; let autoRotateEnabled = true; - let lastAutoRotateSignature = ''; - let lastAutoRotateAt = 0; + let lastErroredPhoneNumber = ''; const AUTO_ROTATE_DEBOUNCE_MS = 800; - const AUTO_ROTATE_COOLDOWN_MS = 8000; function stopCodePolling() { codePollToken += 1; @@ -170,6 +168,7 @@ await copyText(phone); fillPhone(phone); $('.sb-current-phone').textContent = phone; + lastErroredPhoneNumber = ''; $('.sb-current-id').textContent = res.activation.activationId; const codeNode = $('.sb-current-code'); if (codeNode) codeNode.textContent = '无'; @@ -195,25 +194,21 @@ btn.classList.toggle('sb-auto-on', autoRotateEnabled); } - function buildAutoRotateSignature(reason, text) { - const compact = String(text || '').replace(/\s+/g, ' ').trim(); - return `${reason}:${compact.slice(-220)}`; + function getCurrentPhoneNumber() { + const phone = $('.sb-current-phone')?.textContent || latestSettings?.activeActivation?.phoneNumber || ''; + return String(phone).trim(); } async function rotateFromClassifiedError(classified, source = 'manual') { - const text = getPageTextForPhoneError(); - const signature = buildAutoRotateSignature(classified.reason, text); - const now = Date.now(); + const currentPhone = getCurrentPhoneNumber(); if (autoRotateInFlight) return false; - if (source === 'auto' && signature === lastAutoRotateSignature && now - lastAutoRotateAt < AUTO_ROTATE_COOLDOWN_MS) { - return false; - } + if (source === 'auto' && (!currentPhone || currentPhone === '无')) return false; + if (source === 'auto' && currentPhone === lastErroredPhoneNumber) return false; autoRotateInFlight = true; - lastAutoRotateSignature = signature; - lastAutoRotateAt = now; try { + lastErroredPhoneNumber = currentPhone; setStatus(source === 'auto' - ? `检测到${classified.reason === 'phone_number_used' ? '号码已使用' : '验证码发送失败'},正在自动切号...` + ? `当前号码 ${currentPhone} 触发${classified.reason === 'phone_number_used' ? '已使用' : '验证码发送失败'},正在自动切下一个号...` : '检测到手机号错误,正在切号...'); await fetchAndFill({ reason: classified.reason, releaseAction: classified.releaseAction, skipSave: true }); return true;