From bdd4b0f14301abd0c3daa11ff664071f6e7f9aaa Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 19:53:19 -0300 Subject: [PATCH 1/9] Make eagerPatches an internal setting --- src/components/VencordSettings/VencordTab.tsx | 5 ----- src/webpack/patchWebpack.ts | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index c9702b435..c0a66fdc7 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -66,11 +66,6 @@ function VencordSettings() { title: "Enable React Developer Tools", note: "Requires a full restart" }, - { - key: "eagerPatches", - title: "Apply Vencord patches before they are needed", - note: "Increases startup timing, but may make app usage more fluid. Note that the difference of having this on or off is minimal." - }, !IS_WEB && (!IS_DISCORD_DESKTOP || !isWindows ? { key: "frameless", title: "Disable the window frame", diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index e00ae0b13..31aaa911c 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -127,10 +127,17 @@ Object.defineProperty(Function.prototype, "O", { configurable: true, set(v: OnChunksLoaded["j"]) { - // @ts-ignore - delete onChunksLoaded.j; - onChunksLoaded.j = v; - originalOnChunksLoaded.j = v; + function setValue(target: any) { + Object.defineProperty(target, "j", { + value: v, + configurable: true, + enumerable: true, + writable: true + }); + } + + setValue(onChunksLoaded); + setValue(originalOnChunksLoaded); } }); } @@ -318,7 +325,7 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) { // @ts-ignore originalFactory.$$vencordRequired = true; for (const proxiedModules of allProxiedModules) { - proxiedModules[id] = originalFactory; + Reflect.set(proxiedModules, id, originalFactory); } if (wreq == null && IS_DEV) { From bd95cc449f7e6e39fb37449520418f2c1f1e8238 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 19:54:40 -0300 Subject: [PATCH 2/9] Exit script if a chunk failed to load --- scripts/generateReport.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 9026ee788..2035ead09 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -386,7 +386,7 @@ async function runtime(token: string) { await Promise.all( Array.from(validChunkGroups) .map(([chunkIds]) => - Promise.all(chunkIds.map(id => wreq.e(id).catch(() => { }))) + Promise.all(chunkIds.map(id => wreq.e(id))) ) ); From f5be78d1017afb0fbfd160ec3991515b93f6ca91 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 20:02:41 -0300 Subject: [PATCH 3/9] Patching toString -> String --- scripts/generateReport.ts | 12 ++++++------ src/components/VencordSettings/PatchHelperTab.tsx | 2 +- src/plugins/devCompanion.dev/index.tsx | 2 +- src/webpack/patchWebpack.ts | 4 ++-- src/webpack/webpack.ts | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 2035ead09..32e6a3262 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -441,7 +441,7 @@ async function runtime(token: string) { Vencord.Webpack.factoryListeners.add(factory => { let isResolved = false; - searchAndLoadLazyChunks(factory.toString()).then(() => isResolved = true); + searchAndLoadLazyChunks(String(factory)).then(() => isResolved = true); chunksSearchPromises.push(() => isResolved); }); @@ -451,7 +451,7 @@ async function runtime(token: string) { setTimeout(() => { for (const factoryId in wreq.m) { let isResolved = false; - searchAndLoadLazyChunks(wreq.m[factoryId].toString()).then(() => isResolved = true); + searchAndLoadLazyChunks(String(wreq.m[factoryId])).then(() => isResolved = true); chunksSearchPromises.push(() => isResolved); } @@ -470,7 +470,7 @@ async function runtime(token: string) { const allChunks = [] as string[]; // Matches "id" or id: - for (const currentMatch of wreq.u.toString().matchAll(/(?:"(\d+?)")|(?:(\d+?):)/g)) { + for (const currentMatch of String(wreq.u).matchAll(/(?:"(\d+?)")|(?:(\d+?):)/g)) { const id = currentMatch[1] ?? currentMatch[2]; if (id == null) continue; @@ -525,7 +525,7 @@ async function runtime(token: string) { const [code, matcher] = args; const module = Vencord.Webpack.findModuleFactory(...code); - if (module) result = module.toString().match(canonicalizeMatch(matcher)); + if (module) result = String(module).match(canonicalizeMatch(matcher)); } else { // @ts-ignore result = Vencord.Webpack[method](...args); @@ -534,8 +534,8 @@ async function runtime(token: string) { if (result == null || ("$$vencordInternal" in result && result.$$vencordInternal() == null)) throw "a rock at ben shapiro"; } catch (e) { let logMessage = searchType; - if (method === "find" || method === "proxyLazyWebpack" || method === "LazyComponentWebpack") logMessage += `(${args[0].toString().slice(0, 147)}...)`; - else if (method === "extractAndLoadChunks") logMessage += `([${args[0].map(arg => `"${arg}"`).join(", ")}], ${args[1].toString()})`; + if (method === "find" || method === "proxyLazyWebpack" || method === "LazyComponentWebpack") logMessage += `(${String(args[0]).slice(0, 147)}...)`; + else if (method === "extractAndLoadChunks") logMessage += `([${args[0].map(arg => `"${arg}"`).join(", ")}], ${String(args[1])})`; else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`; console.log("[PUP_WEBPACK_FIND_FAIL]", logMessage); diff --git a/src/components/VencordSettings/PatchHelperTab.tsx b/src/components/VencordSettings/PatchHelperTab.tsx index e09a1dbf3..f9204669b 100644 --- a/src/components/VencordSettings/PatchHelperTab.tsx +++ b/src/components/VencordSettings/PatchHelperTab.tsx @@ -56,7 +56,7 @@ function ReplacementComponent({ module, match, replacement, setReplacementError const [compileResult, setCompileResult] = React.useState<[boolean, string]>(); const [patchedCode, matchResult, diff] = React.useMemo(() => { - const src: string = fact.toString().replaceAll("\n", ""); + const src: string = String(fact).replaceAll("\n", ""); try { new RegExp(match); diff --git a/src/plugins/devCompanion.dev/index.tsx b/src/plugins/devCompanion.dev/index.tsx index 819360cfe..3842925f2 100644 --- a/src/plugins/devCompanion.dev/index.tsx +++ b/src/plugins/devCompanion.dev/index.tsx @@ -160,7 +160,7 @@ function initWs(isManual = false) { return reply("Expected exactly one 'find' matches, found " + keys.length); const mod = candidates[keys[0]]; - let src = mod.toString().replaceAll("\n", ""); + let src = String(mod).replaceAll("\n", ""); if (src.startsWith("function(")) { src = "0," + src; diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 31aaa911c..27db70970 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -91,7 +91,7 @@ Object.defineProperty(Function.prototype, "O", { const originalOnChunksLoaded = onChunksLoaded; onChunksLoaded = function (result, chunkIds, callback, priority) { - if (callback != null && initCallbackRegex.test(callback.toString())) { + if (callback != null && initCallbackRegex.test(String(callback))) { Object.defineProperty(this, "O", { value: originalOnChunksLoaded, configurable: true, @@ -218,7 +218,7 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) { // cause issues. // // 0, prefix is to turn it into an expression: 0,function(){} would be invalid syntax without the 0, - let code: string = "0," + factory.toString().replaceAll("\n", ""); + let code: string = "0," + String(factory).replaceAll("\n", ""); for (let i = 0; i < patches.length; i++) { const patch = patches[i]; diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 20bd93e3b..adc88ef83 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -218,7 +218,7 @@ export const findBulk = traceFunction("findBulk", function findBulk(...filterFns export const findModuleId = traceFunction("findModuleId", function findModuleId(...code: string[]) { outer: for (const id in wreq.m) { - const str = wreq.m[id].toString(); + const str = String(wreq.m[id]); for (const c of code) { if (!str.includes(c)) continue outer; @@ -420,7 +420,7 @@ export async function extractAndLoadChunks(code: string[], matcher: RegExp = Def return; } - const match = module.toString().match(canonicalizeMatch(matcher)); + const match = String(module).match(canonicalizeMatch(matcher)); if (!match) { const err = new Error("extractAndLoadChunks: Couldn't find chunk loading in module factory code"); logger.warn(err, "Code:", code, "Matcher:", matcher); @@ -501,7 +501,7 @@ export function search(...filters: Array) { outer: for (const id in factories) { const factory = factories[id]; - const str: string = factory.toString(); + const str: string = String(factory); for (const filter of filters) { if (typeof filter === "string" && !str.includes(filter)) continue outer; if (filter instanceof RegExp && !filter.test(str)) continue outer; @@ -529,7 +529,7 @@ export function extract(id: PropertyKey) { // WARNING: This module was extracted to be more easily readable. // This module is NOT ACTUALLY USED! This means putting breakpoints will have NO EFFECT!! -0,${mod.toString()} +0,${String(mod)} //# sourceURL=ExtractedWebpackModule${String(id)} `; const extracted: ModuleFactory = (0, eval)(code); From 8e9434cdd5bb99e8171f80126960141dd4b8f85e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 21:57:12 -0300 Subject: [PATCH 4/9] Make reporter faster --- scripts/generateReport.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 32e6a3262..bb5c39ac7 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -440,10 +440,13 @@ async function runtime(token: string) { wreq = webpackRequire; Vencord.Webpack.factoryListeners.add(factory => { - let isResolved = false; - searchAndLoadLazyChunks(String(factory)).then(() => isResolved = true); + // setImmediate to avoid blocking the factory patching execution while checking for lazy chunks + setTimeout(() => { + let isResolved = false; + searchAndLoadLazyChunks(String(factory)).then(() => isResolved = true); - chunksSearchPromises.push(() => isResolved); + chunksSearchPromises.push(() => isResolved); + }, 0); }); // setImmediate to only search the initial factories after Discord initialized the app From 9740d28530fda6957683cd115adfb3bc73774738 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 24 May 2024 01:05:17 +0200 Subject: [PATCH 5/9] discord why tf would u roll back to 10 days old build??? --- src/plugins/_core/settings.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index b743b0066..fd221d27e 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -56,6 +56,26 @@ export default definePlugin({ } ] }, + // Discord Stable + // FIXME: remove once change merged to stable + { + find: "Messages.ACTIVITY_SETTINGS", + replacement: { + get match() { + switch (Settings.plugins.Settings.settingsLocation) { + case "top": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.USER_SETTINGS/; + case "aboveNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.BILLING_SETTINGS/; + case "belowNitro": return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.APP_SETTINGS/; + case "belowActivity": return /(?<=\{section:(\i\.\i)\.DIVIDER},)\{section:"changelog"/; + case "bottom": return /\{section:(\i\.\i)\.CUSTOM,\s*element:.+?}/; + case "aboveActivity": + default: + return /\{section:(\i\.\i)\.HEADER,\s*label:(\i)\.\i\.Messages\.ACTIVITY_SETTINGS/; + } + }, + replace: "...$self.makeSettingsCategories($1),$&" + } + }, { find: "Messages.ACTIVITY_SETTINGS", replacement: { From a120b35f4f6d14313f1b476e8a6e5091676c2df8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 24 May 2024 01:07:07 +0200 Subject: [PATCH 6/9] Bump to v1.8.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a99b0ad70..04b811e9c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.8.5", + "version": "1.8.6", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From c5541d297d37fd4a737b4d4e1fa2ecf348e1a9d5 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 21:48:12 -0300 Subject: [PATCH 7/9] Optimize slowest patches --- src/plugins/_api/notices.ts | 2 +- src/plugins/alwaysAnimate/index.ts | 4 ++-- src/plugins/betterFolders/index.tsx | 4 ++-- src/plugins/betterSettings/index.tsx | 4 ++-- src/plugins/colorSighted/index.ts | 4 ++-- src/plugins/fakeNitro/index.tsx | 4 ++-- src/plugins/ignoreActivities/index.tsx | 8 ++++---- src/plugins/memberCount/index.tsx | 4 ++-- src/plugins/pinDms/index.tsx | 4 ++-- src/plugins/resurrectHome/index.tsx | 4 ++-- src/plugins/showHiddenChannels/index.tsx | 12 ++++++------ src/plugins/spotifyCrack/index.ts | 4 ++-- src/plugins/superReactionTweaks/index.ts | 4 ++-- src/plugins/viewIcons/index.tsx | 4 ++-- 14 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts index 90ae6ded9..0c6f6e1db 100644 --- a/src/plugins/_api/notices.ts +++ b/src/plugins/_api/notices.ts @@ -29,7 +29,7 @@ export default definePlugin({ find: '"NoticeStore"', replacement: [ { - match: /\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, + match: /(?<=!1;)\i=null;(?=.{0,80}getPremiumSubscription\(\))/g, replace: "if(Vencord.Api.Notices.currentNotice)return false;$&" }, { diff --git a/src/plugins/alwaysAnimate/index.ts b/src/plugins/alwaysAnimate/index.ts index dbec3b4e3..20cb4f974 100644 --- a/src/plugins/alwaysAnimate/index.ts +++ b/src/plugins/alwaysAnimate/index.ts @@ -31,10 +31,10 @@ export default definePlugin({ // Some modules match the find but the replacement is returned untouched noWarn: true, replacement: { - match: /canAnimate:.+?(?=([,}].*?\)))/g, + match: /canAnimate:.+?([,}].*?\))/g, replace: (m, rest) => { const destructuringMatch = rest.match(/}=.+/); - if (destructuringMatch == null) return "canAnimate:!0"; + if (destructuringMatch == null) return `canAnimate:!0${rest}`; return m; } } diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 795f19901..38e1b8412 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -112,8 +112,8 @@ export default definePlugin({ replacement: [ // Create the isBetterFolders variable in the GuildsBar component { - match: /(?<=let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?)(?=}=\i,)/, - replace: ",isBetterFolders" + match: /let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?(?=}=\i,)/, + replace: "$&,isBetterFolders" }, // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { diff --git a/src/plugins/betterSettings/index.tsx b/src/plugins/betterSettings/index.tsx index e90e5c82a..e0267e4b0 100644 --- a/src/plugins/betterSettings/index.tsx +++ b/src/plugins/betterSettings/index.tsx @@ -111,8 +111,8 @@ export default definePlugin({ { // Load menu TOC eagerly find: "Messages.USER_SETTINGS_WITH_BUILD_OVERRIDE.format", replacement: { - match: /(?<=(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?openContextMenuLazy.{0,100}?(await Promise\.all[^};]*?\)\)).*?,)(?=\1\(this)/, - replace: "(async ()=>$2)()," + match: /(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?openContextMenuLazy.{0,100}?(await Promise\.all[^};]*?\)\)).*?,(?=\1\(this)/, + replace: "$&(async ()=>$2)()," }, predicate: () => settings.store.eagerLoad }, diff --git a/src/plugins/colorSighted/index.ts b/src/plugins/colorSighted/index.ts index d741aaae6..025cfb94e 100644 --- a/src/plugins/colorSighted/index.ts +++ b/src/plugins/colorSighted/index.ts @@ -34,9 +34,9 @@ export default definePlugin({ { find: ".AVATAR_STATUS_MOBILE_16;", replacement: { - match: /(?<=fromIsMobile:\i=!0,.+?)status:(\i)/, + match: /(fromIsMobile:\i=!0,.+?)status:(\i)/, // Rename field to force it to always use "online" - replace: 'status_$:$1="online"' + replace: '$1status_$:$2="online"' } } ] diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 9c8af1e7c..4ab0e18ee 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -344,8 +344,8 @@ export default definePlugin({ { // Patch the stickers array to add fake nitro stickers predicate: () => settings.store.transformStickers, - match: /(?<=renderStickersAccessories\((\i)\){let (\i)=\(0,\i\.\i\)\(\i\).+?;)/, - replace: (_, message, stickers) => `${stickers}=$self.patchFakeNitroStickers(${stickers},${message});` + match: /renderStickersAccessories\((\i)\){let (\i)=\(0,\i\.\i\)\(\i\).+?;/, + replace: (m, message, stickers) => `${m}${stickers}=$self.patchFakeNitroStickers(${stickers},${message});` }, { // Filter attachments to remove fake nitro stickers or emojis diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index e2262129d..f687a0caf 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -228,15 +228,15 @@ export default definePlugin({ { find: ".activityTitleText,variant", replacement: { - match: /(?<=\i\.activityTitleText.+?children:(\i)\.name.*?}\),)/, - replace: (_, props) => `$self.renderToggleActivityButton(${props}),` + match: /\.activityTitleText.+?children:(\i)\.name.*?}\),/, + replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` }, }, { find: ".activityCardDetails,children", replacement: { - match: /(?<=\i\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),)/, - replace: (_, props) => `$self.renderToggleActivityButton(${props}),` + match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/, + replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` } } ], diff --git a/src/plugins/memberCount/index.tsx b/src/plugins/memberCount/index.tsx index 92e9a2057..28ecb9db7 100644 --- a/src/plugins/memberCount/index.tsx +++ b/src/plugins/memberCount/index.tsx @@ -70,8 +70,8 @@ export default definePlugin({ { find: ".invitesDisabledTooltip", replacement: { - match: /(?<=\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100})]/, - replace: ",$self.renderTooltip(arguments[0].guild)]" + match: /\.VIEW_AS_ROLES_MENTIONS_WARNING.{0,100}(?=])/, + replace: "$&,$self.renderTooltip(arguments[0].guild)" }, predicate: () => settings.store.toolTip } diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 60484561a..033552593 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -111,8 +111,8 @@ export default definePlugin({ replace: "$self.getScrollOffset(arguments[0],$1,this.props.padding,this.state.preRenderedChildren,$&)" }, { - match: /(?<=scrollToChannel\(\i\){.{1,300})this\.props\.privateChannelIds/, - replace: "[...$&,...$self.getAllUncollapsedChannels()]" + match: /(scrollToChannel\(\i\){.{1,300})(this\.props\.privateChannelIds)/, + replace: "$1[...$2,...$self.getAllUncollapsedChannels()]" }, ] diff --git a/src/plugins/resurrectHome/index.tsx b/src/plugins/resurrectHome/index.tsx index 70827e08f..5193090ea 100644 --- a/src/plugins/resurrectHome/index.tsx +++ b/src/plugins/resurrectHome/index.tsx @@ -134,8 +134,8 @@ export default definePlugin({ { find: '"MessageActionCreators"', replacement: { - match: /(?<=focusMessage\(\i\){.+?)(?=focus:{messageId:(\i)})/, - replace: "after:$1," + match: /focusMessage\(\i\){.+?(?=focus:{messageId:(\i)})/, + replace: "$&after:$1," } }, // Force Server Home instead of Server Guide diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index f08bc2d1d..c120d72d8 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -89,8 +89,8 @@ export default definePlugin({ }, // Remove permission checking for getRenderLevel function { - match: /(?<=getRenderLevel\(\i\){.+?return)!\i\.\i\.can\(\i\.\i\.VIEW_CHANNEL,this\.record\)\|\|/, - replace: " " + match: /(getRenderLevel\(\i\){.+?return)!\i\.\i\.can\(\i\.\i\.VIEW_CHANNEL,this\.record\)\|\|/, + replace: (_, rest) => `${rest} ` } ] }, @@ -159,8 +159,8 @@ export default definePlugin({ replacement: [ // Make the channel appear as muted if it's hidden { - match: /(?<={channel:(\i),name:\i,muted:(\i).+?;)/, - replace: (_, channel, muted) => `${muted}=$self.isHiddenChannel(${channel})?true:${muted};` + match: /{channel:(\i),name:\i,muted:(\i).+?;/, + replace: (m, channel, muted) => `${m}${muted}=$self.isHiddenChannel(${channel})?true:${muted};` }, // Add the hidden eye icon if the channel is hidden { @@ -186,8 +186,8 @@ export default definePlugin({ { // Hide unreads predicate: () => settings.store.hideUnreads === true, - match: /(?<={channel:(\i),name:\i,.+?unread:(\i).+?;)/, - replace: (_, channel, unread) => `${unread}=$self.isHiddenChannel(${channel})?false:${unread};` + match: /{channel:(\i),name:\i,.+?unread:(\i).+?;/, + replace: (m, channel, unread) => `${m}${unread}=$self.isHiddenChannel(${channel})?false:${unread};` } ] }, diff --git a/src/plugins/spotifyCrack/index.ts b/src/plugins/spotifyCrack/index.ts index 1beccad60..37504be2e 100644 --- a/src/plugins/spotifyCrack/index.ts +++ b/src/plugins/spotifyCrack/index.ts @@ -60,8 +60,8 @@ export default definePlugin({ }, { predicate: () => settings.store.keepSpotifyActivityOnIdle, - match: /(?<=shouldShowActivity\(\){.{0,50})&&!\i\.\i\.isIdle\(\)/, - replace: "" + match: /(shouldShowActivity\(\){.{0,50})&&!\i\.\i\.isIdle\(\)/, + replace: "$1" } ] } diff --git a/src/plugins/superReactionTweaks/index.ts b/src/plugins/superReactionTweaks/index.ts index 89197b4c3..7878ba630 100644 --- a/src/plugins/superReactionTweaks/index.ts +++ b/src/plugins/superReactionTweaks/index.ts @@ -42,8 +42,8 @@ export default definePlugin({ { find: ",BURST_REACTION_EFFECT_PLAY", replacement: { - match: /(?<=BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/, - replace: "!$self.shouldPlayBurstReaction($1)" + match: /(BURST_REACTION_EFFECT_PLAY:\i=>{.{50,100})(\i\(\i,\i\))>=\d+/, + replace: "$1!$self.shouldPlayBurstReaction($2)" } }, { diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 359365ee4..09254d511 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -206,8 +206,8 @@ export default definePlugin({ { find: ".avatarPositionPanel", replacement: { - match: /(?<=avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, - replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}" + match: /(avatarWrapperNonUserBot.{0,50})onClick:(\i\|\|\i)\?void 0(?<=,avatarSrc:(\i).+?)/, + replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" } }, // Group DMs top small & large icon From 5e762ddd044afb5d770f47b21044926e557e827f Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 23:18:43 -0300 Subject: [PATCH 8/9] Add names to Modules objects --- src/webpack/patchWebpack.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 27db70970..51d0b9a93 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -167,6 +167,8 @@ Object.defineProperty(Function.prototype, "m", { // The new object which will contain the factories const proxiedModules: WebpackRequire["m"] = {}; + // @ts-ignore + proxiedModules[Symbol.toStringTag] = "ProxiedModules"; for (const id in originalModules) { // If we have eagerPatches enabled we have to patch the pre-populated factories @@ -180,9 +182,10 @@ Object.defineProperty(Function.prototype, "m", { delete originalModules[id]; } - // @ts-ignore - originalModules.$$proxiedModules = proxiedModules; allProxiedModules.add(proxiedModules); + + // @ts-ignore + originalModules[Symbol.toStringTag] = "OriginalModules"; Object.setPrototypeOf(originalModules, new Proxy(proxiedModules, modulesProxyHandler)); } From d8c65599672a0fb4f67b63b3e7f4226a99a8ed86 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 23:56:29 -0300 Subject: [PATCH 9/9] I forgot this --- src/webpack/patchWebpack.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 51d0b9a93..4aa468fe8 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -24,7 +24,7 @@ const modulesProxyHandler: ProxyHandler = { [propName, (...args: any[]) => Reflect[propName](...args)] )), get: (target, p) => { - const propValue = Reflect.get(target, p); + const propValue = Reflect.get(target, p, target); // If the property is not a number, we are not dealing with a module factory // $$vencordOriginal means the factory is already patched, $$vencordRequired means it has already been required @@ -36,7 +36,7 @@ const modulesProxyHandler: ProxyHandler = { // This patches factories if eagerPatches are disabled const patchedFactory = patchFactory(p, propValue); - Reflect.set(target, p, patchedFactory); + Reflect.set(target, p, patchedFactory, target); return patchedFactory; }, @@ -44,10 +44,10 @@ const modulesProxyHandler: ProxyHandler = { // $$vencordRequired means we are resetting the factory to its original after being required // If the property is not a number, we are not dealing with a module factory if (!Settings.eagerPatches || newValue?.$$vencordRequired === true || Number.isNaN(Number(p))) { - return Reflect.set(target, p, newValue); + return Reflect.set(target, p, newValue, target); } - const existingFactory = Reflect.get(target, p); + const existingFactory = Reflect.get(target, p, target); // Check if this factory is already patched // @ts-ignore @@ -59,7 +59,7 @@ const modulesProxyHandler: ProxyHandler = { // Modules are only patched once, so we need to set the patched factory on all the modules for (const proxiedModules of allProxiedModules) { - Reflect.set(proxiedModules, p, patchedFactory); + Reflect.set(proxiedModules, p, patchedFactory, proxiedModules); } return true; @@ -328,7 +328,7 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) { // @ts-ignore originalFactory.$$vencordRequired = true; for (const proxiedModules of allProxiedModules) { - Reflect.set(proxiedModules, id, originalFactory); + Reflect.set(proxiedModules, id, originalFactory, proxiedModules); } if (wreq == null && IS_DEV) {