Skip to content

Commit

Permalink
fix: proxy Node.getRootNode
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Oct 14, 2024
1 parent a2af4d7 commit ee85b48
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rewriter/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/client/dom/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
5 changes: 5 additions & 0 deletions src/client/shared/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ $scramjet.shared = {
CookieStore,
};

if ("document" in self && document.currentScript) {
if ("document" in self && document?.currentScript) {
document.currentScript.remove();
}
2 changes: 1 addition & 1 deletion src/shared/rewriters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
`;
Expand Down
3 changes: 3 additions & 0 deletions static/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const scramjet = new ScramjetController({
"https://discord.com/.*": {
naiiveRewriter: true,
},
"https://worker-playground.glitch.me/.*": {
serviceworkers: true,
},
},
});

Expand Down

0 comments on commit ee85b48

Please sign in to comment.