mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
feat: proxy node.prototype.textcontent
This commit is contained in:
parent
129f094cda
commit
e57a654ecc
1 changed files with 32 additions and 1 deletions
|
@ -1,11 +1,14 @@
|
||||||
import { SCRAMJETCLIENT } from "../../symbols";
|
import { SCRAMJETCLIENT } from "../../symbols";
|
||||||
import { ScramjetClient } from "../client";
|
import { ScramjetClient } from "../client";
|
||||||
import { nativeGetOwnPropertyDescriptor } from "../natives";
|
import { nativeGetOwnPropertyDescriptor } from "../natives";
|
||||||
import { decodeUrl, htmlRules, unrewriteHtml } from "../../shared";
|
|
||||||
import {
|
import {
|
||||||
encodeUrl,
|
encodeUrl,
|
||||||
|
decodeUrl,
|
||||||
rewriteCss,
|
rewriteCss,
|
||||||
|
unrewriteCss,
|
||||||
|
htmlRules,
|
||||||
rewriteHtml,
|
rewriteHtml,
|
||||||
|
unrewriteHtml,
|
||||||
rewriteJs,
|
rewriteJs,
|
||||||
rewriteSrcset,
|
rewriteSrcset,
|
||||||
} from "../../shared";
|
} 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", {
|
client.Trap("Element.prototype.innerHTML", {
|
||||||
set(ctx, value: string) {
|
set(ctx, value: string) {
|
||||||
let newval;
|
let newval;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue