Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
TheLazySquid
GitHub Repository: TheLazySquid/GimkitCheat
Path: blob/main/src/exposeValues.ts
8160 views
1
import { getUnsafeWindow } from "./utils";
2
import { storesLoaded } from "./stores";
3
4
export async function exposeValues() {
5
if(!document.body) {
6
await new Promise((res) => document.addEventListener('DOMContentLoaded', res));
7
}
8
9
const script = document.querySelector<HTMLScriptElement>("script[src][type='module']");
10
if(!script) throw new Error("Failed to find script");
11
12
const res = await fetch(script.src);
13
const text = await res.text();
14
const gameScriptUrl = text.match(/FixSpinePlugin-[^.]+\.js/)?.[0];
15
if(!gameScriptUrl) throw new Error("Failed to find game script URL");
16
17
const gameScript = await import(`/assets/${gameScriptUrl}`);
18
const stores = Object.values<any>(gameScript).find(v => v.assignment);
19
20
getUnsafeWindow().stores = stores;
21
storesLoaded.set(true);
22
console.log("GC: Stores loaded");
23
}
24