Improved outer tag removal.

This commit is contained in:
Yuhwan Kim
2024-06-02 05:05:41 +09:00
parent 3f78daf563
commit fe405c0ed2

View File

@@ -416,8 +416,8 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
// Serialize the DOM back to HTML
const serializer = new XMLSerializer();
let translatedHTML = serializer.serializeToString(dom);
// Remove the outer <body> tags
translatedHTML = translatedHTML.replace(/^<body[^>]*>|<\/body>$/g, '');
// Remove the outer <html|body|head> tags
translatedHTML = translatedHTML.replace(/<\/?(html|body|head)[^>]*>/g, '');
if(charArg !== ''){
let scripts:customscript[] = []