mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
fix scramjet script injection
This commit is contained in:
parent
ea44f28276
commit
586616700c
1 changed files with 5 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
import { Parser } from "htmlparser2";
|
||||
import { DomHandler, Element } from "domhandler";
|
||||
import { hasAttrib, prependChild } from "domutils";
|
||||
import { hasAttrib } from "domutils";
|
||||
import render from "dom-serializer";
|
||||
import { encodeUrl } from "./url";
|
||||
import { rewriteCss } from "./css";
|
||||
|
@ -49,11 +49,14 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
}
|
||||
|
||||
if (node.name === "head") {
|
||||
const scramjetScripts = [];
|
||||
["codecs", "config", "bundle", "client"].forEach((script) => {
|
||||
prependChild(node, new Element("script", {
|
||||
scramjetScripts.push(new Element("script", {
|
||||
src: self.__scramjet$config[script]
|
||||
}));
|
||||
});
|
||||
|
||||
node.children.unshift(...scramjetScripts);
|
||||
}
|
||||
|
||||
if (node.childNodes) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue