aboutsummaryrefslogtreecommitdiff
path: root/src/webpack/patchWebpack.ts
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-05-30 15:21:24 +0200
committerV <vendicated@riseup.net>2023-05-30 15:23:33 +0200
commita2a33ca62d4651c11829e8d7d0504bbda57fa0f4 (patch)
treeafda4236bde4484abff1b4f3e892b768e03c6d79 /src/webpack/patchWebpack.ts
parentd8cd557fb29833eb36f4ce17c5850bacf2a6e988 (diff)
downloadVencord-a2a33ca62d4651c11829e8d7d0504bbda57fa0f4.tar.gz
Vencord-a2a33ca62d4651c11829e8d7d0504bbda57fa0f4.tar.bz2
Vencord-a2a33ca62d4651c11829e8d7d0504bbda57fa0f4.zip
Fix occasional freezing on firefox (cache related)
Diffstat (limited to 'src/webpack/patchWebpack.ts')
-rw-r--r--src/webpack/patchWebpack.ts36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts
index f33ddc3..f422372 100644
--- a/src/webpack/patchWebpack.ts
+++ b/src/webpack/patchWebpack.ts
@@ -28,21 +28,27 @@ let webpackChunk: any[];
const logger = new Logger("WebpackInterceptor", "#8caaee");
-Object.defineProperty(window, WEBPACK_CHUNK, {
- get: () => webpackChunk,
- set: v => {
- if (v?.push !== Array.prototype.push) {
- logger.info(`Patching ${WEBPACK_CHUNK}.push`);
- _initWebpack(v);
- patchPush();
- // @ts-ignore
- delete window[WEBPACK_CHUNK];
- window[WEBPACK_CHUNK] = v;
- }
- webpackChunk = v;
- },
- configurable: true
-});
+if (window[WEBPACK_CHUNK]) {
+ logger.info(`Patching ${WEBPACK_CHUNK}.push (was already existant, likely from cache!)`);
+ _initWebpack(window[WEBPACK_CHUNK]);
+ patchPush();
+} else {
+ Object.defineProperty(window, WEBPACK_CHUNK, {
+ get: () => webpackChunk,
+ set: v => {
+ if (v?.push !== Array.prototype.push) {
+ logger.info(`Patching ${WEBPACK_CHUNK}.push`);
+ _initWebpack(v);
+ patchPush();
+ // @ts-ignore
+ delete window[WEBPACK_CHUNK];
+ window[WEBPACK_CHUNK] = v;
+ }
+ webpackChunk = v;
+ },
+ configurable: true
+ });
+}
function patchPush() {
function handlePush(chunk: any) {