|
|
@ -31,17 +31,23 @@ const logger = new Logger("WebpackInterceptor", "#8caaee");
|
|
|
|
if (window[WEBPACK_CHUNK]) {
|
|
|
|
if (window[WEBPACK_CHUNK]) {
|
|
|
|
logger.info(`Patching ${WEBPACK_CHUNK}.push (was already existant, likely from cache!)`);
|
|
|
|
logger.info(`Patching ${WEBPACK_CHUNK}.push (was already existant, likely from cache!)`);
|
|
|
|
_initWebpack(window[WEBPACK_CHUNK]);
|
|
|
|
_initWebpack(window[WEBPACK_CHUNK]);
|
|
|
|
patchPush();
|
|
|
|
patchPush(window[WEBPACK_CHUNK]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Object.defineProperty(window, WEBPACK_CHUNK, {
|
|
|
|
Object.defineProperty(window, WEBPACK_CHUNK, {
|
|
|
|
get: () => webpackChunk,
|
|
|
|
get: () => webpackChunk,
|
|
|
|
set: v => {
|
|
|
|
set: v => {
|
|
|
|
if (v?.push !== Array.prototype.push && _initWebpack(v)) {
|
|
|
|
if (v?.push) {
|
|
|
|
logger.info(`Patching ${WEBPACK_CHUNK}.push`);
|
|
|
|
if (!v.push.$$vencordOriginal) {
|
|
|
|
patchPush();
|
|
|
|
logger.info(`Patching ${WEBPACK_CHUNK}.push`);
|
|
|
|
// @ts-ignore
|
|
|
|
patchPush(v);
|
|
|
|
delete window[WEBPACK_CHUNK];
|
|
|
|
}
|
|
|
|
window[WEBPACK_CHUNK] = v;
|
|
|
|
|
|
|
|
|
|
|
|
if (_initWebpack(v)) {
|
|
|
|
|
|
|
|
logger.info("Successfully initialised Vencord webpack");
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
delete window[WEBPACK_CHUNK];
|
|
|
|
|
|
|
|
window[WEBPACK_CHUNK] = v;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
webpackChunk = v;
|
|
|
|
webpackChunk = v;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -49,7 +55,7 @@ if (window[WEBPACK_CHUNK]) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function patchPush() {
|
|
|
|
function patchPush(webpackGlobal: any) {
|
|
|
|
function handlePush(chunk: any) {
|
|
|
|
function handlePush(chunk: any) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const modules = chunk[1];
|
|
|
|
const modules = chunk[1];
|
|
|
@ -213,13 +219,19 @@ function patchPush() {
|
|
|
|
logger.error("Error in handlePush", err);
|
|
|
|
logger.error("Error in handlePush", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return handlePush.original.call(window[WEBPACK_CHUNK], chunk);
|
|
|
|
return handlePush.$$vencordOriginal.call(webpackGlobal, chunk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handlePush.original = window[WEBPACK_CHUNK].push;
|
|
|
|
handlePush.$$vencordOriginal = webpackGlobal.push;
|
|
|
|
Object.defineProperty(window[WEBPACK_CHUNK], "push", {
|
|
|
|
Object.defineProperty(webpackGlobal, "push", {
|
|
|
|
get: () => handlePush,
|
|
|
|
get: () => handlePush,
|
|
|
|
set: v => (handlePush.original = v),
|
|
|
|
set(v) {
|
|
|
|
|
|
|
|
Object.defineProperty(this, "push", {
|
|
|
|
|
|
|
|
value: v,
|
|
|
|
|
|
|
|
configurable: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
patchPush(this);
|
|
|
|
|
|
|
|
},
|
|
|
|
configurable: true
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|