This commit is contained in:
Avad3 2024-07-11 20:44:47 -04:00
commit acfc01ee33

View file

@ -50,13 +50,17 @@ export class ScramjetServiceWorker {
switch (request.destination) { switch (request.destination) {
case "iframe": case "iframe":
case "document": case "document":
responseBody = if (responseHeaders["content-type"].startsWith("text/html")) {
`<html> responseBody =
<head> `<html>
${["codecs", "config", "html"].map((script) => "<script type=\"module\" src=" + this.config[script] + "></script>").join("")} <head>
</head> ${["codecs", "config", "html"].map((script) => "<script type=\"module\" src=" + this.config[script] + "></script>").join("")}
</html>`; </head>
this.html = await response.text(); </html>`;
this.html = await response.text();
} else {
responseBody = response.body
}
break; break;
case "script": case "script":
responseBody = rewriteJs(await response.text(), url); responseBody = rewriteJs(await response.text(), url);
@ -74,7 +78,7 @@ export class ScramjetServiceWorker {
} }
} }
// downloads // downloads
if (request.destination === "document") { if (["document", "iframe"].includes(request.destination)) {
const header = responseHeaders["content-disposition"]; const header = responseHeaders["content-disposition"];
// validate header and test for filename // validate header and test for filename