diff --git a/src/client/dom/postmessage.ts b/src/client/dom/postmessage.ts index 64dd96b..840f186 100644 --- a/src/client/dom/postmessage.ts +++ b/src/client/dom/postmessage.ts @@ -1,3 +1,4 @@ +import { SCRAMJETCLIENT } from "../../symbols"; import { ScramjetClient } from "../client"; import { POLLUTANT } from "../shared/realm"; @@ -18,8 +19,7 @@ export default function (client: ScramjetClient) { // invoking stolen function will give us the caller's globalThis, remember scramjet has already proxied it!!! const callerGlobalThisProxied: Self = Function("return globalThis")(); - const callerClient: ScramjetClient = - callerGlobalThisProxied[ScramjetClient.SCRAMJET]; + const callerClient = callerGlobalThisProxied[SCRAMJETCLIENT]; // this WOULD be enough but the source argument of MessageEvent has to return the caller's window // and if we just call it normally it would be coming from here, which WILL NOT BE THE CALLER'S because the accessor is from the parent @@ -39,7 +39,9 @@ export default function (client: ScramjetClient) { // * origin because obviously if (typeof ctx.args[1] === "string") ctx.args[1] = "*"; - wrappedPostMessage.call(ctx.fn, ctx.args[0], ctx.args[1], ctx.args[2]); + ctx.return( + wrappedPostMessage.call(ctx.fn, ctx.args[0], ctx.args[1], ctx.args[2]) + ); }, }); } diff --git a/src/shared/rewriters/js.ts b/src/shared/rewriters/js.ts index c77218c..0be28da 100644 --- a/src/shared/rewriters/js.ts +++ b/src/shared/rewriters/js.ts @@ -39,11 +39,6 @@ export function rewriteJs(js: string | ArrayBuffer, origin?: URL) { // dbg.debug("Rewrite took", Math.floor((after - before) * 10) / 10, "ms"); - if (typeof js !== "string") js = new TextDecoder().decode(js); - js = js.replaceAll( - `(c=H[36](57,T,(F=(d=["contentWindow","ports",(S=p.dH,"recaptcha-setup")],S).data==d[2],S).origin)==H[36](59,T,A),b=!E||S.source==E[d[0]],F&&c&&b&&S[d[1]].length>M)?S[d[1]][M]:null`, - " p.dH.ports[0]" - ); return js; }