diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 3e51544bd..97d24943d 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -52,7 +52,7 @@ export function CompactPronounsChatComponentWrapper({ message }: { message: Mess } function PronounsChatComponent({ message }: { message: Message; }) { - const result = useFormattedPronouns(message.author.id); + const [result] = useFormattedPronouns(message.author.id); return result ? ( @@ -64,7 +64,7 @@ function PronounsChatComponent({ message }: { message: Message; }) { } export function CompactPronounsChatComponent({ message }: { message: Message; }) { - const result = useFormattedPronouns(message.author.id); + const [result] = useFormattedPronouns(message.author.id); return result ? ( diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index f9e26b107..c99655162 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -26,6 +26,11 @@ import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } fro import { useProfilePronouns } from "./pronoundbUtils"; import { settings } from "./settings"; +const PRONOUN_TOOLTIP_PATCH = { + match: /text:(.{0,10}.Messages\.USER_PROFILE_PRONOUNS)(?=,)/, + replace: '$& + (typeof vcPronounSource !== "undefined" ? ` (${vcPronounSource})` : "")' +}; + export default definePlugin({ name: "PronounDB", authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven], @@ -50,18 +55,24 @@ export default definePlugin({ // Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns { find: ".userTagNoNickname", - replacement: { - match: /=(\i)\.pronouns/, - replace: "=$self.useProfilePronouns($1.user.id)" - } + replacement: [ + { + match: /,(\i)=(\i)\.pronouns/, + replace: ",[$1,vcPronounSource]=$self.useProfilePronouns($2.user.id)" + }, + PRONOUN_TOOLTIP_PATCH + ] }, // Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns { find: ".USER_PROFILE_ACTIVITY", - replacement: { - match: /\).showPronouns/, - replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce" - } + replacement: [ + { + match: /getGlobalName\(\i\);(?<=displayProfile.{0,200})/, + replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;" + }, + PRONOUN_TOOLTIP_PATCH + ] } ], diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index 63565bb0d..d47d7d4f2 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -62,7 +62,7 @@ function getDiscordPronouns(id: string) { ); } -export function useFormattedPronouns(id: string): string | null { +export function useFormattedPronouns(id: string): [string | null, string] { // Discord is so stupid you can put tons of newlines in pronouns const discordPronouns = getDiscordPronouns(id)?.trim().replace(NewLineRe, " "); @@ -72,12 +72,12 @@ export function useFormattedPronouns(id: string): string | null { }); if (settings.store.pronounSource === PronounSource.PreferDiscord && discordPronouns) - return discordPronouns; + return [discordPronouns, "Discord"]; if (result && result !== "unspecified") - return formatPronouns(result); + return [formatPronouns(result), "PronounDB"]; - return discordPronouns; + return [discordPronouns, "Discord"]; } export function useProfilePronouns(id: string) {