feat: proxy node.prototype.textcontent

This commit is contained in:
Percs 2024-10-07 13:42:34 -05:00
parent 129f094cda
commit e57a654ecc

View file

@ -1,11 +1,14 @@
import { SCRAMJETCLIENT } from "../../symbols";
import { ScramjetClient } from "../client";
import { nativeGetOwnPropertyDescriptor } from "../natives";
import { decodeUrl, htmlRules, unrewriteHtml } from "../../shared";
import {
encodeUrl,
decodeUrl,
rewriteCss,
unrewriteCss,
htmlRules,
rewriteHtml,
unrewriteHtml,
rewriteJs,
rewriteSrcset,
} from "../../shared";
@ -160,6 +163,34 @@ export default function (client: ScramjetClient, self: typeof window) {
},
});
client.Trap("Node.prototype.textContent", {
get(ctx) {
switch (ctx.this.tagName) {
case "SCRIPT":
return ctx.get();
case "STYLE":
return unrewriteCss(ctx.get() as string);
default:
return unrewriteHtml(ctx.get() as string);
}
},
set(ctx) {
switch (ctx.this.tagName) {
case "SCRIPT":
return ctx.get();
case "STYLE":
return rewriteCss(ctx.get() as string, client.meta);
default:
return rewriteHtml(
ctx.get() as string,
client.cookieStore,
client.meta,
false
);
}
},
});
client.Trap("Element.prototype.innerHTML", {
set(ctx, value: string) {
let newval;