diff --git a/src/renderer/managers/coremods.ts b/src/renderer/managers/coremods.ts index 4d2b1a845..44819feeb 100644 --- a/src/renderer/managers/coremods.ts +++ b/src/renderer/managers/coremods.ts @@ -76,14 +76,14 @@ export async function stopAll(): Promise { export function runPlaintextPatches(): void { [ - experimentsPlaintext, - notrackPlaintext, - noDevtoolsWarningPlaintext, - messagePopover, - notices, - contextMenu, - languagePlaintext, - settingsPlaintext, - badgesPlaintext, - ].forEach(patchPlaintext); + { patch: experimentsPlaintext, name: "replugged.coremod.experiments" }, + { patch: notrackPlaintext, name: "replugged.coremod.noTrack" }, + { patch: noDevtoolsWarningPlaintext, name: "replugged.coremod.noDevtoolsWarning" }, + { patch: messagePopover, name: "replugged.coremod.messagePopover" }, + { patch: notices, name: "replugged.coremod.notices" }, + { patch: contextMenu, name: "replugged.coremod.contextMenu" }, + { patch: languagePlaintext, name: "replugged.coremod.language" }, + { patch: settingsPlaintext, name: "replugged.coremod.settings" }, + { patch: badgesPlaintext, name: "replugged.coremod.badges" }, + ].forEach(({ patch, name }) => patchPlaintext(patch, name)); } diff --git a/src/renderer/managers/plugins.ts b/src/renderer/managers/plugins.ts index 0797d7cb1..4a7ac6b5f 100644 --- a/src/renderer/managers/plugins.ts +++ b/src/renderer/managers/plugins.ts @@ -176,6 +176,7 @@ export async function runPlaintextPatches(): Promise { }?t=${Date.now()}` ) ).default, + plugin.manifest.id, ); } }), diff --git a/src/renderer/modules/webpack/plaintext-patch.ts b/src/renderer/modules/webpack/plaintext-patch.ts index e5bdb361f..6d241c554 100644 --- a/src/renderer/modules/webpack/plaintext-patch.ts +++ b/src/renderer/modules/webpack/plaintext-patch.ts @@ -15,6 +15,8 @@ export const plaintextPatches: RawPlaintextPatch[] = []; export function patchModuleSource(mod: WebpackModule, id: string): WebpackModule { const originalSource = mod.toString(); + const patchedBy: string[] = []; + const patchedSource = plaintextPatches.reduce((source, patch) => { if ( patch.find && @@ -32,7 +34,7 @@ export function patchModuleSource(mod: WebpackModule, id: string): WebpackModule if (result === source) { return source; } - + patchedBy.push(patch.id); return result; }, originalSource); @@ -44,7 +46,7 @@ export function patchModuleSource(mod: WebpackModule, id: string): WebpackModule return (0, eval)( `${ patchedSource.startsWith("function(") ? `0,${patchedSource}` : patchedSource - }\n//# sourceURL=PatchedWebpack-${id}`, + }\n//Patched by: ${patchedBy.filter(Boolean).join(", ")}\n//# sourceURL=PatchedWebpack-${id}`, ); } catch (err) { logger.error(`PatchedWebpack-${id}`, err); @@ -59,10 +61,11 @@ export function patchModuleSource(mod: WebpackModule, id: string): WebpackModule * @internal * @hidden */ -export function patchPlaintext(patches: PlaintextPatch[]): void { +export function patchPlaintext(patches: PlaintextPatch[], id: string): void { plaintextPatches.push( ...patches.map((patch) => ({ ...patch, + id, replacements: patch.replacements.map((replacement) => typeof replacement === "function" ? replacement diff --git a/src/types/webpack.ts b/src/types/webpack.ts index ee50e8d0e..5e069f0c1 100644 --- a/src/types/webpack.ts +++ b/src/types/webpack.ts @@ -61,6 +61,7 @@ export interface PlaintextPatch { export interface RawPlaintextPatch { find?: string | RegExp; + id: string; check?: (source: string) => boolean; replacements: PlaintextReplacer[]; }