- commit
- 590921784fbd97a7f944f1c6d3a3d2daa7c0139f
- parent
- 98b870a662afd2b14e8d640e3cd368aa5a99afcf
- author
- Dami <dami.etoile@gmail.com>
| M | scripts/ | 33 | +++++++++++++++--------------- |
@@ -10,25 +10,26 @@ const js = JSON.parse(src.match(/^const JS = (".*");$/m)[1]);
1010 // Every element lookup answers with an object that accepts any property and1111 // any method call, so the script gets through its wiring.1212 const element = () => new Proxy(function () {}, {13- get: (t, k) => (k === Symbol.toPrimitive ? () => "" : k === "classList" ? { toggle() {}, add() {}, remove() {}, contains: () => false } : k === "style" ? { setProperty() {} } : element()),13+ get: (_, k) => (k === Symbol.toPrimitive ? () => "" : k === "classList" ? { toggle() {}, add() {}, remove() {}, contains: () => false } : k === "style" ? { setProperty() {} } : element()),1414 set: () => true,1515 apply: () => element(),1616 });1717 const doc = element();18-const g = globalThis;19-g.document = doc;20-g.window = g;21-g.location = { host: "check.localhost", hostname: "check.localhost", origin: "http://check.localhost", protocol: "http:", hash: "", pathname: "/", search: "" };22-g.localStorage = { getItem: () => null, setItem() {}, removeItem() {} };23-g.history = { replaceState() {} };24-g.navigator = { clipboard: { writeText: async () => {} } };25-g.confirm = () => false;26-g.prompt = () => null;27-g.alert = () => {};28-g.fetch = async () => ({ ok: true, json: async () => ({}), text: async () => "" });29-g.WebSocket = class { close() {} send() {} };30-g.SIGNER_URL = "/signer.js";31-g.addEventListener = () => {};18+const define = (k, v) => Object.defineProperty(globalThis, k, { value: v, configurable: true, writable: true });19+define("document", doc);20+define("window", globalThis);21+define("location", { host: "check.localhost", hostname: "check.localhost", origin: "http://check.localhost", protocol: "http:", hash: "", pathname: "/", search: "" });22+define("localStorage", { getItem: () => null, setItem() {}, removeItem() {} });23+define("history", { replaceState() {} });24+define("navigator", { clipboard: { writeText: async () => {} } });25+define("confirm", () => false);26+define("prompt", () => null);27+define("alert", () => {});28+// fetch never answers, so the boot stops at its first await and only the synchronous start is judged.29+define("fetch", () => new Promise(() => {}));30+define("WebSocket", class { close() {} send() {} });31+define("SIGNER_URL", "/signer.js");32+define("addEventListener", () => {});3233 3334 let failed = null;3435 process.on("unhandledRejection", (e) => { failed = e; });@@ -39,7 +40,7 @@ try {
3940 } catch (e) {4041 failed = e;4142 }42-if (failed && !/fetch|json|network/i.test(String(failed))) {43+if (failed) {4344 console.error("console script fails before it boots:", failed);4445 process.exit(1);4546 }