From fad16cefaf94aba4d536b539e5c05db9bc194282 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 16 Aug 2024 01:59:49 -0400 Subject: [PATCH] Fixes --- .../soundBoardLogger/index.tsx | 46 ++++++++++--- src/plugins/_api/badges/index.tsx | 27 -------- src/plugins/betterNotes/index.tsx | 18 ----- src/plugins/friendsSince/index.tsx | 65 +------------------ src/plugins/mutualGroupDMs/index.tsx | 14 ---- src/plugins/permissionsViewer/index.tsx | 7 -- src/plugins/pronoundb/index.ts | 22 ------- src/plugins/reviewDB/index.tsx | 7 -- src/plugins/reviewDB/style.css | 6 +- src/plugins/showConnections/index.tsx | 28 ++------ src/plugins/viewIcons/index.tsx | 8 --- 11 files changed, 47 insertions(+), 201 deletions(-) diff --git a/src/equicordplugins/soundBoardLogger/index.tsx b/src/equicordplugins/soundBoardLogger/index.tsx index 98521df2..32a0aea6 100644 --- a/src/equicordplugins/soundBoardLogger/index.tsx +++ b/src/equicordplugins/soundBoardLogger/index.tsx @@ -6,17 +6,35 @@ import { addChatBarButton, removeChatBarButton } from "@api/ChatButtons"; import { disableStyle, enableStyle } from "@api/Styles"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; +import { findExportedComponentLazy } from "@webpack"; import { FluxDispatcher } from "@webpack/common"; -import { ChatBarIcon, IconWithTooltip, LogIcon } from "./components/Icons"; +import { ChatBarIcon, LogIcon } from "./components/Icons"; import { openSoundBoardLog } from "./components/SoundBoardLog"; import settings from "./settings"; import { updateLoggedSounds } from "./store"; import styles from "./styles.css?managed"; import { getListeners } from "./utils"; +const HeaderBarIcon = findExportedComponentLazy("Icon", "Divider"); + +function ToolBarHeader() { + return ( + + } + onClick={openSoundBoardLog} + /> + + ); +} + export default definePlugin({ name: "SoundBoardLogger", authors: [Devs.Moxxie, EquicordDevs.Fres, Devs.echo, EquicordDevs.thororen], @@ -24,10 +42,10 @@ export default definePlugin({ patches: [ { predicate: () => settings.store.IconLocation === "toolbar", - find: ".iconBadge}):null", + find: "toolbar:function", replacement: { - match: /className:(\i).toolbar,children:(\i)/, - replace: "className:$1.toolbar,children:$self.toolbarPatch($2)" + match: /(function \i\(\i\){)(.{1,200}toolbar.{1,100}mobileToolbar)/, + replace: "$1$self.toolbarAction(arguments[0]);$2" } } ], @@ -45,9 +63,19 @@ export default definePlugin({ disableStyle(styles); if (settings.store.IconLocation === "chat") removeChatBarButton("vc-soundlog-button"); }, - toolbarPatch: obj => { - if (!obj?.props?.children) return obj; - obj.props.children = [} onClick={openSoundBoardLog} />, ...obj.props.children]; - return obj; - } + toolbarAction(e) { + if (Array.isArray(e.toolbar)) + return e.toolbar.push( + + + + ); + + e.toolbar = [ + + + , + e.toolbar, + ]; + }, }); diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 0dc09370..f86d1af0 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -77,33 +77,6 @@ export default definePlugin({ authors: [Devs.Megu, Devs.Ven, Devs.TheSun], required: true, patches: [ - /* Patch the badge list component on user profiles */ - { - find: 'id:"premium",', - replacement: [ - { - match: /&&(\i)\.push\(\{id:"premium".+?\}\);/, - replace: "$&$1.unshift(...$self.getBadges(arguments[0]));", - }, - { - // alt: "", aria-hidden: false, src: originalSrc - match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/, - // ...badge.props, ..., src: badge.image ?? ... - replace: "...$1.props,$& $1.image??" - }, - // replace their component with ours if applicable - { - match: /(?<=text:(\i)\.description,spacing:12,.{0,50})children:/, - replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :" - }, - // conditionally override their onClick with badge.onClick if it exists - { - match: /href:(\i)\.link/, - replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&" - } - ] - }, - /* new profiles */ { find: ".FULL_SIZE]:26", diff --git a/src/plugins/betterNotes/index.tsx b/src/plugins/betterNotes/index.tsx index b97076bf..63fcf647 100644 --- a/src/plugins/betterNotes/index.tsx +++ b/src/plugins/betterNotes/index.tsx @@ -17,13 +17,9 @@ */ import { definePluginSettings, Settings } from "@api/Settings"; -import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { canonicalizeMatch } from "@utils/patches"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy } from "@webpack"; - -const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection"); const settings = definePluginSettings({ hide: { @@ -72,23 +68,9 @@ export default definePlugin({ match: /\.NOTE_PLACEHOLDER,/, replace: "$&spellCheck:!$self.noSpellCheck," } - }, - { - find: ".popularApplicationCommandIds,", - replacement: { - match: /lastSection:(!?\i)}\),/, - replace: "$&$self.patchPadding({lastSection:$1})," - } } ], - patchPadding: ErrorBoundary.wrap(({ lastSection }) => { - if (!lastSection) return null; - return ( -
- ); - }), - get noSpellCheck() { return settings.store.noSpellCheck; } diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index b0aed7a3..13237504 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -16,8 +16,6 @@ const containerWrapper = findByPropsLazy("memberSinceWrapper"); const container = findByPropsLazy("memberSince"); const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"'); const locale = findByPropsLazy("getLocale"); -const lastSection = findByPropsLazy("lastSection"); - const section = findLazy((m: any) => m.section !== void 0 && m.heading !== void 0 && Object.values(m).length === 2); export default definePlugin({ @@ -25,36 +23,12 @@ export default definePlugin({ description: "Shows when you became friends with someone in the user popout", authors: [Devs.Elvyra, Devs.Antti], patches: [ - // User popup - old layout - { - find: ".USER_PROFILE}};return", - replacement: { - match: /,{userId:(\i.id).{0,30}}\)/, - replace: "$&,$self.friendsSinceOld({ userId: $1 })" - } - }, - // DM User Sidebar - old layout - { - find: ".PROFILE_PANEL,", - replacement: { - match: /,{userId:([^,]+?)}\)/, - replace: "$&,$self.friendsSinceOld({ userId: $1 })" - } - }, - // User Profile Modal - old layout - { - find: ".userInfoSectionHeader,", - replacement: { - match: /(\.Messages\.USER_PROFILE_MEMBER_SINCE.+?userId:(.+?),textClassName:)(\i\.userInfoText)}\)/, - replace: (_, rest, userId, textClassName) => `${rest}!$self.getFriendSince(${userId}) ? ${textClassName} : void 0 }), $self.friendsSinceOld({ userId: ${userId}, textClassName: ${textClassName} })` - } - }, // DM User Sidebar - new layout { find: ".PANEL}),nicknameIcons", replacement: { match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/, - replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})" + replace: "$&,$self.friendsSince({userId:$1,isSidebar:true})" } }, // User Profile Modal - new layout @@ -62,7 +36,7 @@ export default definePlugin({ find: "action:\"PRESS_APP_CONNECTION\"", replacement: { match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id),.{0,100}}\)}\),/, - replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:false})," + replace: "$&,$self.friendsSince({userId:$1,isSidebar:false})," } } ], @@ -78,40 +52,7 @@ export default definePlugin({ } }, - friendsSinceOld: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => { - if (!RelationshipStore.isFriend(userId)) return null; - - const friendsSince = RelationshipStore.getSince(userId); - if (!friendsSince) return null; - - return ( -
- - Friends Since - - -
- {!!getCurrentChannel()?.guild_id && ( - - )} - - {getCreatedAtDate(friendsSince, locale.getLocale())} - -
-
- ); - }, { noop: true }), - - friendsSinceNew: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => { + friendsSince: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => { if (!RelationshipStore.isFriend(userId)) return null; const friendsSince = RelationshipStore.getSince(userId); diff --git a/src/plugins/mutualGroupDMs/index.tsx b/src/plugins/mutualGroupDMs/index.tsx index 7c71e1ed..755aaeff 100644 --- a/src/plugins/mutualGroupDMs/index.tsx +++ b/src/plugins/mutualGroupDMs/index.tsx @@ -58,20 +58,6 @@ export default definePlugin({ authors: [Devs.amia], patches: [ - { - find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Note: the module is lazy-loaded - replacement: { - match: /(?<=\.tabBarItem.{0,50}MUTUAL_GUILDS.+?}\),)(?=.+?(\(0,\i\.jsxs?\)\(.{0,100}id:))/, - replace: '$self.isBotOrSelf(arguments[0].user)?null:$1"MUTUAL_GDMS",children:$self.getMutualGDMCountText(arguments[0].user)}),' - } - }, - { - find: ".USER_INFO_CONNECTIONS:case", - replacement: { - match: /(?<={user:(\i),onClose:(\i)}\);)(?=case \i\.\i\.MUTUAL_FRIENDS)/, - replace: "case \"MUTUAL_GDMS\":return $self.renderMutualGDMs({user: $1, onClose: $2});" - } - }, { find: ".MUTUAL_FRIENDS?(", replacement: [ diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx index eaf90439..afd0df29 100644 --- a/src/plugins/permissionsViewer/index.tsx +++ b/src/plugins/permissionsViewer/index.tsx @@ -175,13 +175,6 @@ export default definePlugin({ settings, patches: [ - { - find: ".popularApplicationCommandIds,", - replacement: { - match: /showBorder:(.{0,60})}\),(?<=guild:(\i),guildMember:(\i),.+?)/, - replace: (m, showBoder, guild, guildMember) => `${m}$self.UserPermissions(${guild},${guildMember},${showBoder}),` - } - }, { find: ".VIEW_ALL_ROLES,", replacement: [ diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 690c5ef5..4f0fb8f3 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -51,28 +51,6 @@ export default definePlugin({ replace: "[$1, $self.PronounsChatComponentWrapper(arguments[0])]" } ] - }, - // Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns - { - find: ".pronouns,children", - replacement: [ - { - match: /{user:(\i),[^}]*,pronouns:(\i),[^}]*}=\i.*?;(?=return)/, - replace: "$&let vcPronounSource;[$2,vcPronounSource]=$self.useProfilePronouns($1.id);" - }, - PRONOUN_TOOLTIP_PATCH - ] - }, - // Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns - { - find: ".nameTagSmall)", - replacement: [ - { - match: /\.getName\(\i\);(?<=displayProfile.{0,200})/, - replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id,true);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;" - }, - PRONOUN_TOOLTIP_PATCH - ] } ], diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index fbe43a61..5dc9da99 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -78,13 +78,6 @@ export default definePlugin({ }, patches: [ - { - find: "showBorder:null", - replacement: { - match: /user:(\i),setNote:\i,canDM.+?\}\)/, - replace: "$&,$self.getReviewsComponent($1)" - } - }, { find: /inline:!1,profileViewedAnalytics:\i}\),/, replacement: { diff --git a/src/plugins/reviewDB/style.css b/src/plugins/reviewDB/style.css index 5e46b757..361db9a6 100644 --- a/src/plugins/reviewDB/style.css +++ b/src/plugins/reviewDB/style.css @@ -3,10 +3,6 @@ --vc-rdb-spacing-size: 8px; } -[class|="section"]:not([class|="lastSection"])+.vc-rdb-view { - margin-top: 12px; -} - .vc-rdb-badge { vertical-align: middle; margin-left: 4px; @@ -184,4 +180,4 @@ .vc-rdb-review:hover>.vc-rdb-buttons { opacity: 1; -} \ No newline at end of file +} diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index 19f6258a..4c9becde 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -24,13 +24,12 @@ import { CopyIcon, LinkIcon } from "@components/Icons"; import { Devs } from "@utils/constants"; import { copyWithToast } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; +import { findByCodeLazy, findByPropsLazy, findStoreLazy } from "@webpack"; import { Text, Tooltip, UserProfileStore } from "@webpack/common"; import { User } from "discord-types/general"; import { VerifiedIcon } from "./VerifiedIcon"; -const Section = findComponentByCodeLazy(".lastSection", "children:"); const ThemeStore = findStoreLazy("ThemeStore"); const useLegacyPlatformType: (platform: string) => string = findByCodeLazy(".TWITTER_LEGACY:"); @@ -75,7 +74,7 @@ interface ConnectionPlatform { } const profilePopoutComponent = ErrorBoundary.wrap( - (props: { user: User; displayProfile?: any; simplified?: boolean; }) => ( + (props: { user: User; displayProfile?: any; }) => ( ( + (props: { id: string; }) => ( @@ -124,14 +122,7 @@ function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: st ); - if (simplified) - return connectionsContainer; - - return ( -
- {connectionsContainer} -
- ); + return connectionsContainer; } function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { @@ -197,13 +188,6 @@ export default definePlugin({ description: "Show connected accounts in user popouts", authors: [Devs.TheKodeToad], patches: [ - { - find: "{isUsingGuildBio:null!==(", - replacement: { - match: /,theme:\i\}\)(?=,.{0,150}setNote:)/, - replace: "$&,$self.profilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile })" - } - }, { find: ".PROFILE_PANEL,", replacement: { @@ -216,7 +200,7 @@ export default definePlugin({ find: '"BiteSizeProfileBody"', replacement: { match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==(\i)\?.+?)/, - replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2, simplified: true })" + replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2 })" } } ], diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 927a974f..e48fa82e 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -192,14 +192,6 @@ export default definePlugin({ }, all: true }, - // Old Profiles Modal pfp - { - find: ".MODAL,hasProfileEffect", - replacement: { - match: /\{src:(\i)(?=,avatarDecoration)/, - replace: "{src:$1,onClick:()=>$self.openImage($1)" - } - }, // Banners ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ find,