-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
30 lines (24 loc) · 823 Bytes
/
Copy pathcontent.js
File metadata and controls
30 lines (24 loc) · 823 Bytes
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
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'getEmailBody') {
let emailBody = '';
const selectors = [
'.ii.gt',
'.a3s.aXjCH',
'div[role="main"] .a3s',
'.gs',
'div[role="listitem"] .a3s'
];
for (const selector of selectors) {
const elem = document.querySelector(selector);
// Check for a minimum length (e.g., 50 chars) to skip empty or signature blocks
if (elem && elem.innerText.trim().length > 50) {
emailBody = elem.innerText.trim();
break;
}
}
// Debug log
console.log('Extracted Email Body (first 100 chars):', emailBody.substring(0, 100));
sendResponse({ emailBody });
}
return true;
});