From 9871e16e288401935d2f39e8a7344521306cc242 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:11:03 -0300 Subject: [PATCH] fix error spam in non app discord websites --- src/plugins/_core/noTrack.ts | 2 +- src/webpack/patchWebpack.ts | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index 5d84ae89b..fab0ec7a8 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -97,7 +97,7 @@ export default definePlugin({ return; } - const assetPath = stack.match(/\/assets\/.+?\.js/)?.[0]; + const assetPath = stack.match(/http.+?\.js/)?.[0]; if (!assetPath) { return; } diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 033a1a091..9e4e809bf 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -68,7 +68,7 @@ define(Function.prototype, "m", { define(this, "e", { value: ensureChunk }); clearTimeout(setterTimeout); - logger.info("Main Webpack found" + interpolateIfDefined` in ${fileName}` + ", initializing internal references to WebpackRequire"); + logger.info("Main WebpackInstance found" + interpolateIfDefined` in ${fileName}` + ", initializing internal references to WebpackRequire"); _initWebpack(this); } }); @@ -280,7 +280,7 @@ function wrapAndPatchFactory(id: PropertyKey, originalFactory: AnyModuleFactory) // There are (at the time of writing) 11 modules exporting the window // Make these non enumerable to improve webpack search performance - if (typeof require === "function" && require.c != null) { + if (typeof require === "function") { let foundWindow = false; if (exports === window) { @@ -298,12 +298,14 @@ function wrapAndPatchFactory(id: PropertyKey, originalFactory: AnyModuleFactory) } if (foundWindow) { - Object.defineProperty(require.c, id, { - value: require.c[id], - enumerable: false, - configurable: true, - writable: true - }); + if (require.c != null) { + Object.defineProperty(require.c, id, { + value: require.c[id], + enumerable: false, + configurable: true, + writable: true + }); + } return factoryReturn; }