diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 0847cb6..aa4ea8c 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -166,7 +166,7 @@ export default function (client: ScramjetClient, self: typeof window) { }); client.Proxy("Element.prototype.setAttributeNS", { apply(ctx) { - const [_namespace, name, value] = ctx.args; + const [namespace, name, value] = ctx.args; const ruleList = htmlRules.find((rule) => { const r = rule[name]; diff --git a/src/client/dom/history.ts b/src/client/dom/history.ts index 3a67d74..37ece22 100644 --- a/src/client/dom/history.ts +++ b/src/client/dom/history.ts @@ -2,7 +2,7 @@ import { ScramjetClient } from "../client"; import { rewriteUrl } from "../../shared"; import { UrlChangeEvent } from "../events"; -export default function (client: ScramjetClient, _self: typeof globalThis) { +export default function (client: ScramjetClient, self: typeof globalThis) { client.Proxy("history.pushState", { apply(ctx) { if (ctx.args[2]) ctx.args[2] = rewriteUrl(ctx.args[2], client.meta); diff --git a/src/client/dom/origin.ts b/src/client/dom/origin.ts index 95fef2c..3f2c124 100644 --- a/src/client/dom/origin.ts +++ b/src/client/dom/origin.ts @@ -1,6 +1,7 @@ import { ScramjetClient } from "../client"; +import { unrewriteUrl } from "../../shared"; -export default function (client: ScramjetClient, _self: typeof window) { +export default function (client: ScramjetClient, self: typeof window) { client.Trap("origin", { get() { // this isn't right!! diff --git a/src/client/dom/performance.ts b/src/client/dom/performance.ts index cd04403..fce56e5 100644 --- a/src/client/dom/performance.ts +++ b/src/client/dom/performance.ts @@ -1,7 +1,7 @@ import { unrewriteUrl } from "../../shared"; import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, _self: typeof globalThis) { +export default function (client: ScramjetClient, self: typeof globalThis) { client.Trap("PerformanceEntry.prototype.name", { get(ctx) { return unrewriteUrl(ctx.get() as string); diff --git a/src/client/dom/storage.ts b/src/client/dom/storage.ts index cd287ce..d5aa220 100644 --- a/src/client/dom/storage.ts +++ b/src/client/dom/storage.ts @@ -86,7 +86,7 @@ export default function (client: ScramjetClient, self: typeof window) { }; const realLocalStorage = self.localStorage; - // const realSessionStorage = self.sessionStorage; + const realSessionStorage = self.sessionStorage; const localStorageProxy = new Proxy(self.localStorage, handler); const sessionStorageProxy = new Proxy(self.sessionStorage, handler); diff --git a/src/client/location.ts b/src/client/location.ts index 2d2b8b5..bf912db 100644 --- a/src/client/location.ts +++ b/src/client/location.ts @@ -1,7 +1,7 @@ // @ts-nocheck import { ScramjetClient } from "./client"; import { nativeGetOwnPropertyDescriptor } from "./natives"; -import { rewriteUrl } from "../shared"; +import { unrewriteUrl, rewriteUrl } from "../shared"; import { iswindow } from "."; export function createLocationProxy( diff --git a/src/client/shared/antiantidebugger.ts b/src/client/shared/antiantidebugger.ts index 0e67d17..e119afd 100644 --- a/src/client/shared/antiantidebugger.ts +++ b/src/client/shared/antiantidebugger.ts @@ -10,10 +10,10 @@ export default function (client: ScramjetClient) { const log = console.log; client.Trap("console.log", { - set(_ctx, _v) { + set(ctx, v) { // is there a legitimate reason to let sites do this? }, - get(_ctx) { + get(ctx) { return log; }, }); diff --git a/src/client/shared/function.ts b/src/client/shared/function.ts index e193743..a9a1b45 100644 --- a/src/client/shared/function.ts +++ b/src/client/shared/function.ts @@ -8,7 +8,7 @@ function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) { ctx.return(ctx.fn(content)()); } -export default function (client: ScramjetClient, _self: Self) { +export default function (client: ScramjetClient, self: Self) { const handler: Proxy = { apply(ctx) { rewriteFunction(ctx, client); diff --git a/src/client/shared/indexeddb.ts b/src/client/shared/indexeddb.ts index 962dff5..4b57257 100644 --- a/src/client/shared/indexeddb.ts +++ b/src/client/shared/indexeddb.ts @@ -1,6 +1,6 @@ import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, _self: Self) { +export default function (client: ScramjetClient, self: Self) { client.Proxy("IDBFactory.prototype.open", { apply(ctx) { ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`; diff --git a/src/client/shared/requests/beacon.ts b/src/client/shared/requests/beacon.ts index 02da29c..f758521 100644 --- a/src/client/shared/requests/beacon.ts +++ b/src/client/shared/requests/beacon.ts @@ -1,7 +1,7 @@ import { rewriteUrl } from "../../../shared"; import { ScramjetClient } from "../../client"; -export default function (client: ScramjetClient, _self) { +export default function (client: ScramjetClient, self) { client.Proxy("navigator.sendBeacon", { apply(ctx) { ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); diff --git a/src/client/shared/worker.ts b/src/client/shared/worker.ts index 3cd1008..a6e10c8 100644 --- a/src/client/shared/worker.ts +++ b/src/client/shared/worker.ts @@ -1,6 +1,7 @@ import { iswindow } from ".."; import { BareMuxConnection } from "../../shared"; import { rewriteUrl } from "../../shared"; +import type { MessageC2W } from "../../worker"; import { ScramjetClient } from "../client"; const sharedworkerpostmessage = MessagePort.prototype.postMessage; diff --git a/src/client/shared/wrap.ts b/src/client/shared/wrap.ts index f3bdcf3..596ffd0 100644 --- a/src/client/shared/wrap.ts +++ b/src/client/shared/wrap.ts @@ -2,15 +2,15 @@ import { iswindow, isworker } from ".."; import { SCRAMJETCLIENT } from "../../symbols"; import { ScramjetClient } from "../client"; import { config } from "../../shared"; +import { argdbg } from "./err"; import { indirectEval } from "./eval"; -// import { argdbg } from "./err"; export function createWrapFn(client: ScramjetClient, self: typeof globalThis) { return function (identifier: any, args: any) { if (args && typeof args === "object" && args.length === 0) - // for (const arg of args) { - // argdbg(arg); - // } + for (const arg of args) { + // argdbg(arg); + } if (iswindow && identifier instanceof self.Window) { return client.globalProxy; } else if (iswindow && identifier instanceof self.parent.self.Window) { diff --git a/src/client/swruntime.ts b/src/client/swruntime.ts index 8ce0aae..6b21b2c 100644 --- a/src/client/swruntime.ts +++ b/src/client/swruntime.ts @@ -38,7 +38,6 @@ export class ScramjetServiceWorkerRuntime { postMessage: () => {}, addEventListener: () => {}, removeEventListener: () => {}, - // @ts-ignore dispatchEvent: (_e: Event) => {}, }, showNotification: async () => {}, @@ -124,7 +123,7 @@ function handleMessage( function trustEvent(event: Event): Event { return new Proxy(event, { - get(target, prop, _reciever) { + get(target, prop, reciever) { if (prop === "isTrusted") return true; return Reflect.get(target, prop); diff --git a/src/sync.ts b/src/sync.ts index bc80ae7..1372ca1 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -31,14 +31,14 @@ addEventListener( cursor += 2; // next write the header string - const resHeaders = xhr.getAllResponseHeaders(); - view.setUint32(cursor, resHeaders.length); + const headers = xhr.getAllResponseHeaders(); + view.setUint32(cursor, headers.length); cursor += 4; - if (sab.byteLength < cursor + resHeaders.length) - sab.grow(cursor + resHeaders.length); - u8view.set(new TextEncoder().encode(resHeaders), cursor); - cursor += resHeaders.length; + if (sab.byteLength < cursor + headers.length) + sab.grow(cursor + headers.length); + u8view.set(new TextEncoder().encode(headers), cursor); + cursor += headers.length; view.setUint32(cursor, xhr.response.byteLength); cursor += 4; diff --git a/src/thread/thread.ts b/src/thread/thread.ts index d565064..dc208bc 100644 --- a/src/thread/thread.ts +++ b/src/thread/thread.ts @@ -1,8 +1,8 @@ import { rewriteJs } from "../shared/rewriters/js"; // @ts-ignore -onconnect = (ev) => { - const port = ev.ports[0]; +onconnect = (e) => { + const port = e.ports[0]; console.log("thread: connected to port", port); port.postMessage("ready"); @@ -20,10 +20,10 @@ onconnect = (ev) => { token, result: res, }); - } catch (err) { + } catch (e) { port.postMessage({ token, - error: err.message, + error: e.message, }); }