From ee85b48d33576fd78cd8389ea63123531bfe6f52 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:17:37 -0500 Subject: [PATCH] fix: proxy Node.getRootNode --- rewriter/build.sh | 2 +- src/client/dom/element.ts | 1 + src/client/index.ts | 2 +- src/client/shared/wrap.ts | 5 +++++ src/shared/index.ts | 2 +- src/shared/rewriters/html.ts | 2 +- static/ui.js | 3 +++ 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rewriter/build.sh b/rewriter/build.sh index 94b8820..9021eb6 100755 --- a/rewriter/build.sh +++ b/rewriter/build.sh @@ -36,7 +36,7 @@ mkdir dist/ || true { cat <>self)) { client.frame?.dispatchEvent(ev); } -if ("document" in self && document.currentScript) { +if ("document" in self && document?.currentScript) { document.currentScript.remove(); } diff --git a/src/client/shared/wrap.ts b/src/client/shared/wrap.ts index 0e066e9..c723749 100644 --- a/src/client/shared/wrap.ts +++ b/src/client/shared/wrap.ts @@ -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; } diff --git a/src/shared/index.ts b/src/shared/index.ts index bac2c1c..af2abb5 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -43,6 +43,6 @@ $scramjet.shared = { CookieStore, }; -if ("document" in self && document.currentScript) { +if ("document" in self && document?.currentScript) { document.currentScript.remove(); } diff --git a/src/shared/rewriters/html.ts b/src/shared/rewriters/html.ts index 2e84a2c..5647421 100644 --- a/src/shared/rewriters/html.ts +++ b/src/shared/rewriters/html.ts @@ -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(); } `; diff --git a/static/ui.js b/static/ui.js index c5c57b7..637955f 100644 --- a/static/ui.js +++ b/static/ui.js @@ -10,6 +10,9 @@ const scramjet = new ScramjetController({ "https://discord.com/.*": { naiiveRewriter: true, }, + "https://worker-playground.glitch.me/.*": { + serviceworkers: true, + }, }, });