From 37f6453ddabd8cf74e3c1545fe74155fe87e713e Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Wed, 15 Apr 2026 10:27:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=92=8C=E5=8C=B9=E9=85=8D=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E7=AE=80=E5=8C=96=E7=9B=AE=E6=A0=87=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/gmail-mail.js | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/content/gmail-mail.js b/content/gmail-mail.js index d40efe9..3c14ebd 100644 --- a/content/gmail-mail.js +++ b/content/gmail-mail.js @@ -77,17 +77,6 @@ function normalizeMinuteTimestamp(timestamp) { return date.getTime(); } -function extractEmails(text) { - const matches = String(text || '').match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/ig) || []; - return [...new Set(matches.map((item) => item.toLowerCase()))]; -} - -function emailMatchesTarget(candidate, targetEmail) { - const normalizedCandidate = String(candidate || '').trim().toLowerCase(); - const normalizedTarget = String(targetEmail || '').trim().toLowerCase(); - return Boolean(normalizedCandidate && normalizedTarget && normalizedCandidate === normalizedTarget); -} - function getTargetEmailMatchState(text, targetEmail) { const normalizedTarget = String(targetEmail || '').trim().toLowerCase(); if (!normalizedTarget) { @@ -106,16 +95,7 @@ function getTargetEmailMatchState(text, targetEmail) { return { matches: true, hasExplicitEmail: true }; } } - - const emails = extractEmails(text); - if (!emails.length) { - return { matches: false, hasExplicitEmail: false }; - } - - return { - matches: emails.some((email) => emailMatchesTarget(email, normalizedTarget)), - hasExplicitEmail: true, - }; + return { matches: false, hasExplicitEmail: false }; } const MONTH_INDEX_MAP = { @@ -528,13 +508,8 @@ async function handlePollEmail(step, payload) { } const previewTargetState = getTargetEmailMatchState(preview.combinedText, targetEmail); - const previewEmails = extractEmails(preview.combinedText); - if (targetEmail && previewEmails.length > 0 && !previewTargetState.matches) { - continue; - } - const previewCode = extractVerificationCode(preview.combinedText); - if (previewCode && previewTargetState.matches) { + if (previewCode) { if (excludedCodeSet.has(previewCode)) { log(`步骤 ${step}:跳过排除的验证码:${previewCode}`, 'info'); continue; @@ -547,7 +522,8 @@ async function handlePollEmail(step, payload) { persistSeenCodes(); const source = useFallback && existingMailIds.has(rowId) ? '回退匹配邮件' : '新邮件'; const timeLabel = rowTimestamp ? `,时间:${new Date(rowTimestamp).toLocaleString('zh-CN', { hour12: false })}` : ''; - log(`步骤 ${step}:已在 Gmail 找到验证码:${previewCode}(来源:${source}${timeLabel})`, 'ok'); + const targetLabel = previewTargetState.matches ? ',目标邮箱命中' : ''; + log(`步骤 ${step}:已在 Gmail 找到验证码:${previewCode}(来源:${source}${timeLabel}${targetLabel})`, 'ok'); return { ok: true, code: previewCode, @@ -558,10 +534,6 @@ async function handlePollEmail(step, payload) { const openedText = await openRowAndGetMessageText(row); const openedTargetState = getTargetEmailMatchState(openedText, targetEmail); - if (targetEmail && openedTargetState.hasExplicitEmail && !openedTargetState.matches) { - continue; - } - const bodyCode = extractVerificationCode(openedText); if (!bodyCode) { continue; @@ -578,7 +550,8 @@ async function handlePollEmail(step, payload) { persistSeenCodes(); const source = useFallback && existingMailIds.has(rowId) ? '回退匹配邮件正文' : '新邮件正文'; const timeLabel = rowTimestamp ? `,时间:${new Date(rowTimestamp).toLocaleString('zh-CN', { hour12: false })}` : ''; - log(`步骤 ${step}:已在 Gmail 正文中找到验证码:${bodyCode}(来源:${source}${timeLabel})`, 'ok'); + const targetLabel = openedTargetState.matches ? ',目标邮箱命中' : ''; + log(`步骤 ${step}:已在 Gmail 正文中找到验证码:${bodyCode}(来源:${source}${timeLabel}${targetLabel})`, 'ok'); return { ok: true, code: bodyCode,