From 92ae62602b3364f30bb69a7d0155bb2a1c0753d3 Mon Sep 17 00:00:00 2001 From: vee Date: Sat, 13 Jul 2024 19:14:22 +0200 Subject: [PATCH 1/3] new plugin MentionAvatars: Shows user avatars inside mentions (#2691) --- src/plugins/mentionAvatars/README.md | 5 +++ src/plugins/mentionAvatars/index.tsx | 44 +++++++++++++++++++++++ src/plugins/mentionAvatars/styles.css | 8 +++++ src/plugins/roleColorEverywhere/index.tsx | 2 +- src/plugins/showHiddenThings/index.ts | 39 +++++++------------- src/plugins/viewIcons/index.tsx | 10 +++--- 6 files changed, 75 insertions(+), 33 deletions(-) create mode 100644 src/plugins/mentionAvatars/README.md create mode 100644 src/plugins/mentionAvatars/index.tsx create mode 100644 src/plugins/mentionAvatars/styles.css diff --git a/src/plugins/mentionAvatars/README.md b/src/plugins/mentionAvatars/README.md new file mode 100644 index 000000000..912b51916 --- /dev/null +++ b/src/plugins/mentionAvatars/README.md @@ -0,0 +1,5 @@ +# MentionAvatars + +Shows user avatars inside mentions + +![](https://github.com/user-attachments/assets/fc76ea47-5e19-4063-a592-c57785a75cc7) diff --git a/src/plugins/mentionAvatars/index.tsx b/src/plugins/mentionAvatars/index.tsx new file mode 100644 index 000000000..549693142 --- /dev/null +++ b/src/plugins/mentionAvatars/index.tsx @@ -0,0 +1,44 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./styles.css"; + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { SelectedGuildStore, useState } from "@webpack/common"; +import { User } from "discord-types/general"; + +export default definePlugin({ + name: "MentionAvatars", + description: "Shows user avatars inside mentions", + authors: [Devs.Ven], + + patches: [{ + find: ".USER_MENTION)", + replacement: { + match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/, + replace: "children:$self.renderUsername({username:$1,user:$2})" + } + }], + + renderUsername: ErrorBoundary.wrap((props: { user: User, username: string; }) => { + const { user, username } = props; + const [isHovering, setIsHovering] = useState(false); + + if (!user) return <>@{username}; + + return ( + setIsHovering(true)} + onMouseLeave={() => setIsHovering(false)} + > + + @{username} + + ); + }, { noop: true }) +}); diff --git a/src/plugins/mentionAvatars/styles.css b/src/plugins/mentionAvatars/styles.css new file mode 100644 index 000000000..33404d7b5 --- /dev/null +++ b/src/plugins/mentionAvatars/styles.css @@ -0,0 +1,8 @@ +.vc-mentionAvatars-avatar { + vertical-align: middle; + width: 1em; + height: 1em; + margin: 0 4px 0.2rem 2px; + border-radius: 50%; + box-sizing: border-box; +} diff --git a/src/plugins/roleColorEverywhere/index.tsx b/src/plugins/roleColorEverywhere/index.tsx index 37177caad..3e7d216b7 100644 --- a/src/plugins/roleColorEverywhere/index.tsx +++ b/src/plugins/roleColorEverywhere/index.tsx @@ -60,7 +60,7 @@ export default definePlugin({ find: 'location:"UserMention', replacement: [ { - match: /user:(\i),channel:(\i).{0,400}?"@"\.concat\(.+?\)/, + match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/, replace: "$&,color:$self.getUserColor($1?.id,{channelId:$2?.id})" } ], diff --git a/src/plugins/showHiddenThings/index.ts b/src/plugins/showHiddenThings/index.ts index 599bcd36d..90bb345ef 100644 --- a/src/plugins/showHiddenThings/index.ts +++ b/src/plugins/showHiddenThings/index.ts @@ -18,34 +18,21 @@ import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; +import definePlugin, { OptionType, PluginSettingDef } from "@utils/types"; + +const opt = (description: string) => ({ + type: OptionType.BOOLEAN, + description, + default: true, + restartNeeded: true +} satisfies PluginSettingDef); const settings = definePluginSettings({ - showTimeouts: { - type: OptionType.BOOLEAN, - description: "Show member timeout icons in chat.", - default: true, - }, - showInvitesPaused: { - type: OptionType.BOOLEAN, - description: "Show the invites paused tooltip in the server list.", - default: true, - }, - showModView: { - type: OptionType.BOOLEAN, - description: "Show the member mod view context menu item in all servers.", - default: true, - }, - disableDiscoveryFilters: { - type: OptionType.BOOLEAN, - description: "Disable filters in Server Discovery search that hide servers that don't meet discovery criteria.", - default: true, - }, - disableDisallowedDiscoveryFilters: { - type: OptionType.BOOLEAN, - description: "Disable filters in Server Discovery search that hide NSFW & disallowed servers.", - default: true, - }, + showTimeouts: opt("Show member timeout icons in chat."), + showInvitesPaused: opt("Show the invites paused tooltip in the server list."), + showModView: opt("Show the member mod view context menu item in all servers."), + disableDiscoveryFilters: opt("Disable filters in Server Discovery search that hide servers that don't meet discovery criteria."), + disableDisallowedDiscoveryFilters: opt("Disable filters in Server Discovery search that hide NSFW & disallowed servers."), }); migratePluginSettings("ShowHiddenThings", "ShowTimeouts"); diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 6ca9bf2d1..6bde04be0 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -186,12 +186,10 @@ export default definePlugin({ // Avatar component used in User DMs "User Profile" popup in the right and Profiles Modal pfp { find: ".overlay:void 0,status:", - replacement: [ - ...[/"PRESS_VIEW_PROFILE".+?(?=children:)(?<=avatarSrc:(\i).+?)/, /avatarSrc:(\i),eventHandlers:(\i).+?"div",{...\2,/].map(match => ({ - match, - replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," - })) - ] + replacement: { + match: /avatarSrc:(\i),eventHandlers:(\i).+?"div",{...\2,/, + replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," + } }, // Old Profiles Modal pfp { From 0e7570ad713a91959c6b3095cf426698b7907e5f Mon Sep 17 00:00:00 2001 From: Hen <68553709+henmalib@users.noreply.github.com> Date: Sat, 13 Jul 2024 19:17:00 +0200 Subject: [PATCH 2/3] InvisibleChat: fix embeds missing decrypted content (#2655) --- src/plugins/invisibleChat.desktop/index.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/invisibleChat.desktop/index.tsx b/src/plugins/invisibleChat.desktop/index.tsx index 01199d999..c7eb29e7e 100644 --- a/src/plugins/invisibleChat.desktop/index.tsx +++ b/src/plugins/invisibleChat.desktop/index.tsx @@ -133,10 +133,12 @@ export default definePlugin({ message: message, channel: ChannelStore.getChannel(message.channel_id), onClick: async () => { - await iteratePasswords(message).then((res: string | false) => { - if (res) return void this.buildEmbed(message, res); - return void buildDecModal({ message }); - }); + const res = await iteratePasswords(message); + + if (res) + this.buildEmbed(message, res); + else + buildDecModal({ message }); } } : null; @@ -169,9 +171,9 @@ export default definePlugin({ message.embeds.push({ type: "rich", - title: "Decrypted Message", + rawTitle: "Decrypted Message", color: "0x45f5f5", - description: revealed, + rawDescription: revealed, footer: { text: "Made with ❤️ by c0dine and Sammy!", }, From bbf43c3073a6393d9c6cbc1e815790ecdcf2505d Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 13 Jul 2024 20:34:16 +0200 Subject: [PATCH 3/3] fix(FakeNitro): do not convert applicable twitch sub emotes --- src/plugins/fakeNitro/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index ddcabcbdf..efc194954 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -24,7 +24,7 @@ import { getCurrentGuild } from "@utils/discord"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack"; -import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; +import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; import type { Emoji } from "@webpack/types"; import type { Message } from "discord-types/general"; import { applyPalette, GIFEncoder, quantize } from "gifenc"; @@ -818,7 +818,14 @@ export default definePlugin({ if (isUnusableRoleSubscriptionEmoji(e, this.guildId, true)) return false; - if (this.canUseEmotes) + let isUsableTwitchSubEmote = false; + if (e.managed && e.guildId) { + // @ts-ignore outdated type + const myRoles = GuildMemberStore.getSelfMember(e.guildId)?.roles ?? []; + isUsableTwitchSubEmote = e.roles.some(r => myRoles.includes(r)); + } + + if (this.canUseEmotes || isUsableTwitchSubEmote) return e.guildId === this.guildId || hasExternalEmojiPerms(channelId); else return !e.animated && e.guildId === this.guildId;