From e8a8a66397a8d2380f6a7ec9e50d8e9d0557af6d Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Thu, 10 Oct 2024 19:31:35 -0500 Subject: [PATCH] chore: lint:fix --- src/client/dom/element.ts | 8 +++++--- src/client/shared/indexeddb.ts | 5 +++-- src/client/shared/requests/xmlhttprequest.ts | 11 +++++++---- src/client/shared/wrap.ts | 3 ++- src/shared/rewriters/html.ts | 8 +++++--- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 9553e07..3485311 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -171,9 +171,10 @@ export default function (client: ScramjetClient, self: typeof window) { // since the prototype chain is fucked const style = ctx.get() as CSSStyleDeclaration; - return new Proxy(style, { + +return new Proxy(style, { get(t, p) { - let v = Reflect.get(t, p); + const v = Reflect.get(t, p); if (typeof v === "function") { return new Proxy(v, { apply(target, thisArg, argArray) { @@ -189,7 +190,8 @@ export default function (client: ScramjetClient, self: typeof window) { if (v == "" || typeof v !== "string") { return Reflect.set(t, p, v); } - return Reflect.set(t, p, rewriteCss(v, client.meta)); + +return Reflect.set(t, p, rewriteCss(v, client.meta)); }, }); }, diff --git a/src/client/shared/indexeddb.ts b/src/client/shared/indexeddb.ts index 1c02536..6143e1d 100644 --- a/src/client/shared/indexeddb.ts +++ b/src/client/shared/indexeddb.ts @@ -9,8 +9,9 @@ export default function (client: ScramjetClient, self: Self) { client.Trap("IDBDatabase.prototype.name", { get(ctx) { - let name = ctx.get() as string; - return name.substring(name.indexOf("@") + 1); + const name = ctx.get() as string; + +return name.substring(name.indexOf("@") + 1); }, }); } diff --git a/src/client/shared/requests/xmlhttprequest.ts b/src/client/shared/requests/xmlhttprequest.ts index cc59564..e13dac8 100644 --- a/src/client/shared/requests/xmlhttprequest.ts +++ b/src/client/shared/requests/xmlhttprequest.ts @@ -47,7 +47,7 @@ export default function (client: ScramjetClient, self: Self) { body: ctx.args[0], }); - let now = performance.now(); + const now = performance.now(); while (view.getUint8(0) === 0) { if (performance.now() - now > 1000) { throw new Error("xhr timeout"); @@ -85,13 +85,15 @@ export default function (client: ScramjetClient, self: Self) { client.RawTrap(ctx.this, "response", { get() { if (ctx.this.responseType === "arraybuffer") return bodyab.buffer; - return body; + +return body; }, }); client.RawTrap(ctx.this, "responseXML", { get() { const parser = new DOMParser(); - return parser.parseFromString(body, "text/xml"); + +return parser.parseFromString(body, "text/xml"); }, }); client.RawTrap(ctx.this, "getAllResponseHeaders", { @@ -104,7 +106,8 @@ export default function (client: ScramjetClient, self: Self) { return (header: string) => { const re = new RegExp(`^${header}: (.*)$`, "m"); const match = re.exec(headers); - return match ? match[1] : null; + +return match ? match[1] : null; }; }, }); diff --git a/src/client/shared/wrap.ts b/src/client/shared/wrap.ts index c28a5b6..fe9b56f 100644 --- a/src/client/shared/wrap.ts +++ b/src/client/shared/wrap.ts @@ -66,7 +66,8 @@ export default function (client: ScramjetClient, self: typeof globalThis) { if (typeof v === "string" && v.includes("scramjet")) { debugger; } - return v; + +return v; }; // location = "..." can't be rewritten as wrapfn(location) = ..., so instead it will actually be rewritten as diff --git a/src/shared/rewriters/html.ts b/src/shared/rewriters/html.ts index a053d10..f36ec64 100644 --- a/src/shared/rewriters/html.ts +++ b/src/shared/rewriters/html.ts @@ -219,7 +219,7 @@ function traverseParsedHtml( ) { let js = node.children[0].data; // node.attribs[`data-scramjet-script-source-src`] = btoa(js); - node.attribs[`data-scramjet-script-source-src`] = bytesToBase64( + node.attribs["data-scramjet-script-source-src"] = bytesToBase64( new TextEncoder().encode(js) ); const htmlcomment = //g; @@ -272,12 +272,14 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) { function base64ToBytes(base64) { const binString = atob(base64); - return Uint8Array.from(binString, (m) => m.codePointAt(0)); + +return Uint8Array.from(binString, (m) => m.codePointAt(0)); } function bytesToBase64(bytes: Uint8Array) { const binString = Array.from(bytes, (byte) => String.fromCodePoint(byte) ).join(""); - return btoa(binString); + +return btoa(binString); }