新增TG自定义是否显示文本消息

This commit is contained in:
eoao
2025-10-23 23:55:00 +08:00
parent 7980e6a444
commit a4a1db22e8
8 changed files with 52 additions and 13 deletions

View File

@@ -15,9 +15,16 @@ const emailUtils = {
},
htmlToText(content) {
const { document } = parseHTML(content);
document.querySelectorAll('style, script, title').forEach(el => el.remove());
return document.documentElement.innerText;
if (!content) return ''
try {
const { document } = parseHTML(content);
document.querySelectorAll('style, script, title').forEach(el => el.remove());
let text = document.body.innerText;
return text.trim();
} catch (e) {
console.error(e)
return ''
}
}
};