From a74805308516f76f1e7e89c1e68e170a960d15f1 Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Thu, 17 Oct 2024 19:49:35 -0500 Subject: [PATCH] proxy Element.prototype.insertAdjacentHTML, rust docs work perfectly now. --- src/client/dom/element.ts | 12 ++++++++++++ src/shared/rewriters/html.ts | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 4cf1dd4..6d2870c 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -237,6 +237,18 @@ 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, + true + ); + }, + }) + client.Trap("HTMLIFrameElement.prototype.contentWindow", { get(ctx) { const realwin = ctx.get() as Window; diff --git a/src/shared/rewriters/html.ts b/src/shared/rewriters/html.ts index 5647421..520e710 100644 --- a/src/shared/rewriters/html.ts +++ b/src/shared/rewriters/html.ts @@ -280,11 +280,11 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) { return rewrittenUrls.join(""); } -function _base64ToBytes(base64) { - const binString = atob(base64); +// function base64ToBytes(base64) { +// const binString = atob(base64); - return Uint8Array.from(binString, (m) => m.codePointAt(0)); -} +// return Uint8Array.from(binString, (m) => m.codePointAt(0)); +// } function bytesToBase64(bytes: Uint8Array) { const binString = Array.from(bytes, (byte) =>