mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 20:55:13 +00:00
fix reporter (#3699)
This commit is contained in:
parent
fd461045b9
commit
7aa1d47193
1 changed files with 21 additions and 10 deletions
|
|
@ -11,6 +11,24 @@ import * as Webpack from "@webpack";
|
|||
import { wreq } from "@webpack";
|
||||
import { AnyModuleFactory } from "webpack";
|
||||
|
||||
function getWebpackChunkMap() {
|
||||
const sym = Symbol();
|
||||
let v: Record<PropertyKey, string> | null = null;
|
||||
|
||||
Object.defineProperty(Object.prototype, sym, {
|
||||
get() {
|
||||
v = this;
|
||||
return "";
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
wreq.u(sym);
|
||||
delete Object.prototype[sym];
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
export async function loadLazyChunks() {
|
||||
const LazyChunkLoaderLogger = new Logger("LazyChunkLoader");
|
||||
|
||||
|
|
@ -153,17 +171,10 @@ export async function loadLazyChunks() {
|
|||
}
|
||||
|
||||
// All chunks Discord has mapped to asset files, even if they are not used anymore
|
||||
const allChunks = [] as PropertyKey[];
|
||||
|
||||
// Matches "id" or id:
|
||||
for (const currentMatch of String(wreq.u).matchAll(/(?:"([\deE]+?)"(?![,}]))|(?:([\deE]+?):)/g)) {
|
||||
const id = currentMatch[1] ?? currentMatch[2];
|
||||
if (id == null) continue;
|
||||
|
||||
const numId = Number(id);
|
||||
allChunks.push(Number.isNaN(numId) ? id : numId);
|
||||
}
|
||||
const chunkMap = getWebpackChunkMap();
|
||||
if (!chunkMap) throw new Error("Failed to get chunk map");
|
||||
|
||||
const allChunks = Object.keys(chunkMap).map(id => Number.isNaN(Number(id)) ? id : Number(id));
|
||||
if (allChunks.length === 0) throw new Error("Failed to get all chunks");
|
||||
|
||||
// Chunks which our regex could not catch to load
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue