diff --git a/src/client/client.ts b/src/client/client.ts index d43ad6a..d0fc398 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -112,6 +112,7 @@ export class ScramjetClient { ); } + // eslint-disable-next-line @typescript-eslint/no-this-alias const client = this; this.meta = { get origin() { @@ -121,13 +122,15 @@ export class ScramjetClient { if (iswindow) { const base = client.global.document.querySelector("base"); if (base) { - let url = base.getAttribute(`href`); - let frag = url.indexOf("#"); + let url = base.getAttribute("href"); + const frag = url.indexOf("#"); url = url.substring(0, frag === -1 ? undefined : frag); if (!url) return client.url; + return new URL(url, client.url.origin); } } + return client.url; }, }; diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 31d0dc8..ff78d13 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -1,7 +1,7 @@ import { SCRAMJETCLIENT } from "../../symbols"; import { ScramjetClient } from "../client"; import { nativeGetOwnPropertyDescriptor } from "../natives"; -import { config, decodeUrl, htmlRules, unrewriteHtml } from "../../shared"; +import { decodeUrl, htmlRules, unrewriteHtml } from "../../shared"; import { encodeUrl, rewriteCss, @@ -134,7 +134,7 @@ export default function (client: ScramjetClient, self: typeof window) { apply(ctx) { const [name, value] = ctx.args; - const rule = htmlRules.find((rule) => { + const ruleList = htmlRules.find((rule) => { const r = rule[name]; if (!r) return false; if (r === "*") return true; @@ -143,8 +143,8 @@ export default function (client: ScramjetClient, self: typeof window) { return r.includes(ctx.this.tagName.toLowerCase()); }); - if (rule) { - ctx.args[1] = rule.fn(value, client.meta, client.cookieStore); + if (ruleList) { + ctx.args[1] = ruleList.fn(value, client.meta, client.cookieStore); ctx.fn.call(ctx.this, `data-scramjet-${ctx.args[0]}`, value); } }, @@ -246,7 +246,7 @@ export default function (client: ScramjetClient, self: typeof window) { client.Trap("Node.prototype.ownerDocument", { get(ctx) { - return client.documentProxy; + // return client.documentProxy; const doc = ctx.get() as Document | null; if (!doc) return null; diff --git a/src/client/global.ts b/src/client/global.ts index b1861ec..446ff42 100644 --- a/src/client/global.ts +++ b/src/client/global.ts @@ -1,7 +1,7 @@ -import { encodeUrl } from "../shared"; +// import { encodeUrl } from "../shared"; import { ScramjetClient } from "./client"; import { indirectEval } from "./shared/eval"; -import { config } from "../shared"; +// import { config } from "../shared"; import { getOwnPropertyDescriptorHandler } from "./helpers"; export function createGlobalProxy( diff --git a/src/client/shared/err.ts b/src/client/shared/err.ts index 9a816d4..7125fcc 100644 --- a/src/client/shared/err.ts +++ b/src/client/shared/err.ts @@ -6,6 +6,7 @@ export function argdbg(arg, recurse = []) { switch (typeof arg) { case "string": if (arg.includes("localhost:1337/scramjet/") && arg.includes("m3u8")) + // eslint-disable-next-line no-debugger debugger; break; case "object": diff --git a/src/client/shared/sourcemaps.ts b/src/client/shared/sourcemaps.ts index 920754c..fd5ed0a 100644 --- a/src/client/shared/sourcemaps.ts +++ b/src/client/shared/sourcemaps.ts @@ -43,7 +43,7 @@ export default function (client: ScramjetClient, self: Self) { ); // subtracting that from the index of the scramtag gives us the starting index of the function relative to the entire file - let absindex = abstagindex - scramtagstart; + const absindex = abstagindex - scramtagstart; const scramtagend = stringified.indexOf("*/", scramtagstart); const tag = stringified.substring(firstspace + 1, scramtagend); @@ -75,6 +75,7 @@ export default function (client: ScramjetClient, self: Self) { } newString += stringified.slice(i); + return ctx.return(newString); }, }); diff --git a/src/client/worker/importScripts.ts b/src/client/worker/importScripts.ts index d85299a..04a0977 100644 --- a/src/client/worker/importScripts.ts +++ b/src/client/worker/importScripts.ts @@ -1,7 +1,7 @@ import { encodeUrl } from "../../shared"; import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self: Self) { +export default function (client: ScramjetClient, _self: Self) { client.Proxy("importScripts", { apply(ctx) { for (const i in ctx.args) {