diff options
author | V <vendicated@riseup.net> | 2023-06-30 15:39:33 +0200 |
---|---|---|
committer | V <vendicated@riseup.net> | 2023-06-30 15:39:33 +0200 |
commit | 13bde79ec8c78a471eb9cf3e6e58f404e8f1bd1f (patch) | |
tree | 97b083f36611449ddc9e273c0702f1edbcc190b0 /src/plugins/pronoundb/index.ts | |
parent | b592defaaf5f92c942b6c2dc3f39c4761a823ca3 (diff) | |
download | Vencord-13bde79ec8c78a471eb9cf3e6e58f404e8f1bd1f.tar.gz Vencord-13bde79ec8c78a471eb9cf3e6e58f404e8f1bd1f.tar.bz2 Vencord-13bde79ec8c78a471eb9cf3e6e58f404e8f1bd1f.zip |
PronounDB: Fix profile patch, add pronoun source to tooltip
Diffstat (limited to 'src/plugins/pronoundb/index.ts')
-rw-r--r-- | src/plugins/pronoundb/index.ts | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index f9e26b1..c996551 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 + ] } ], |