aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/pronoundb/index.ts
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2023-03-25 01:30:24 +0000
committerGitHub <noreply@github.com>2023-03-25 01:30:24 +0000
commitb90392576e81fe2d0e665039ec832d47dc6a731c (patch)
treeb0386e13c0af7191fbf6fdeb8c3648bbf0f1d2bc /src/plugins/pronoundb/index.ts
parente143260891e25bc133ab5e2f94b5831bdf63f3dc (diff)
downloadVencord-b90392576e81fe2d0e665039ec832d47dc6a731c.tar.gz
Vencord-b90392576e81fe2d0e665039ec832d47dc6a731c.tar.bz2
Vencord-b90392576e81fe2d0e665039ec832d47dc6a731c.zip
PronounDB: Add support for compact mode & clean up (#604)
Diffstat (limited to 'src/plugins/pronoundb/index.ts')
-rw-r--r--src/plugins/pronoundb/index.ts35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts
index 820b66e..5587191 100644
--- a/src/plugins/pronoundb/index.ts
+++ b/src/plugins/pronoundb/index.ts
@@ -16,11 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import "./styles.css";
+
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import PronounsAboutComponent from "./components/PronounsAboutComponent";
-import PronounsChatComponent from "./components/PronounsChatComponent";
+import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent";
import PronounsProfileWrapper from "./components/PronounsProfileWrapper";
export enum PronounsFormat {
@@ -30,22 +32,30 @@ export enum PronounsFormat {
export default definePlugin({
name: "PronounDB",
- authors: [Devs.Tyman],
+ authors: [Devs.Tyman, Devs.TheKodeToad],
description: "Adds pronouns to user messages using pronoundb",
patches: [
- // Patch the chat timestamp element
+ // Add next to username (compact mode)
+ {
+ find: "showCommunicationDisabledStyles",
+ replacement: {
+ match: /("span",{id:\i,className:\i,children:\i}\))/,
+ replace: "$1, $self.CompactPronounsChatComponentWrapper(e)"
+ }
+ },
+ // Patch the chat timestamp element (normal mode)
{
find: "showCommunicationDisabledStyles",
replacement: {
- match: /(?<=return\s*\(0,\w{1,3}\.jsxs?\)\(.+!\w{1,3}&&)(\(0,\w{1,3}.jsxs?\)\(.+?\{.+?\}\))/,
- replace: "[$1, $self.PronounsChatComponent(e)]"
+ match: /(?<=return\s*\(0,\i\.jsxs?\)\(.+!\i&&)(\(0,\i.jsxs?\)\(.+?\{.+?\}\))/,
+ replace: "[$1, $self.PronounsChatComponentWrapper(e)]"
}
},
// Hijack the discord pronouns section and add a wrapper around the text section
{
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
replacement: {
- match: /\(0,.\.jsx\)\((?<PronounComponent>.{1,2}\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>.{1,2})\.pronouns.+?})\)/,
+ match: /\(0,.\.jsx\)\((?<PronounComponent>\i\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>\i)\.pronouns.+?})\)/,
replace: "$<fullProps>&&$self.PronounsProfileWrapper($<PronounComponent>,$<pronounProps>,$<fullProps>)"
}
},
@@ -79,10 +89,21 @@ export default definePlugin({
type: OptionType.BOOLEAN,
description: "Enable or disable showing pronouns for the current user",
default: true
+ },
+ showInMessages: {
+ type: OptionType.BOOLEAN,
+ description: "Show in messages",
+ default: true
+ },
+ showInProfile: {
+ type: OptionType.BOOLEAN,
+ description: "Show in profile",
+ default: true
}
},
settingsAboutComponent: PronounsAboutComponent,
// Re-export the components on the plugin object so it is easily accessible in patches
- PronounsChatComponent,
+ PronounsChatComponentWrapper,
+ CompactPronounsChatComponentWrapper,
PronounsProfileWrapper
});