From 60ccd8cc25d86f10a166a31faf1cb996deb74621 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 15 Feb 2023 22:00:09 -0300 Subject: [PATCH] Various plugin fixes (#492) Co-authored-by: Ven --- src/plugins/fakeNitro.ts | 38 ++++++++++++++++++------ src/plugins/showHiddenChannels/index.tsx | 2 +- src/plugins/vcDoubleClick.ts | 6 ++-- src/plugins/whoReacted.tsx | 7 +++++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts index e5ac3b9ce..dd8ff19e4 100644 --- a/src/plugins/fakeNitro.ts +++ b/src/plugins/fakeNitro.ts @@ -27,6 +27,17 @@ import { ChannelStore, UserStore } from "@webpack/common"; const DRAFT_TYPE = 0; const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR"); +enum EmojiIntentions { + REACTION = 0, + STATUS = 1, + COMMUNITY_CONTENT = 2, + CHAT = 3, + GUILD_STICKER_RELATED_EMOJI = 4, + GUILD_ROLE_BENEFIT_EMOJI = 5, + COMMUNITY_CONTENT_ONLY = 6, + SOUNDBOARD = 7 +} + interface BaseSticker { available: boolean; description: string; @@ -64,17 +75,26 @@ export default definePlugin({ patches: [ { - find: "canUseAnimatedEmojis:function", + find: ".PREMIUM_LOCKED;", predicate: () => Settings.plugins.FakeNitro.enableEmojiBypass === true, replacement: [ - "canUseAnimatedEmojis", - "canUseEmojisEverywhere" - ].map(func => { - return { - match: new RegExp(`${func}:function\\(.+?\\{`), - replace: "$&return true;" - }; - }) + { + match: /(?<=(?\i)=\i\.intention.+?\.(?:canUseEmojisEverywhere|canUseAnimatedEmojis)\(\i)(?=\))/g, + replace: ",$" + }, + { + match: /(?<=,\i=)\i\.\i\.can\(\i\.\i\.USE_EXTERNAL_EMOJIS,\i\)(?=;)/, + replace: "true" + } + ] + }, + { + find: "canUseAnimatedEmojis:function", + predicate: () => Settings.plugins.FakeNitro.enableEmojiBypass === true, + replacement: { + match: /(?<=(?:canUseEmojisEverywhere|canUseAnimatedEmojis):function\(\i)\){/g, + replace: `,fakeNitroIntention){return fakeNitroIntention===undefined||[${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention);` + } }, { find: "canUseAnimatedEmojis:function", diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index a4c7decd9..fe14fe68b 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -263,7 +263,7 @@ export default definePlugin({ replacement: [ { // Remove the divider and the open chat button for the HiddenChannelLockScreen - match: /(?<=function \i\((?\i)\).{1,1800}"more-options-popout"\)\);if\()/, + match: /(?<=function \i\((?\i)\).{1,2000}"more-options-popout"\)\);if\()/, replace: "(!$self.isHiddenChannel($.channel)||$.inCall)&&" }, { diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index 39b8a059c..64c676cfc 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -48,10 +48,10 @@ export default definePlugin({ }, { // channel mentions - find: 'className:"channelMention",iconType:(', + find: ".EMOJI_IN_MESSAGE_HOVER", replacement: { - match: /onClick:(.{1,3}),/, - replace: "onClick:(_vcEv)=>(_vcEv.detail>=2||_vcEv.target.className.includes('MentionText'))&&($1)(),", + match: /onClick:(\i)(?=,.{0,30}className:"channelMention")/, + replace: "onClick:(_vcEv)=>(_vcEv.detail>=2||_vcEv.target.className.includes('MentionText'))&&($1)()", } } ], diff --git a/src/plugins/whoReacted.tsx b/src/plugins/whoReacted.tsx index a260bac00..8ab1c5f7d 100644 --- a/src/plugins/whoReacted.tsx +++ b/src/plugins/whoReacted.tsx @@ -121,6 +121,13 @@ export default definePlugin({ const reactions = getReactionsWithQueue(message, emoji, type); const users = Object.values(reactions).filter(Boolean) as User[]; + for (const user of users) { + FluxDispatcher.dispatch({ + type: "USER_UPDATE", + user + }); + } + return (