From 79e2cb15f1e680fe9a1c7aeb33080fd09d41a85f Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Mon, 30 Dec 2024 15:22:10 +1300 Subject: [PATCH 1/4] QuickReply: Prevent caret from moving when selecting message (#3104) --- src/plugins/quickReply/index.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/plugins/quickReply/index.ts b/src/plugins/quickReply/index.ts index ac2a38705..4a7060c59 100644 --- a/src/plugins/quickReply/index.ts +++ b/src/plugins/quickReply/index.ts @@ -20,7 +20,7 @@ import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { ChannelStore, ComponentDispatch, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; const Kangaroo = findByPropsLazy("jumpToMessage"); @@ -60,24 +60,24 @@ export default definePlugin({ settings, start() { - Dispatcher.subscribe("DELETE_PENDING_REPLY", onDeletePendingReply); - Dispatcher.subscribe("MESSAGE_END_EDIT", onEndEdit); - Dispatcher.subscribe("MESSAGE_START_EDIT", onStartEdit); - Dispatcher.subscribe("CREATE_PENDING_REPLY", onCreatePendingReply); document.addEventListener("keydown", onKeydown); }, stop() { - Dispatcher.unsubscribe("DELETE_PENDING_REPLY", onDeletePendingReply); - Dispatcher.unsubscribe("MESSAGE_END_EDIT", onEndEdit); - Dispatcher.unsubscribe("MESSAGE_START_EDIT", onStartEdit); - Dispatcher.unsubscribe("CREATE_PENDING_REPLY", onCreatePendingReply); document.removeEventListener("keydown", onKeydown); }, -}); -const onDeletePendingReply = () => replyIdx = -1; -const onEndEdit = () => editIdx = -1; + flux: { + DELETE_PENDING_REPLY() { + replyIdx = -1; + }, + MESSAGE_END_EDIT() { + editIdx = -1; + }, + MESSAGE_START_EDIT: onStartEdit, + CREATE_PENDING_REPLY: onCreatePendingReply + } +}); function calculateIdx(messages: Message[], id: string) { const idx = messages.findIndex(m => m.id === id); @@ -109,6 +109,8 @@ function onKeydown(e: KeyboardEvent) { if (!isUp && e.key !== "ArrowDown") return; if (!isCtrl(e) || isAltOrMeta(e)) return; + e.preventDefault(); + if (e.shiftKey) nextEdit(isUp); else @@ -194,9 +196,10 @@ function nextReply(isUp: boolean) { channel, message, shouldMention: shouldMention(message), - showMentionToggle: channel.guild_id !== null && message.author.id !== meId, + showMentionToggle: channel.isPrivate() && message.author.id !== meId, _isQuickReply: true }); + ComponentDispatch.dispatchToLastSubscribed("TEXTAREA_FOCUS"); jumpIfOffScreen(channel.id, message.id); } From 0e813e78d0c55d06f5062312d4aea3db01d0cc97 Mon Sep 17 00:00:00 2001 From: fae <752642+faejr@users.noreply.github.com> Date: Mon, 30 Dec 2024 03:24:29 +0100 Subject: [PATCH 2/4] OpenInApp: Add support for geo.music.apple.com links (#3101) --- src/plugins/openInApp/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/openInApp/index.ts b/src/plugins/openInApp/index.ts index 2d27c2b20..09fc2f3b7 100644 --- a/src/plugins/openInApp/index.ts +++ b/src/plugins/openInApp/index.ts @@ -57,7 +57,7 @@ const UrlReplacementRules: Record = { description: "Open Tidal links in the Tidal app", }, itunes: { - match: /^https:\/\/music\.apple\.com\/([a-z]{2}\/)?(album|artist|playlist|song|curator)\/([^/?#]+)\/?([^/?#]+)?(?:\?.*)?(?:#.*)?$/, + match: /^https:\/\/(?:geo\.)?music\.apple\.com\/([a-z]{2}\/)?(album|artist|playlist|song|curator)\/([^/?#]+)\/?([^/?#]+)?(?:\?.*)?(?:#.*)?$/, replace: (_, lang, type, name, id) => id ? `itunes://music.apple.com/us/${type}/${name}/${id}` : `itunes://music.apple.com/us/${type}/${name}`, description: "Open Apple Music links in the iTunes app" }, From 0fd76ab15a51a8426786b696d422f59bd1250099 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sun, 29 Dec 2024 21:28:22 -0500 Subject: [PATCH 3/4] NoUnblockToJump: Also allow jump for ignored users (#3110) --- src/plugins/noUnblockToJump/README.md | 5 +++ src/plugins/noUnblockToJump/index.ts | 45 ++++++++++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 src/plugins/noUnblockToJump/README.md diff --git a/src/plugins/noUnblockToJump/README.md b/src/plugins/noUnblockToJump/README.md new file mode 100644 index 000000000..326bca3b8 --- /dev/null +++ b/src/plugins/noUnblockToJump/README.md @@ -0,0 +1,5 @@ +# No Unblock To Jump + +Removes the popup preventing you to jump to a message from a blocked/ignored user (eg: in search results) + +![A modal popup telling you to unblock a user to jump their message](https://github.com/user-attachments/assets/0e4b859d-f3b3-4101-9a83-829afb473d1e) diff --git a/src/plugins/noUnblockToJump/index.ts b/src/plugins/noUnblockToJump/index.ts index cde0e19e5..621129269 100644 --- a/src/plugins/noUnblockToJump/index.ts +++ b/src/plugins/noUnblockToJump/index.ts @@ -26,25 +26,46 @@ export default definePlugin({ authors: [Devs.dzshn], patches: [ { + // Clicking on search results to jump find: '.id,"Search Results"', - replacement: { - match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, - replace: "if(false)$1" - } + replacement: [ + { + match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, + replace: "if(false)$1" + }, + { + match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNIGNORE_TO_JUMP_TITLE})/, + replace: "if(false)$1" + }, + ] }, { + // Jump buttton in top right corner of messages find: "renderJumpButton()", - replacement: { - match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, - replace: "if(false)$1" - } + replacement: [ + { + match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, + replace: "if(false)$1" + }, + { + match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNIGNORE_TO_JUMP_TITLE})/, + replace: "if(false)$1" + }, + ] }, { + // Clicking on replied messages to jump find: "flash:!0,returnMessageId", - replacement: { - match: /.\?(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, - replace: "false?$1" - } + replacement: [ + { + match: /.\?(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, + replace: "false?$1" + }, + { + match: /.\?(.{1,10}\.show\({.{1,50}#{intl::UNIGNORE_TO_JUMP_TITLE})/, + replace: "false?$1" + }, + ] } ] }); From 20ed7dc96b1ae687dff21c56481548d50a63396a Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Mon, 30 Dec 2024 00:07:26 -0500 Subject: [PATCH 4/4] new plugin FullUserInChatbox (#2766) --- src/components/ErrorBoundary.tsx | 3 +- .../accountPanelServerProfile/index.tsx | 2 +- src/plugins/fullUserInChatbox/README.md | 9 ++++ src/plugins/fullUserInChatbox/index.tsx | 47 +++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/plugins/fullUserInChatbox/README.md create mode 100644 src/plugins/fullUserInChatbox/index.tsx diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index ea2e02b51..320d40962 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -27,7 +27,7 @@ interface Props { /** Render nothing if an error occurs */ noop?: boolean; /** Fallback component to render if an error occurs */ - fallback?: React.ComponentType>; + fallback?: React.ComponentType>; /** called when an error occurs. The props property is only available if using .wrap */ onError?(data: { error: Error, errorInfo: React.ErrorInfo, props: T; }): void; /** Custom error message */ @@ -81,6 +81,7 @@ const ErrorBoundary = LazyComponent(() => { if (this.props.fallback) return ; diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index fcecffb17..1b468a6d8 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -85,7 +85,7 @@ export default definePlugin({ replace: "$&onRequestClose:$self.onPopoutClose," }, { - match: /(?<=.avatarWrapper,)/, + match: /(?<=\.avatarWrapper,)/, replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu," } ] diff --git a/src/plugins/fullUserInChatbox/README.md b/src/plugins/fullUserInChatbox/README.md new file mode 100644 index 000000000..2401f5897 --- /dev/null +++ b/src/plugins/fullUserInChatbox/README.md @@ -0,0 +1,9 @@ +# Full User In Chatbox + +Adds the full user mention to the textbox + +Adds the avatar if you have mentioned avatars enabled + +Provides the full context menu to make it easy to access the users profile, and other common actions + +https://github.com/user-attachments/assets/cd9edb33-99c8-4c8d-b669-8cddd05f4b45 diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx new file mode 100644 index 000000000..792f0419f --- /dev/null +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -0,0 +1,47 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findComponentByCodeLazy } from "@webpack"; +import { ReactNode } from "react"; + +const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)"); + +interface UserMentionComponentProps { + id: string; + channelId: string; + guildId: string; + OriginalComponent: ReactNode; +} + +export default definePlugin({ + name: "FullUserInChatbox", + description: "Makes the user mention in the chatbox have more functionalities, like left/right clicking", + authors: [Devs.sadan], + + patches: [ + { + find: ':"text":', + replacement: { + match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/, + replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:(()=>{$2})()});" + } + } + ], + + UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => ( + + ), { + fallback: ({ wrappedProps }) => wrappedProps.OriginalComponent + }) +});