From d6b3fcda4c0781409edd895fdc35a81a9e728af7 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:38:04 -0600 Subject: [PATCH] fix: try catch most instances of rewriteHTML --- src/client/dom/document.ts | 28 ++++++++++++++++------------ src/client/dom/element.ts | 28 ++++++++++++++++------------ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/client/dom/document.ts b/src/client/dom/document.ts index 0be4453..e402611 100644 --- a/src/client/dom/document.ts +++ b/src/client/dom/document.ts @@ -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 {} }, }); } diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 1b6c89e..492f084 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -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 {} } }, });