MCPcopy Index your code
hub / github.com/Bistutu/FluentRead / getTextWithNode

Function getTextWithNode

userscripts.js:992–1009  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

990
991// LLM 模式获取翻译文本
992function getTextWithNode(node) {
993 let text = "";
994 // 遍历所有子节点
995 node.childNodes.forEach(child => {
996 if (child.nodeType === Node.TEXT_NODE) {
997 // 文本节点:直接添加其文本
998 text += child.nodeValue;
999 } else if (child.nodeType === Node.ELEMENT_NODE) {
1000 // 检查是否为特定节点
1001 if (getTextWithNodeSet.has(child.tagName.toLowerCase())) {
1002 text += child.outerHTML; // 添加至 outerHTML
1003 } else {
1004 text += getTextWithNode(child); // 递归
1005 }
1006 }
1007 });
1008 return text;
1009}
1010
1011// endregion
1012

Callers 1

translateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected