diff --git a/package.json b/package.json index f052be31..a02b7dcc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "equicord", "private": "true", - "version": "1.12.1", + "version": "1.12.2", "description": "The other cutest Discord client mod", "homepage": "https://github.com/Equicord/Equicord#readme", "bugs": { @@ -119,4 +119,4 @@ "engines": { "node": ">=18" } -} \ No newline at end of file +} diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts index 08ad25bf..13848cec 100644 --- a/src/utils/quickCss.ts +++ b/src/utils/quickCss.ts @@ -93,11 +93,6 @@ async function initThemes() { document.addEventListener("DOMContentLoaded", () => { initSystemValues(); - - if (!IS_WEB) { - VencordNative.quickCss.addThemeChangeListener(initThemes); - } - initThemes(); toggle(Settings.useQuickCss); @@ -105,6 +100,10 @@ document.addEventListener("DOMContentLoaded", () => { SettingsStore.addChangeListener("enabledThemeLinks", initThemes); SettingsStore.addChangeListener("enabledThemes", initThemes); + + if (!IS_WEB) { + VencordNative.quickCss.addThemeChangeListener(initThemes); + } }); export function initQuickCssThemeStore() { diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 38c8bbe6..3900cad4 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -105,7 +105,11 @@ define(Function.prototype, "m", { } const fileName = stack.match(/\/assets\/(.+?\.js)/)?.[1]; - if (fileName?.includes("libdiscore")) { + + // Currently, sentry and libDiscore Webpack instances are not meant to be patched. + // As an extra measure, take advatange of the fact their files include the names and return early if it's one of them. + // Later down we also include other measures to avoid patching them. + if (["sentry", "libdiscore"].some(name => fileName?.toLowerCase()?.includes(name))) { return; } @@ -119,7 +123,10 @@ define(Function.prototype, "m", { define(this, "p", { value: bundlePath }); clearTimeout(bundlePathTimeout); - if (bundlePath !== "/assets/") { + // libDiscore init Webpack instance always returns a constanst string for the js filename of a chunk. + // In that case, avoid patching this instance, + // as it runs before the main Webpack instance and will make the WebpackRequire fallback not work properly, or init an wrongful main WebpackRequire. + if (bundlePath !== "/assets/" || /(?:=>|{return)"[^"]/.exec(String(this.u))) { return; } @@ -132,9 +139,9 @@ define(Function.prototype, "m", { } }); - // In the past, the sentry Webpack instance which we also wanted to patch used to rely on chunks being loaded before initting sentry. + // In the past, the sentry Webpack instance which we also wanted to patch used to rely on chunks being loaded before initing sentry. // This Webpack instance did not include actual chunk loading, and only awaited for them to be loaded, which means it did not include the bundlePath property. - // To keep backwards compability, in case this is ever the case again, and keep patching this type of instance, we explicity patch instances which include wreq.O and not wreq.p. + // To keep backwards compability, if this is ever the case again, and keep patching this type of instance, we explicity patch instances which include wreq.O and not wreq.p. // Since we cannot check what is the bundlePath of the instance to filter for the Discord bundlePath, we only patch it if wreq.p is not included, // which means the instance relies on another instance which does chunk loading, and that makes it very likely to only target Discord Webpack instances like the old sentry.