From 9e9d71d014a185bbdf990a545be4870d36c1b3b9 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:40:47 -0300 Subject: [PATCH 1/6] AccountPanelServerProfile: Fix buttons unusable and request spam --- src/plugins/accountPanelServerProfile/index.tsx | 10 +++++----- src/plugins/fullUserInChatbox/index.tsx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index b6218bf54..e2dc220b7 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -16,7 +16,7 @@ import { User } from "discord-types/general"; interface UserProfileProps { popoutProps: Record; currentUser: User; - OriginalPopout: () => React.ReactNode; + originalRenderPopout: () => React.ReactNode; } const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); @@ -78,7 +78,7 @@ export default definePlugin({ }, { match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, - replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},OriginalPopout:()=>{${originalPopout}}})` + replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})` }, { match: /\.AVATAR,children:.+?(?=renderPopout:)/, @@ -112,17 +112,17 @@ export default definePlugin({ openAlternatePopout = false; }, - UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, OriginalPopout }: UserProfileProps) => { + UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalRenderPopout }: UserProfileProps) => { if ( (settings.store.prioritizeServerProfile && openAlternatePopout) || (!settings.store.prioritizeServerProfile && !openAlternatePopout) ) { - return ; + return originalRenderPopout(); } const currentChannel = getCurrentChannel(); if (currentChannel?.getGuildId() == null) { - return ; + return originalRenderPopout(); } return ( diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx index 4bcc95b6c..5a0c41c01 100644 --- a/src/plugins/fullUserInChatbox/index.tsx +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -16,7 +16,7 @@ interface UserMentionComponentProps { id: string; channelId: string; guildId: string; - OriginalComponent: () => ReactNode; + originalComponent: () => ReactNode; } export default definePlugin({ @@ -29,7 +29,7 @@ export default definePlugin({ find: ':"text":', replacement: { match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/, - replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:()=>{$2}});" + replace: "$1return $self.UserMentionComponent({...arguments[0],originalComponent:()=>{$2}});" } } ], @@ -42,6 +42,6 @@ export default definePlugin({ channelId={props.channelId} /> ), { - fallback: ({ wrappedProps: { OriginalComponent } }) => + fallback: ({ wrappedProps: { originalComponent } }) => originalComponent() }) }); From ea0182a194d22f7caf05bfbda9fcb68f03cc56aa Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 22 Jan 2025 18:03:51 -0300 Subject: [PATCH 2/6] Fix BetterUploadButton & FixImagesQuality --- src/plugins/betterUploadButton/index.ts | 2 +- src/plugins/fixImagesQuality/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/betterUploadButton/index.ts b/src/plugins/betterUploadButton/index.ts index 2406b71e5..c08d43282 100644 --- a/src/plugins/betterUploadButton/index.ts +++ b/src/plugins/betterUploadButton/index.ts @@ -27,7 +27,7 @@ export default definePlugin({ { find: '"ChannelAttachButton"', replacement: { - match: /\.attachButtonInner,"aria-label":.{0,50},onDoubleClick:(.+?:void 0),\.\.\.(\i),/, + match: /\.attachButtonInner,"aria-label":.{0,50},onDoubleClick:(.+?:void 0),.{0,30}?\.\.\.(\i),/, replace: "$&onClick:$1,onContextMenu:$2.onClick,", }, }, diff --git a/src/plugins/fixImagesQuality/index.ts b/src/plugins/fixImagesQuality/index.ts index 8f84573c0..b62d3c7bc 100644 --- a/src/plugins/fixImagesQuality/index.ts +++ b/src/plugins/fixImagesQuality/index.ts @@ -13,7 +13,7 @@ export default definePlugin({ authors: [Devs.Nuckyz], patches: [ { - find: "getFormatQuality(){", + find: ".handleImageLoad)", replacement: { match: /(?<=null;return )\i\.\i&&\(\i\|\|!\i\.isAnimated.+?:(?=\i&&\(\i="png"\))/, replace: "" From 17f1ef275ef52c8ab539f528247df50022d81550 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Thu, 23 Jan 2025 07:33:11 +0700 Subject: [PATCH 3/6] CustomRPC: improve rich presence preview & UX (#3159) Co-authored-by: Vendicated --- src/plugins/customRPC/index.tsx | 57 ++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index f4b9ab060..64aea76aa 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -19,6 +19,7 @@ import { definePluginSettings, Settings } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import { ErrorCard } from "@components/ErrorCard"; +import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; import { Devs } from "@utils/constants"; import { isTruthy } from "@utils/guards"; @@ -27,15 +28,14 @@ import { classes } from "@utils/misc"; import { useAwaiter } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; -import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common"; +import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, React, UserStore } from "@webpack/common"; const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color"); -const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile"); +const ActivityView = findComponentByCodeLazy('location:"UserProfileActivityCard",'); const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; async function getApplicationAsset(key: string): Promise { - if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\/attachments\//.test(key)) return "mp:" + key.replace(/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//, ""); return (await ApplicationAssetUtils.fetchAssetIds(settings.store.appID!, [key]))[0]; } @@ -169,7 +169,7 @@ const settings = definePluginSettings({ value: TimestampMode.NOW }, { - label: "Same as your current time", + label: "Same as your current time (not reset after 24h)", value: TimestampMode.TIME }, { @@ -269,6 +269,7 @@ function isStreamLinkDisabled() { function isStreamLinkValid(value: string) { if (!isStreamLinkDisabled() && !/https?:\/\/(www\.)?(twitch\.tv|youtube\.com)\/\w+/.test(value)) return "Streaming link must be a valid URL."; + if (value && value.length > 512) return "Streaming link must be not longer than 512 characters."; return true; } @@ -277,8 +278,9 @@ function isTimestampDisabled() { } function isImageKeyValid(value: string) { - if (/https?:\/\/(?!i\.)?imgur\.com\//.test(value)) return "Imgur link must be a direct link to the image. (e.g. https://i.imgur.com/...)"; - if (/https?:\/\/(?!media\.)?tenor\.com\//.test(value)) return "Tenor link must be a direct link to the image. (e.g. https://media.tenor.com/...)"; + if (/https?:\/\/(cdn|media)\.discordapp\.(com|net)\//.test(value)) return "Don't use a Discord link. Use an Imgur image link instead."; + if (/https?:\/\/(?!i\.)?imgur\.com\//.test(value)) return "Imgur link must be a direct link to the image (e.g. https://i.imgur.com/...). Right click the image and click 'Copy image address'"; + if (/https?:\/\/(?!media\.)?tenor\.com\//.test(value)) return "Tenor link must be a direct link to the image (e.g. https://media.tenor.com/...). Right click the GIF and click 'Copy image address'"; return true; } @@ -390,7 +392,7 @@ async function setRpc(disable?: boolean) { export default definePlugin({ name: "CustomRPC", - description: "Allows you to set a custom rich presence.", + description: "Add a fully customisable Rich Presence (Game status) to your Discord profile", authors: [Devs.captain, Devs.AutumnVN, Devs.nin0dev], dependencies: ["UserSettingsAPI"], start: setRpc, @@ -410,7 +412,7 @@ export default definePlugin({ style={{ padding: "1em" }} > Notice - Game activity isn't enabled, people won't be able to see your custom rich presence! + Activity Sharing isn't enabled, people won't be able to see your custom rich presence!