Greasemonkey 在 document.implementation.createHTMLDocument().open() 上抛出 "DOMException: The operation is insecure."

Greasemonkey throws "DOMException: The operation is insecure." on document.implementation.createHTMLDocument().open()

FF 84.0.2,GM 4.10.0

代码可见GitLab。相关部分是:

        ...
        const doc = document.implementation.createHTMLDocument('http://www.w3.org/1999/xhtml', 'html');
console.debug("DOC CREATED")
        doc.open() // <-- with GM: DOMException: The operation is insecure.
console.debug("DOC OPENED")
        ...

控制台输出:

...
DOC CREATED
DOMException: The operation is insecure.

脚本适用于 Tampermonkey。

answer to DOM parsing in JavaScript得到了解决方案:

        ...
        const doc = document.implementation.createHTMLDocument('http://www.w3.org/1999/xhtml', 'html');
        doc.documentElement.innerHTML = page.responseText
        ...

而不是:

        ...
        const doc = document.implementation.createHTMLDocument('http://www.w3.org/1999/xhtml', 'html');
        doc.open()
        doc.write( page.responseText )
        ...