-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
31 lines (25 loc) · 1.1 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function extractEmailContent() {
const subjectElement = document.querySelector('h2[data-thread-perm-id]');
const fromElement = document.querySelector('.gD');
const toRecipients = document.querySelectorAll('.gD[email]');
const ccRecipients = document.querySelectorAll('.cc-recipient');
const bccRecipients = document.querySelectorAll('.bcc-recipient');
const bodyElement = document.querySelector('.a3s.aiL');
const subjectText = subjectElement?.innerText || "No subject found.";
const fromText = fromElement?.getAttribute('email') || "No sender found.";
const bodyText = bodyElement?.innerText || "No body found.";
const allRecipients = [
...Array.from(toRecipients).map(to => to.getAttribute('email')),
...Array.from(ccRecipients).map(cc => cc.getAttribute('email')),
...Array.from(bccRecipients).map(bcc => bcc.getAttribute('email'))
].filter(Boolean).join(', ');
const toText = allRecipients || "No recipients found.";
const emailContent = `
Subject: ${subjectText}
From: ${fromText}
To: ${toText}
Body:
${bodyText.trim()}
`.trim();
return emailContent;
}