fix first set of plugins (#2591)

* Add back mangled webpack searching

* Make window non enumerable in all cases

* fix some webpack commons

* oops

* fix more webpack commons

* fix some finds

* fix more webpack commons

* fix common names

* fix reporter

* fix Constants common

* more fix

* fix SettingsStores (return of old SettingsStoreAPI)

* doomsday fix: MutualGroupDMs (#2585)

* fix SettingsStoreAPI

* fix MessageLinkEmbeds

* fix checking uninitialised settings

* doomsday fix: BetterSessions (#2587)

* doomsday fix: ReviewDB and Summaries (#2586)

Co-authored-by: vee <vendicated@riseup.net>

* fix various things that use default/other names

* fix settings

* wbctxmenus

* fix BetterSettings

* wouldnt it be funny if discord reverted again once we're done

* fix ViewIcons

* fix showconnections

* fix FriendsSince

* FakeNitro: fix app icons

* doomsday fix: NoPendingCount (#2590)

---------

Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
Co-authored-by: Amia <9750071+aamiaa@users.noreply.github.com>
Co-authored-by: Manti <67705577+mantikafasi@users.noreply.github.com>
This commit is contained in:
vee 2024-06-19 03:04:15 +02:00 committed by GitHub
parent db6b1f5aaf
commit d6f1209438
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 393 additions and 147 deletions

View file

@ -209,14 +209,33 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
// There are (at the time of writing) 11 modules exporting the window
// Make these non enumerable to improve webpack search performance
if (require.c && (exports === window || exports?.default === window)) {
Object.defineProperty(require.c, id, {
value: require.c[id],
enumerable: false,
configurable: true,
writable: true
});
return;
if (require.c) {
let foundWindow = false;
if (exports === window) {
foundWindow = true;
} else if (typeof exports === "object") {
if (exports?.default === window) {
foundWindow = true;
} else {
for (const nested in exports) if (nested.length <= 3) {
if (exports[nested] === window) {
foundWindow = true;
}
}
}
}
if (foundWindow) {
Object.defineProperty(require.c, id, {
value: require.c[id],
enumerable: false,
configurable: true,
writable: true
});
return;
}
}
for (const callback of moduleListeners) {
@ -232,9 +251,18 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
if (exports && filter(exports)) {
subscriptions.delete(filter);
callback(exports, id);
} else if (exports.default && filter(exports.default)) {
subscriptions.delete(filter);
callback(exports.default, id);
} else if (typeof exports === "object") {
if (exports.default && filter(exports.default)) {
subscriptions.delete(filter);
callback(exports.default, id);
} else {
for (const nested in exports) if (nested.length <= 3) {
if (exports[nested] && filter(exports[nested])) {
subscriptions.delete(filter);
callback(exports[nested], id);
}
}
}
}
} catch (err) {
logger.error("Error while firing callback for Webpack subscription:\n", err, filter, callback);