fix: try catch most instances of rewriteHTML

This commit is contained in:
Percs 2024-11-06 10:38:04 -06:00
parent c9c98bc70e
commit d6b3fcda4c
2 changed files with 32 additions and 24 deletions

View file

@ -5,24 +5,28 @@ export default function (client: ScramjetClient, self: typeof window) {
client.Proxy("Document.prototype.write", {
apply(ctx) {
if (ctx.args[0])
ctx.args[0] = rewriteHtml(
ctx.args[0],
client.cookieStore,
client.meta,
false
);
try {
ctx.args[0] = rewriteHtml(
ctx.args[0],
client.cookieStore,
client.meta,
false
);
} catch {}
},
});
client.Proxy("Document.prototype.writeln", {
apply(ctx) {
if (ctx.args[0])
ctx.args[0] = rewriteHtml(
ctx.args[0],
client.cookieStore,
client.meta,
false
);
try {
ctx.args[0] = rewriteHtml(
ctx.args[0],
client.cookieStore,
client.meta,
false
);
} catch {}
},
});
}

View file

@ -220,12 +220,14 @@ export default function (client: ScramjetClient, self: typeof window) {
client.Proxy("Element.prototype.insertAdjacentHTML", {
apply(ctx) {
if (ctx.args[1])
ctx.args[1] = rewriteHtml(
ctx.args[1],
client.cookieStore,
client.meta,
false
);
try {
ctx.args[1] = rewriteHtml(
ctx.args[1],
client.cookieStore,
client.meta,
false
);
} catch {}
},
});
@ -327,12 +329,14 @@ export default function (client: ScramjetClient, self: typeof window) {
client.Proxy("DOMParser.prototype.parseFromString", {
apply(ctx) {
if (ctx.args[1] === "text/html") {
ctx.args[0] = rewriteHtml(
ctx.args[0],
client.cookieStore,
client.meta,
false
);
try {
ctx.args[0] = rewriteHtml(
ctx.args[0],
client.cookieStore,
client.meta,
false
);
} catch {}
}
},
});