在扩展中使用Mozilla firefox解析器(渲染引擎)

时间:2014-04-21 06:22:37

标签: security firefox web firefox-addon

我想构建一个Firefox扩展,它将使用Firefox解析器(渲染引擎)。我想将一些HTML数据提供给解析器,作为回报,它将分别给我HTML和java脚本内容。然后我会对它进行一些处理。有没有API或其他方法可以做到这一点?

1 个答案:

答案 0 :(得分:2)

你的意思是这样......

let s = "<i>cool</i><script>alert('cool!')</script>";
var parser = new DOMParser();
let doc = parser.parseFromString(s, "text/html");

//do whatever you want....
doc.body.appendChild(doc.createElement('hr'));
alert(doc.documentElement.outerHTML)
相关问题