From c2e5dcc384a852fffc86d4098e12289fcc4aa0f5 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 15 May 2025 19:54:09 -0300 Subject: [PATCH 1/3] Fix MessageLogger edit history & misc SHC patches --- src/plugins/messageLogger/index.tsx | 8 ++++---- src/plugins/showHiddenChannels/index.tsx | 17 ++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 25ee395e..3c7aecae 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -462,13 +462,13 @@ export default definePlugin({ ] }, - // Message content renderer { + // Message content renderer find: ".SEND_FAILED,", replacement: { - // Render editHistory in the deepest div for message content - match: /(\)\("div",\{id:.+?children:\[)/, - replace: "$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0]))," + // Render editHistory behind the message content + match: /\.isFailed]:.+?children:\[/, + replace: "$&arguments[0]?.message?.editHistory?.length>0&&$self.renderEdits(arguments[0])," } }, diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 7a3dd9fb..95dee8fd 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -356,15 +356,10 @@ export default definePlugin({ find: "#{intl::CHANNEL_CALL_CURRENT_SPEAKER}", replacement: [ { - // Remove the divider and the open chat button for the HiddenChannelLockScreen - match: /"more-options-popout"\)\),(?<=channel:(\i).+?inCall:(\i).+?)/, - replace: (m, channel, inCall) => `${m}${inCall}||!$self.isHiddenChannel(${channel},true)&&` - }, - { - // Remove invite users button for the HiddenChannelLockScreen - match: /"popup".{0,100}?if\((?<=channel:(\i).+?inCall:(\i).+?)/, - replace: (m, channel, inCall) => `${m}(${inCall}||!$self.isHiddenChannel(${channel},true))&&` - }, + // Remove the open chat button for the HiddenChannelLockScreen + match: /(?<=&&)\i\.push\(.{0,120}"chat-spacer"/, + replace: "(arguments[0]?.inCall||!$self.isHiddenChannel(arguments[0]?.channel,true))&&$&" + } ] }, { @@ -427,8 +422,8 @@ export default definePlugin({ }, { // Remove the open chat button for the HiddenChannelLockScreen - match: /"recents".+?&&(?=\(.+?channelId:(\i)\.id,showRequestToSpeakSidebar)/, - replace: (m, channel) => `${m}!$self.isHiddenChannel(${channel})&&` + match: /(?<=&&)\(0,\i\.jsxs?\).{0,180}\.buttonIcon/, + replace: "!$self.isHiddenChannel(arguments[0]?.channel,true)&&$&" } ] }, From 8023b1be95a7fd3a754bdd305b23f668cf58b34e Mon Sep 17 00:00:00 2001 From: Suffocate <70031311+lolsuffocate@users.noreply.github.com> Date: Fri, 16 May 2025 00:16:51 +0100 Subject: [PATCH 2/3] Fix jumping to patched module source for new React Dev Tools (#3418) --- scripts/build/build.mjs | 12 ++++++------ scripts/build/buildWeb.mjs | 4 ++-- src/webpack/patchWebpack.ts | 2 +- src/webpack/webpack.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index 0d796ddb..7d21cd24 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -112,7 +112,7 @@ const buildConfigs = ([ ...nodeCommonOpts, entryPoints: ["src/main/index.ts"], outfile: "dist/patcher.js", - footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") }, + footer: { js: "//# sourceURL=file:///VencordPatcher\n" + sourceMapFooter("patcher") }, sourcemap, plugins: [ // @ts-ignore this is never undefined @@ -131,7 +131,7 @@ const buildConfigs = ([ outfile: "dist/renderer.js", format: "iife", target: ["esnext"], - footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") }, + footer: { js: "//# sourceURL=file:///VencordRenderer\n" + sourceMapFooter("renderer") }, globalName: "Vencord", sourcemap, plugins: [ @@ -148,7 +148,7 @@ const buildConfigs = ([ ...nodeCommonOpts, entryPoints: ["src/preload.ts"], outfile: "dist/preload.js", - footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") }, + footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") }, sourcemap, define: { ...defines, @@ -162,7 +162,7 @@ const buildConfigs = ([ ...nodeCommonOpts, entryPoints: ["src/main/index.ts"], outfile: "dist/vencordDesktopMain.js", - footer: { js: "//# sourceURL=VencordDesktopMain\n" + sourceMapFooter("vencordDesktopMain") }, + footer: { js: "//# sourceURL=file:///VencordDesktopMain\n" + sourceMapFooter("vencordDesktopMain") }, sourcemap, plugins: [ ...nodeCommonOpts.plugins, @@ -180,7 +180,7 @@ const buildConfigs = ([ outfile: "dist/vencordDesktopRenderer.js", format: "iife", target: ["esnext"], - footer: { js: "//# sourceURL=VencordDesktopRenderer\n" + sourceMapFooter("vencordDesktopRenderer") }, + footer: { js: "//# sourceURL=file:///VencordDesktopRenderer\n" + sourceMapFooter("vencordDesktopRenderer") }, globalName: "Vencord", sourcemap, plugins: [ @@ -197,7 +197,7 @@ const buildConfigs = ([ ...nodeCommonOpts, entryPoints: ["src/preload.ts"], outfile: "dist/vencordDesktopPreload.js", - footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("vencordDesktopPreload") }, + footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("vencordDesktopPreload") }, sourcemap, define: { ...defines, diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs index 33168ff9..824194cf 100644 --- a/scripts/build/buildWeb.mjs +++ b/scripts/build/buildWeb.mjs @@ -82,7 +82,7 @@ const buildConfigs = [ { ...commonOptions, outfile: "dist/browser.js", - footer: { js: "//# sourceURL=VencordWeb" } + footer: { js: "//# sourceURL=file:///VencordWeb" } }, { ...commonOptions, @@ -91,7 +91,7 @@ const buildConfigs = [ ...commonOptions.define, IS_EXTENSION: "true" }, - footer: { js: "//# sourceURL=VencordWeb" } + footer: { js: "//# sourceURL=file:///VencordWeb" } }, { ...commonOptions, diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 7d30ee1f..72effca5 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -581,7 +581,7 @@ function patchFactory(moduleId: PropertyKey, originalFactory: AnyModuleFactory): } code = newCode; - patchedSource = `// Webpack Module ${String(moduleId)} - Patched by ${pluginsList.join(", ")}\n${newCode}\n//# sourceURL=WebpackModule${String(moduleId)}`; + patchedSource = `// Webpack Module ${String(moduleId)} - Patched by ${pluginsList.join(", ")}\n${newCode}\n//# sourceURL=file:///WebpackModule${String(moduleId)}`; patchedFactory = (0, eval)(patchedSource); if (!patchedBy.has(patch.plugin)) { diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index bce50f3d..ec9e99be 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -751,7 +751,7 @@ export function extract(id: string | number) { // This module is NOT ACTUALLY USED! This means putting breakpoints will have NO EFFECT!! 0,${mod.toString()} -//# sourceURL=ExtractedWebpackModule${id} +//# sourceURL=file:///ExtractedWebpackModule${id} `; const extracted = (0, eval)(code); return extracted as Function; From 94b258af4d65976b85edf887f0cc92b242ee87cc Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 16 May 2025 03:55:49 +0200 Subject: [PATCH 3/3] fix canary --- src/webpack/patchWebpack.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 72effca5..baba751f 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -105,6 +105,9 @@ define(Function.prototype, "m", { } const fileName = stack.match(/\/assets\/(.+?\.js)/)?.[1]; + if (fileName?.includes("libdiscore")) { + return; + } // Define a setter for the bundlePath property of WebpackRequire. Only Webpack instances which include chunk loading functionality, // like the main Discord Webpack, have this property.