feat: 更新2925邮箱邮件提取逻辑,增强对右侧邮件头的处理与测试
This commit is contained in:
@@ -534,6 +534,9 @@ function detectMail2925ViewState() {
|
|||||||
|
|
||||||
function getMail2925DisplayedMailboxEmail() {
|
function getMail2925DisplayedMailboxEmail() {
|
||||||
const directSelectors = [
|
const directSelectors = [
|
||||||
|
'.right-header',
|
||||||
|
'[class~="right-header"]',
|
||||||
|
'[class*="right-header"]',
|
||||||
'[class*="user"] [class*="mail"]',
|
'[class*="user"] [class*="mail"]',
|
||||||
'[class*="user"] [class*="email"]',
|
'[class*="user"] [class*="email"]',
|
||||||
'[class*="account"] [class*="mail"]',
|
'[class*="account"] [class*="mail"]',
|
||||||
@@ -548,7 +551,8 @@ function getMail2925DisplayedMailboxEmail() {
|
|||||||
if (!isVisibleNode(candidate) || isMailItemNode(candidate)) {
|
if (!isVisibleNode(candidate) || isMailItemNode(candidate)) {
|
||||||
continue;
|
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) {
|
if (email) {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
@@ -567,7 +571,8 @@ function getMail2925DisplayedMailboxEmail() {
|
|||||||
return rect.top >= 0 && rect.top <= Math.max(window.innerHeight * 0.35, 280);
|
return rect.top >= 0 && rect.top <= Math.max(window.innerHeight * 0.35, 280);
|
||||||
})
|
})
|
||||||
.map((node) => {
|
.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 };
|
return { node, email };
|
||||||
})
|
})
|
||||||
.filter((entry) => entry.email);
|
.filter((entry) => entry.email);
|
||||||
|
|||||||
@@ -32,13 +32,14 @@ const MAIL2925_AGREEMENT_PATTERNS = [];
|
|||||||
const document = {
|
const document = {
|
||||||
querySelectorAll(selector) {
|
querySelectorAll(selector) {
|
||||||
if (selector === '.mail-item') return [];
|
if (selector === '.mail-item') return [];
|
||||||
if (selector === 'body *') return [headerEmail];
|
if (selector === 'body *') return [headerEmail, wrongHeader];
|
||||||
if (selector.includes('[class*="user"]')) return [headerEmail];
|
if (selector === '.right-header' || selector.includes('right-header')) return [headerEmail];
|
||||||
|
if (selector.includes('[class*="user"]')) return [];
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
innerText: 'QLHazycoder qlhazycoder@2925.com',
|
innerText: 'QLHazycoder qlhazycoder@2925.com tm1.openai.com@foo.example',
|
||||||
textContent: 'QLHazycoder qlhazycoder@2925.com',
|
textContent: 'QLHazycoder qlhazycoder@2925.com tm1.openai.com@foo.example',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const window = {
|
const window = {
|
||||||
@@ -54,6 +55,13 @@ const headerEmail = {
|
|||||||
getBoundingClientRect() { return { top: 40, left: 400, width: 120, height: 20 }; },
|
getBoundingClientRect() { return { top: 40, left: 400, width: 120, height: 20 }; },
|
||||||
closest() { return null; },
|
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 detectMail2925LimitMessage() { return ''; }
|
||||||
function findMail2925LoginPasswordInput() { return null; }
|
function findMail2925LoginPasswordInput() { return null; }
|
||||||
function findMail2925LoginEmailInput() { return null; }
|
function findMail2925LoginEmailInput() { return null; }
|
||||||
|
|||||||
Reference in New Issue
Block a user