fix issues & crashes caused by recent Discord changes (#3231)
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
This commit is contained in:
parent
8dfbb5f9d8
commit
6b0c02daa6
5 changed files with 82 additions and 46 deletions
|
|
@ -12,7 +12,7 @@ import { canonicalizeReplacement } from "@utils/patches";
|
|||
import { Patch, PatchReplacement } from "@utils/types";
|
||||
|
||||
import { traceFunctionWithResults } from "../debug/Tracer";
|
||||
import { _initWebpack, _shouldIgnoreModule, factoryListeners, findModuleId, moduleListeners, waitForSubscriptions, wreq } from "./webpack";
|
||||
import { _blacklistBadModules, _initWebpack, factoryListeners, findModuleId, moduleListeners, waitForSubscriptions, wreq } from "./webpack";
|
||||
import { AnyModuleFactory, AnyWebpackRequire, MaybePatchedModuleFactory, ModuleExports, PatchedModuleFactory, WebpackRequire } from "./wreq.d";
|
||||
|
||||
export const patches = [] as Patch[];
|
||||
|
|
@ -190,6 +190,20 @@ define(Function.prototype, "m", {
|
|||
*/
|
||||
|
||||
define(this, "m", { value: proxiedModuleFactories });
|
||||
|
||||
// Overwrite Webpack's defineExports function to define the export descriptors configurable.
|
||||
// This is needed so we can later blacklist specific exports from Webpack search by making them non-enumerable
|
||||
this.d = function (exports: object, getters: object) {
|
||||
for (const key in getters) {
|
||||
if (Object.hasOwn(getters, key) && !Object.hasOwn(exports, key)) {
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: getters[key],
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
@ -407,19 +421,8 @@ function runFactoryWithWrap(patchedFactory: PatchedModuleFactory, thisArg: unkno
|
|||
return factoryReturn;
|
||||
}
|
||||
|
||||
if (typeof require === "function") {
|
||||
const shouldIgnoreModule = _shouldIgnoreModule(exports);
|
||||
|
||||
if (shouldIgnoreModule) {
|
||||
if (require.c != null) {
|
||||
Object.defineProperty(require.c, module.id, {
|
||||
value: require.c[module.id],
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof require === "function" && require.c) {
|
||||
if (_blacklistBadModules(require.c, exports, module.id)) {
|
||||
return factoryReturn;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue