fix: proxy Node.getRootNode

This commit is contained in:
Percs 2024-10-14 12:17:37 -05:00
parent a2af4d7f3b
commit ee85b48d33
7 changed files with 13 additions and 4 deletions

View file

@ -36,7 +36,7 @@ mkdir dist/ || true
{
cat <<EOF
if ("document" in self && document.currentScript) {
if ("document" in self && document?.currentScript) {
document.currentScript.remove();
}
EOF

View file

@ -306,6 +306,7 @@ export default function (client: ScramjetClient, self: typeof window) {
"Node.prototype.parentElement",
"Node.prototype.previousSibling",
"Node.prototype.nextSibling",
"Node.prototype.getRootNode",
],
{
get(ctx) {

View file

@ -38,6 +38,6 @@ if (!(SCRAMJETCLIENT in <Partial<typeof self>>self)) {
client.frame?.dispatchEvent(ev);
}
if ("document" in self && document.currentScript) {
if ("document" in self && document?.currentScript) {
document.currentScript.remove();
}

View file

@ -63,6 +63,11 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
if (typeof v === "string" && v.includes("scramjet")) {
debugger;
}
if (typeof v === "string" && v.includes(location.origin)) {
debugger;
}
if (iswindow && v instanceof Document && v.defaultView.$scramjet) {
debugger;
}

View file

@ -43,6 +43,6 @@ $scramjet.shared = {
CookieStore,
};
if ("document" in self && document.currentScript) {
if ("document" in self && document?.currentScript) {
document.currentScript.remove();
}

View file

@ -45,7 +45,7 @@ export function rewriteHtml(
const injected = `
self.COOKIE = ${dump};
self.$scramjet.config = ${JSON.stringify($scramjet.config)};
if ("document" in self && document.currentScript) {
if ("document" in self && document?.currentScript) {
document.currentScript.remove();
}
`;

View file

@ -10,6 +10,9 @@ const scramjet = new ScramjetController({
"https://discord.com/.*": {
naiiveRewriter: true,
},
"https://worker-playground.glitch.me/.*": {
serviceworkers: true,
},
},
});