From e7cf2010835b6176b65360abe1cf8cf78b676f41 Mon Sep 17 00:00:00 2001 From: velzie Date: Fri, 11 Oct 2024 16:33:10 -0400 Subject: [PATCH] fuck my stupid scramjet life --- src/client/dom/element.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 84d77bd..2c6567e 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -52,7 +52,7 @@ export default function (client: ScramjetClient, self: typeof window) { for (const element of attrObject[attr]) { const descriptor = nativeGetOwnPropertyDescriptor( element.prototype, - attr + attr, ); Object.defineProperty(element.prototype, attr, { get() { @@ -80,7 +80,7 @@ export default function (client: ScramjetClient, self: typeof window) { base: new URL(client.url.origin), origin: new URL(client.url.origin), } as URLMeta, - true + true, ); } else if (["srcset", "imagesrcset"].includes(attr)) { value = rewriteSrcset(value, client.meta); @@ -183,8 +183,8 @@ export default function (client: ScramjetClient, self: typeof window) { return atob( client.natives["Element.prototype.getAttribute"].call( ctx.this, - "data-scramjet-script-source-src" - ) + "data-scramjet-script-source-src", + ), ); } if (ctx.this instanceof self.HTMLStyleElement) { @@ -267,6 +267,20 @@ export default function (client: ScramjetClient, self: typeof window) { }, }); + client.Trap( + [ + "Node.prototype.parentNode", + "Node.prototype.parentElement", + "Node.prototype.previousSibling", + "Node.prototype.nextSibling", + ], + { + get(ctx) { + return client.wrapfn(ctx.get()); + }, + }, + ); + client.Proxy("DOMParser.prototype.parseFromString", { apply(ctx) { if (ctx.args[1] === "text/html") { @@ -274,7 +288,7 @@ export default function (client: ScramjetClient, self: typeof window) { ctx.args[0], client.cookieStore, client.meta, - false + false, ); } }, @@ -286,7 +300,7 @@ export default function (client: ScramjetClient, self: typeof window) { ctx.args[0], client.cookieStore, client.meta, - true + true, ); }, }); @@ -297,7 +311,7 @@ export default function (client: ScramjetClient, self: typeof window) { ctx.args[0], client.cookieStore, client.meta, - false + false, ); }, });