From 6cc40eb095cac7a8e27d53eb6144c038778825b9 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 May 2024 01:27:39 -0300 Subject: [PATCH 1/6] okay CodiumAI --- scripts/generateReport.ts | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index ed0739445..2f21033bb 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -507,31 +507,41 @@ async function runtime(token: string) { try { let result = null as any; - if (searchType === "webpackDependantLazy" || searchType === "webpackDependantLazyComponent") { - const [factory] = args; - result = factory(); - } else if (searchType === "extractAndLoadChunks") { - const [code, matcher] = args; - - const module = Vencord.Webpack.findModuleFactory(...code); - if (module) { - result = module.toString().match(Vencord.Util.canonicalizeMatch(matcher)); + switch (searchType) { + case "webpackDependantLazy": + case "webpackDependantLazyComponent": { + const [factory] = args; + result = factory(); + break; } - } else { - const findResult = args.shift(); + case "extractAndLoadChunks": { + const [code, matcher] = args; - if (findResult != null) { - if (findResult.$$vencordCallbackCalled != null && findResult.$$vencordCallbackCalled()) { - result = findResult; + const module = Vencord.Webpack.findModuleFactory(...code); + if (module) { + result = module.toString().match(Vencord.Util.canonicalizeMatch(matcher)); } - if (findResult[Vencord.Util.proxyInnerGet] != null) { - result = findResult[Vencord.Util.proxyInnerValue]; + break; + } + default: { + const findResult = args.shift(); + + if (findResult != null) { + if (findResult.$$vencordCallbackCalled != null && findResult.$$vencordCallbackCalled()) { + result = findResult; + } + + if (findResult[Vencord.Util.proxyInnerGet] != null) { + result = findResult[Vencord.Util.proxyInnerValue]; + } + + if (findResult.$$vencordInner != null) { + result = findResult.$$vencordInner(); + } } - if (findResult.$$vencordInner != null) { - result = findResult.$$vencordInner(); - } + break; } } From f686cba3988dcbefbc5d9d524bea832dfd46c7bf Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 May 2024 05:11:09 -0300 Subject: [PATCH 2/6] Fix not setting property on originalOnChunksLoaded --- src/webpack/patchWebpack.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index f891e38df..311e6f2bc 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -99,6 +99,16 @@ Object.defineProperty(Function.prototype, "O", { }; onChunksLoaded.toString = originalOnChunksLoaded.toString.bind(originalOnChunksLoaded); + + // Returns whether a chunk has been loaded + Object.defineProperty(onChunksLoaded, "j", { + set(v) { + delete onChunksLoaded.j; + onChunksLoaded.j = v; + originalOnChunksLoaded.j = v; + }, + configurable: true + }); } Object.defineProperty(this, "O", { From b335df7fe2d20f24e8d463b10b8ec64f51793a51 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 23 May 2024 03:25:02 +0200 Subject: [PATCH 3/6] MessageLogger: fix edit logging --- src/plugins/messageLogger/index.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index c3a25e1b6..892c819b7 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -295,12 +295,9 @@ export default definePlugin({ // }, { // Pass through editHistory & deleted & original attachments to the "edited message" transformer - match: /interactionData:(\i)\.interactionData/, + match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/, replace: - "interactionData:$1.interactionData," + - "deleted:$1.deleted," + - "editHistory:$1.editHistory," + - "attachments:$1.attachments" + "Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory, attachments:$1.attachments })" }, // { From 869e71112e1555097ba453e227f8404d7c18ad12 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 23 May 2024 03:26:23 +0200 Subject: [PATCH 4/6] fix AnonymiseFilenames --- src/plugins/anonymiseFileNames/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/anonymiseFileNames/index.tsx b/src/plugins/anonymiseFileNames/index.tsx index b424b7a59..526ccd12e 100644 --- a/src/plugins/anonymiseFileNames/index.tsx +++ b/src/plugins/anonymiseFileNames/index.tsx @@ -73,13 +73,13 @@ export default definePlugin({ { find: "instantBatchUpload:function", replacement: { - match: /uploadFiles:(.{1,2}),/, + match: /uploadFiles:(\i),/, replace: "uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=$self.anonymise(f)),$1(...args)),", }, }, { - find: "message.attachments", + find: 'addFilesTo:"message.attachments"', replacement: { match: /(\i.uploadFiles\((\i),)/, replace: "$2.forEach(f=>f.filename=$self.anonymise(f)),$1" From a0778f6a2e786889d11f2b627f2ac03f7696c2e5 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 23 May 2024 03:35:02 +0200 Subject: [PATCH 5/6] work around discord unloading in background --- src/main/patcher.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/patcher.ts b/src/main/patcher.ts index 0d79a96f6..a85702a27 100644 --- a/src/main/patcher.ts +++ b/src/main/patcher.ts @@ -73,6 +73,9 @@ if (!IS_VANILLA) { const original = options.webPreferences.preload; options.webPreferences.preload = join(__dirname, IS_DISCORD_DESKTOP ? "preload.js" : "vencordDesktopPreload.js"); options.webPreferences.sandbox = false; + // work around discord unloading when in background + options.webPreferences.backgroundThrottling = false; + if (settings.frameless) { options.frame = false; } else if (process.platform === "win32" && settings.winNativeTitleBar) { @@ -128,14 +131,8 @@ if (!IS_VANILLA) { process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); - // Monkey patch commandLine to disable WidgetLayering: Fix DevTools context menus https://github.com/electron/electron/issues/38790 - const originalAppend = app.commandLine.appendSwitch; - app.commandLine.appendSwitch = function (...args) { - if (args[0] === "disable-features" && !args[1]?.includes("WidgetLayering")) { - args[1] += ",WidgetLayering"; - } - return originalAppend.apply(this, args); - }; + // work around discord unloading when in background + app.commandLine.appendSwitch("disable-renderer-backgrounding"); } else { console.log("[Vencord] Running in vanilla mode. Not loading Vencord"); } From 775877281ee2f0f439c45a6c0996f52327818754 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 23 May 2024 06:02:57 -0300 Subject: [PATCH 6/6] Revert removal of DevTools context menu fix --- src/main/patcher.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/patcher.ts b/src/main/patcher.ts index a85702a27..f0e3c3ab4 100644 --- a/src/main/patcher.ts +++ b/src/main/patcher.ts @@ -131,7 +131,16 @@ if (!IS_VANILLA) { process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); - // work around discord unloading when in background + // Monkey patch commandLine to disable WidgetLayering: Fix DevTools context menus https://github.com/electron/electron/issues/38790 + const originalAppend = app.commandLine.appendSwitch; + app.commandLine.appendSwitch = function (...args) { + if (args[0] === "disable-features" && !args[1]?.includes("WidgetLayering")) { + args[1] += ",WidgetLayering"; + } + return originalAppend.apply(this, args); + }; + + // Work around discord unloading when in background app.commandLine.appendSwitch("disable-renderer-backgrounding"); } else { console.log("[Vencord] Running in vanilla mode. Not loading Vencord");