fix: node not returning proper value

This commit is contained in:
Percs 2024-10-12 02:44:35 -05:00
parent 59782b9a30
commit 9879199d27

View file

@ -52,7 +52,7 @@ export default function (client: ScramjetClient, self: typeof window) {
for (const element of attrObject[attr]) { for (const element of attrObject[attr]) {
const descriptor = nativeGetOwnPropertyDescriptor( const descriptor = nativeGetOwnPropertyDescriptor(
element.prototype, element.prototype,
attr, attr
); );
Object.defineProperty(element.prototype, attr, { Object.defineProperty(element.prototype, attr, {
get() { get() {
@ -80,7 +80,7 @@ export default function (client: ScramjetClient, self: typeof window) {
base: new URL(client.url.origin), base: new URL(client.url.origin),
origin: new URL(client.url.origin), origin: new URL(client.url.origin),
} as URLMeta, } as URLMeta,
true, true
); );
} else if (["srcset", "imagesrcset"].includes(attr)) { } else if (["srcset", "imagesrcset"].includes(attr)) {
value = rewriteSrcset(value, client.meta); value = rewriteSrcset(value, client.meta);
@ -183,8 +183,8 @@ export default function (client: ScramjetClient, self: typeof window) {
return atob( return atob(
client.natives["Element.prototype.getAttribute"].call( client.natives["Element.prototype.getAttribute"].call(
ctx.this, ctx.this,
"data-scramjet-script-source-src", "data-scramjet-script-source-src"
), )
); );
} }
if (ctx.this instanceof self.HTMLStyleElement) { if (ctx.this instanceof self.HTMLStyleElement) {
@ -277,14 +277,14 @@ export default function (client: ScramjetClient, self: typeof window) {
{ {
get(ctx) { get(ctx) {
const n = ctx.get() as Node; const n = ctx.get() as Node;
if (!(n instanceof Document)) return; if (!(n instanceof Document)) return n;
const scram: ScramjetClient = n[SCRAMJETCLIENT]; const scram: ScramjetClient = n[SCRAMJETCLIENT];
if (!scram) return n; // ?? if (!scram) return n; // ??
return scram.documentProxy; return scram.documentProxy;
}, },
}, }
); );
client.Proxy("DOMParser.prototype.parseFromString", { client.Proxy("DOMParser.prototype.parseFromString", {
@ -294,7 +294,7 @@ export default function (client: ScramjetClient, self: typeof window) {
ctx.args[0], ctx.args[0],
client.cookieStore, client.cookieStore,
client.meta, client.meta,
false, false
); );
} }
}, },
@ -306,7 +306,7 @@ export default function (client: ScramjetClient, self: typeof window) {
ctx.args[0], ctx.args[0],
client.cookieStore, client.cookieStore,
client.meta, client.meta,
true, true
); );
}, },
}); });
@ -317,7 +317,7 @@ export default function (client: ScramjetClient, self: typeof window) {
ctx.args[0], ctx.args[0],
client.cookieStore, client.cookieStore,
client.meta, client.meta,
false, false
); );
}, },
}); });