diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 03322f9a6..036a8c434 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -513,31 +513,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; } } diff --git a/src/main/patcher.ts b/src/main/patcher.ts index 0d79a96f6..f0e3c3ab4 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) { @@ -136,6 +139,9 @@ if (!IS_VANILLA) { } 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"); } diff --git a/src/plugins/anonymiseFileNames/index.tsx b/src/plugins/anonymiseFileNames/index.tsx index 93efa2491..c7f5afe9e 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" diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index dea7e0a13..bbdf160bd 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 })" }, // { diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 5da2a32a2..614993056 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -88,6 +88,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", {