mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
chore: lint:fix
This commit is contained in:
parent
4d7fa7abb6
commit
e8a8a66397
5 changed files with 22 additions and 13 deletions
|
@ -171,9 +171,10 @@ export default function (client: ScramjetClient, self: typeof window) {
|
||||||
// since the prototype chain is fucked
|
// since the prototype chain is fucked
|
||||||
|
|
||||||
const style = ctx.get() as CSSStyleDeclaration;
|
const style = ctx.get() as CSSStyleDeclaration;
|
||||||
|
|
||||||
return new Proxy(style, {
|
return new Proxy(style, {
|
||||||
get(t, p) {
|
get(t, p) {
|
||||||
let v = Reflect.get(t, p);
|
const v = Reflect.get(t, p);
|
||||||
if (typeof v === "function") {
|
if (typeof v === "function") {
|
||||||
return new Proxy(v, {
|
return new Proxy(v, {
|
||||||
apply(target, thisArg, argArray) {
|
apply(target, thisArg, argArray) {
|
||||||
|
@ -189,6 +190,7 @@ export default function (client: ScramjetClient, self: typeof window) {
|
||||||
if (v == "" || typeof v !== "string") {
|
if (v == "" || typeof v !== "string") {
|
||||||
return Reflect.set(t, p, v);
|
return Reflect.set(t, p, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Reflect.set(t, p, rewriteCss(v, client.meta));
|
return Reflect.set(t, p, rewriteCss(v, client.meta));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,8 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
|
|
||||||
client.Trap("IDBDatabase.prototype.name", {
|
client.Trap("IDBDatabase.prototype.name", {
|
||||||
get(ctx) {
|
get(ctx) {
|
||||||
let name = ctx.get() as string;
|
const name = ctx.get() as string;
|
||||||
|
|
||||||
return name.substring(name.indexOf("@") + 1);
|
return name.substring(name.indexOf("@") + 1);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -47,7 +47,7 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
body: ctx.args[0],
|
body: ctx.args[0],
|
||||||
});
|
});
|
||||||
|
|
||||||
let now = performance.now();
|
const now = performance.now();
|
||||||
while (view.getUint8(0) === 0) {
|
while (view.getUint8(0) === 0) {
|
||||||
if (performance.now() - now > 1000) {
|
if (performance.now() - now > 1000) {
|
||||||
throw new Error("xhr timeout");
|
throw new Error("xhr timeout");
|
||||||
|
@ -85,12 +85,14 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
client.RawTrap(ctx.this, "response", {
|
client.RawTrap(ctx.this, "response", {
|
||||||
get() {
|
get() {
|
||||||
if (ctx.this.responseType === "arraybuffer") return bodyab.buffer;
|
if (ctx.this.responseType === "arraybuffer") return bodyab.buffer;
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
client.RawTrap(ctx.this, "responseXML", {
|
client.RawTrap(ctx.this, "responseXML", {
|
||||||
get() {
|
get() {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
|
|
||||||
return parser.parseFromString(body, "text/xml");
|
return parser.parseFromString(body, "text/xml");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -104,6 +106,7 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
return (header: string) => {
|
return (header: string) => {
|
||||||
const re = new RegExp(`^${header}: (.*)$`, "m");
|
const re = new RegExp(`^${header}: (.*)$`, "m");
|
||||||
const match = re.exec(headers);
|
const match = re.exec(headers);
|
||||||
|
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,6 +66,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||||
if (typeof v === "string" && v.includes("scramjet")) {
|
if (typeof v === "string" && v.includes("scramjet")) {
|
||||||
debugger;
|
debugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ function traverseParsedHtml(
|
||||||
) {
|
) {
|
||||||
let js = node.children[0].data;
|
let js = node.children[0].data;
|
||||||
// node.attribs[`data-scramjet-script-source-src`] = btoa(js);
|
// 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)
|
new TextEncoder().encode(js)
|
||||||
);
|
);
|
||||||
const htmlcomment = /<!--[\s\S]*?-->/g;
|
const htmlcomment = /<!--[\s\S]*?-->/g;
|
||||||
|
@ -272,6 +272,7 @@ export function rewriteSrcset(srcset: string, meta: URLMeta) {
|
||||||
|
|
||||||
function base64ToBytes(base64) {
|
function base64ToBytes(base64) {
|
||||||
const binString = atob(base64);
|
const binString = atob(base64);
|
||||||
|
|
||||||
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,5 +280,6 @@ function bytesToBase64(bytes: Uint8Array) {
|
||||||
const binString = Array.from(bytes, (byte) =>
|
const binString = Array.from(bytes, (byte) =>
|
||||||
String.fromCodePoint(byte)
|
String.fromCodePoint(byte)
|
||||||
).join("");
|
).join("");
|
||||||
|
|
||||||
return btoa(binString);
|
return btoa(binString);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue