Files
Folo/apps/renderer/__debug_proxy.html
T
2024-11-06 19:07:44 +08:00

46 lines
1.3 KiB
HTML

<!doctype html>
<html>
<head>
<script type="module">
const host = "https://localhost:2233"
globalThis["__DEBUG_PROXY__"] = true
fetch(`${host}`)
.then((res) => res.text())
.then((html) => {
const parser = new DOMParser()
const doc = parser.parseFromString(html, "text/html")
document.head.innerHTML = doc.head.innerHTML
document.body.innerHTML = doc.body.innerHTML
const scripts = doc.querySelectorAll("script")
scripts.forEach((script) => {
const $script = document.createElement("script")
if (!script.innerHTML) return
$script.innerHTML = script.innerHTML
$script.type = "module"
$script.crossOrigin = script.crossOrigin
document.body.appendChild($script)
})
const srcScripts = doc.querySelectorAll("script[src]")
srcScripts.forEach((script) => {
fetch(`${script.src}`)
.then((res) => res.text())
.then((text) => {
const $script = document.createElement("script")
$script.innerHTML = text
$script.type = "module"
document.body.appendChild($script)
})
})
})
</script>
</head>
<body></body>
</html>