From 7ba9e609ab86bb147f6a20a920375e7889e81118 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Thu, 23 Apr 2026 00:45:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B02925=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E9=82=AE=E4=BB=B6=E6=8F=90=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=BC=BA=E5=AF=B9=E5=8F=B3=E4=BE=A7=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E5=A4=B4=E7=9A=84=E5=A4=84=E7=90=86=E4=B8=8E=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/mail-2925.js | 9 +++++++-- tests/mail-2925-content.test.js | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/content/mail-2925.js b/content/mail-2925.js index 09e9581..4263f87 100644 --- a/content/mail-2925.js +++ b/content/mail-2925.js @@ -534,6 +534,9 @@ function detectMail2925ViewState() { function getMail2925DisplayedMailboxEmail() { const directSelectors = [ + '.right-header', + '[class~="right-header"]', + '[class*="right-header"]', '[class*="user"] [class*="mail"]', '[class*="user"] [class*="email"]', '[class*="account"] [class*="mail"]', @@ -548,7 +551,8 @@ function getMail2925DisplayedMailboxEmail() { if (!isVisibleNode(candidate) || isMailItemNode(candidate)) { continue; } - const email = extractEmails(candidate.textContent || candidate.innerText || '')[0] || ''; + const email = extractEmails(candidate.textContent || candidate.innerText || '') + .find((value) => /@2925\.com$/i.test(String(value || '').trim())) || ''; if (email) { return email; } @@ -567,7 +571,8 @@ function getMail2925DisplayedMailboxEmail() { return rect.top >= 0 && rect.top <= Math.max(window.innerHeight * 0.35, 280); }) .map((node) => { - const email = extractEmails(node.textContent || node.innerText || '')[0] || ''; + const email = extractEmails(node.textContent || node.innerText || '') + .find((value) => /@2925\.com$/i.test(String(value || '').trim())) || ''; return { node, email }; }) .filter((entry) => entry.email); diff --git a/tests/mail-2925-content.test.js b/tests/mail-2925-content.test.js index e36e182..f923d7f 100644 --- a/tests/mail-2925-content.test.js +++ b/tests/mail-2925-content.test.js @@ -32,13 +32,14 @@ const MAIL2925_AGREEMENT_PATTERNS = []; const document = { querySelectorAll(selector) { if (selector === '.mail-item') return []; - if (selector === 'body *') return [headerEmail]; - if (selector.includes('[class*="user"]')) return [headerEmail]; + if (selector === 'body *') return [headerEmail, wrongHeader]; + if (selector === '.right-header' || selector.includes('right-header')) return [headerEmail]; + if (selector.includes('[class*="user"]')) return []; return []; }, body: { - innerText: 'QLHazycoder qlhazycoder@2925.com', - textContent: 'QLHazycoder qlhazycoder@2925.com', + innerText: 'QLHazycoder qlhazycoder@2925.com tm1.openai.com@foo.example', + textContent: 'QLHazycoder qlhazycoder@2925.com tm1.openai.com@foo.example', }, }; const window = { @@ -54,6 +55,13 @@ const headerEmail = { getBoundingClientRect() { return { top: 40, left: 400, width: 120, height: 20 }; }, closest() { return null; }, }; +const wrongHeader = { + hidden: false, + textContent: 'tm1.openai.com@foo.example', + innerText: 'tm1.openai.com@foo.example', + getBoundingClientRect() { return { top: 48, left: 430, width: 150, height: 20 }; }, + closest() { return null; }, +}; function detectMail2925LimitMessage() { return ''; } function findMail2925LoginPasswordInput() { return null; } function findMail2925LoginEmailInput() { return null; }