just make eslint happier

This commit is contained in:
wearrrrr 2024-09-22 20:48:56 -05:00
parent 96103460b8
commit dc80bf1170
6 changed files with 16 additions and 11 deletions

View file

@ -112,6 +112,7 @@ export class ScramjetClient {
); );
} }
// eslint-disable-next-line @typescript-eslint/no-this-alias
const client = this; const client = this;
this.meta = { this.meta = {
get origin() { get origin() {
@ -121,13 +122,15 @@ export class ScramjetClient {
if (iswindow) { if (iswindow) {
const base = client.global.document.querySelector("base"); const base = client.global.document.querySelector("base");
if (base) { if (base) {
let url = base.getAttribute(`href`); let url = base.getAttribute("href");
let frag = url.indexOf("#"); const frag = url.indexOf("#");
url = url.substring(0, frag === -1 ? undefined : frag); url = url.substring(0, frag === -1 ? undefined : frag);
if (!url) return client.url; if (!url) return client.url;
return new URL(url, client.url.origin); return new URL(url, client.url.origin);
} }
} }
return client.url; return client.url;
}, },
}; };

View file

@ -1,7 +1,7 @@
import { SCRAMJETCLIENT } from "../../symbols"; import { SCRAMJETCLIENT } from "../../symbols";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
import { nativeGetOwnPropertyDescriptor } from "../natives"; import { nativeGetOwnPropertyDescriptor } from "../natives";
import { config, decodeUrl, htmlRules, unrewriteHtml } from "../../shared"; import { decodeUrl, htmlRules, unrewriteHtml } from "../../shared";
import { import {
encodeUrl, encodeUrl,
rewriteCss, rewriteCss,
@ -134,7 +134,7 @@ export default function (client: ScramjetClient, self: typeof window) {
apply(ctx) { apply(ctx) {
const [name, value] = ctx.args; const [name, value] = ctx.args;
const rule = htmlRules.find((rule) => { const ruleList = htmlRules.find((rule) => {
const r = rule[name]; const r = rule[name];
if (!r) return false; if (!r) return false;
if (r === "*") return true; if (r === "*") return true;
@ -143,8 +143,8 @@ export default function (client: ScramjetClient, self: typeof window) {
return r.includes(ctx.this.tagName.toLowerCase()); return r.includes(ctx.this.tagName.toLowerCase());
}); });
if (rule) { if (ruleList) {
ctx.args[1] = rule.fn(value, client.meta, client.cookieStore); ctx.args[1] = ruleList.fn(value, client.meta, client.cookieStore);
ctx.fn.call(ctx.this, `data-scramjet-${ctx.args[0]}`, value); 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", { client.Trap("Node.prototype.ownerDocument", {
get(ctx) { get(ctx) {
return client.documentProxy; // return client.documentProxy;
const doc = ctx.get() as Document | null; const doc = ctx.get() as Document | null;
if (!doc) return null; if (!doc) return null;

View file

@ -1,7 +1,7 @@
import { encodeUrl } from "../shared"; // import { encodeUrl } from "../shared";
import { ScramjetClient } from "./client"; import { ScramjetClient } from "./client";
import { indirectEval } from "./shared/eval"; import { indirectEval } from "./shared/eval";
import { config } from "../shared"; // import { config } from "../shared";
import { getOwnPropertyDescriptorHandler } from "./helpers"; import { getOwnPropertyDescriptorHandler } from "./helpers";
export function createGlobalProxy( export function createGlobalProxy(

View file

@ -6,6 +6,7 @@ export function argdbg(arg, recurse = []) {
switch (typeof arg) { switch (typeof arg) {
case "string": case "string":
if (arg.includes("localhost:1337/scramjet/") && arg.includes("m3u8")) if (arg.includes("localhost:1337/scramjet/") && arg.includes("m3u8"))
// eslint-disable-next-line no-debugger
debugger; debugger;
break; break;
case "object": case "object":

View file

@ -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 // 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 scramtagend = stringified.indexOf("*/", scramtagstart);
const tag = stringified.substring(firstspace + 1, scramtagend); const tag = stringified.substring(firstspace + 1, scramtagend);
@ -75,6 +75,7 @@ export default function (client: ScramjetClient, self: Self) {
} }
newString += stringified.slice(i); newString += stringified.slice(i);
return ctx.return(newString); return ctx.return(newString);
}, },
}); });

View file

@ -1,7 +1,7 @@
import { encodeUrl } from "../../shared"; import { encodeUrl } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: Self) { export default function (client: ScramjetClient, _self: Self) {
client.Proxy("importScripts", { client.Proxy("importScripts", {
apply(ctx) { apply(ctx) {
for (const i in ctx.args) { for (const i in ctx.args) {