From 3e732646e5ab83f76b34ec7fdb3d9d8c68faca8d Mon Sep 17 00:00:00 2001 From: V Date: Sat, 12 Aug 2023 05:27:59 +0200 Subject: [PATCH] Fix plugins broken by latest canary update (#1637) * Fix WebContextMenus * BetterGifAltText: futureproof find * Fix pronoundb profile patch * Fix NoScreensharePreview * Fix FakeNitro emote text patch --------- Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> --- src/plugins/betterGifAltText.ts | 2 +- src/plugins/fakeNitro.ts | 2 +- src/plugins/noScreensharePreview.ts | 6 +++--- src/plugins/pronoundb/index.ts | 3 ++- src/plugins/webContextMenus.web.ts | 6 +++--- src/webpack/common/utils.ts | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/plugins/betterGifAltText.ts b/src/plugins/betterGifAltText.ts index dcffc029..4dd30f2d 100644 --- a/src/plugins/betterGifAltText.ts +++ b/src/plugins/betterGifAltText.ts @@ -34,7 +34,7 @@ export default definePlugin({ }, }, { - find: 'preload:"none","aria', + find: ".embedGallerySide", replacement: { match: /(?<==(.{1,3})\.alt.{0,20})\?.{0,5}\.Messages\.GIF/, replace: diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts index cd2dda81..d74a6c0c 100644 --- a/src/plugins/fakeNitro.ts +++ b/src/plugins/fakeNitro.ts @@ -313,7 +313,7 @@ export default definePlugin({ find: ".Messages.EMOJI_POPOUT_PREMIUM_JOINED_GUILD_DESCRIPTION", predicate: () => settings.store.transformEmojis, replacement: { - match: /((\i)=\i\.node,\i=\i\.emojiSourceDiscoverableGuild)(.+?return )(.{0,450}Messages\.EMOJI_POPOUT_PREMIUM_JOINED_GUILD_DESCRIPTION.+?}\))/, + match: /((\i)=\i\.node,\i=\i\.expressionSourceGuild)(.+?return )(.{0,450}Messages\.EMOJI_POPOUT_PREMIUM_JOINED_GUILD_DESCRIPTION.+?}\))/, replace: (_, rest1, node, rest2, reactNode) => `${rest1},fakeNitroNode=${node}${rest2}$self.addFakeNotice("EMOJI",${reactNode},fakeNitroNode.fake)` } } diff --git a/src/plugins/noScreensharePreview.ts b/src/plugins/noScreensharePreview.ts index 50b2a964..df3daadb 100644 --- a/src/plugins/noScreensharePreview.ts +++ b/src/plugins/noScreensharePreview.ts @@ -27,10 +27,10 @@ export default definePlugin({ { find: '("ApplicationStreamPreviewUploadManager")', replacement: [ - "\\i\\.default\\.makeChunkedRequest\\(", - "\\i\\.\\i\\.post\\({url:" + String.raw`\i\.\i\.makeChunkedRequest\(`, + String.raw`\i\.\i\.post\({url:` ].map(match => ({ - match: new RegExp(`(?=return\\[(\\d),${match}\\i\\.\\i\\.STREAM_PREVIEW.+?}\\)\\];)`), + match: new RegExp(String.raw`(?=return\[(\d),${match}\i\.\i\.STREAM_PREVIEW.+?}\)\];)`), replace: (_, code) => `return[${code},Promise.resolve({body:"",status:204})];` })) } diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 8605869b..52fefdc3 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -68,7 +68,8 @@ export default definePlugin({ find: ".USER_PROFILE_ACTIVITY", replacement: [ { - match: /getGlobalName\(\i\);(?<=displayProfile.{0,200})/, + /* FIXME: old name is getGlobalName, new name is getName. Remove optional Global once stable has also migrated */ + match: /\.get(?:Global)?Name\(\i\);(?<=displayProfile.{0,200})/, replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id,true);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;" }, PRONOUN_TOOLTIP_PATCH diff --git a/src/plugins/webContextMenus.web.ts b/src/plugins/webContextMenus.web.ts index 7ec63480..ca295408 100644 --- a/src/plugins/webContextMenus.web.ts +++ b/src/plugins/webContextMenus.web.ts @@ -86,7 +86,7 @@ export default definePlugin({ }, // Fix silly Discord calling the non web support copy { - match: /\w\.default\.copy/, + match: /\i\.\i\.copy/, replace: "Vencord.Webpack.Common.Clipboard.copy" } ] @@ -102,7 +102,7 @@ export default definePlugin({ replace: "if(null==" }, { - match: /return\s*?\[\i\.default\.canCopyImage\(\)/, + match: /return\s*?\[\i\.\i\.canCopyImage\(\)/, replace: "return [true" }, { @@ -158,7 +158,7 @@ export default definePlugin({ }, { // Change calls to DiscordNative.clipboard to us instead - match: /\b\i\.default\.(copy|cut|paste)/g, + match: /\b\i\.\i\.(copy|cut|paste)/g, replace: "$self.$1" } ] diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 40a45da6..2c814de5 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -93,7 +93,7 @@ export const UserUtils = { }; export const Clipboard = mapMangledModuleLazy('document.queryCommandEnabled("copy")||document.queryCommandSupported("copy")', { - copy: filters.byCode(".default.copy("), + copy: filters.byCode(".copy("), SUPPORTS_COPY: x => typeof x === "boolean", });