fix plugins for latest discord update (#3387)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
sadan4 2025-04-23 14:36:43 -04:00 committed by GitHub
parent e99e89e964
commit cf78ddcfe2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 44 additions and 46 deletions

View file

@ -21,25 +21,14 @@ import { Channel, User } from "discord-types/general/index.js";
import { JSX } from "react"; import { JSX } from "react";
interface DecoratorProps { interface DecoratorProps {
activities: any[]; type: "guild" | "dm";
channel: Channel;
/**
* Only for DM members
*/
channelName?: string;
/**
* Only for server members
*/
currentUser?: User;
guildId?: string;
isMobile: boolean;
isOwner?: boolean;
isTyping: boolean;
selected: boolean;
status: string;
user: User; user: User;
[key: string]: any; /** only present when this is a DM list item */
channel: Channel;
/** only present when this is a guild list item */
isOwner: boolean;
} }
export type MemberListDecoratorFactory = (props: DecoratorProps) => JSX.Element | null; export type MemberListDecoratorFactory = (props: DecoratorProps) => JSX.Element | null;
type OnlyIn = "guilds" | "dms"; type OnlyIn = "guilds" | "dms";
@ -53,18 +42,16 @@ export function removeMemberListDecorator(identifier: string) {
decoratorsFactories.delete(identifier); decoratorsFactories.delete(identifier);
} }
export function __getDecorators(props: DecoratorProps): JSX.Element { export function __getDecorators(props: DecoratorProps, type: "guild" | "dm"): JSX.Element {
const isInGuild = !!(props.guildId);
const decorators = Array.from( const decorators = Array.from(
decoratorsFactories.entries(), decoratorsFactories.entries(),
([key, { render: Decorator, onlyIn }]) => { ([key, { render: Decorator, onlyIn }]) => {
if ((onlyIn === "guilds" && !isInGuild) || (onlyIn === "dms" && isInGuild)) if ((onlyIn === "guilds" && type !== "guild") || (onlyIn === "dms" && type !== "dm"))
return null; return null;
return ( return (
<ErrorBoundary noop key={key} message={`Failed to render ${key} Member List Decorator`}> <ErrorBoundary noop key={key} message={`Failed to render ${key} Member List Decorator`}>
<Decorator {...props} /> <Decorator {...props} type={type} />
</ErrorBoundary> </ErrorBoundary>
); );
} }

View file

@ -63,7 +63,7 @@ export default definePlugin({
required: true, required: true,
patches: [ patches: [
{ {
find: ".FULL_SIZE]:26", find: ".MODAL]:26",
replacement: { replacement: {
match: /(?=;return 0===(\i)\.length\?)(?<=(\i)\.useMemo.+?)/, match: /(?=;return 0===(\i)\.length\?)(?<=(\i)\.useMemo.+?)/,
replace: ";$1=$2.useMemo(()=>[...$self.getBadges(arguments[0].displayProfile),...$1],[$1])" replace: ";$1=$2.useMemo(()=>[...$self.getBadges(arguments[0].displayProfile),...$1],[$1])"

View file

@ -32,21 +32,17 @@ export default definePlugin({
{ {
find: ".lostPermission)", find: ".lostPermission)",
replacement: [ replacement: [
{
match: /let\{[^}]*lostPermissionTooltipText:\i[^}]*\}=(\i),/,
replace: "$&vencordProps=$1,"
},
{ {
match: /children:\[(?=.{0,300},lostPermissionTooltipText:)/, match: /children:\[(?=.{0,300},lostPermissionTooltipText:)/,
replace: "children:[(typeof vencordProps!=='undefined'&&Vencord.Api.MemberListDecorators.__getDecorators(vencordProps))," replace: "children:[Vencord.Api.MemberListDecorators.__getDecorators(arguments[0],'guild'),"
} }
] ]
}, },
{ {
find: "PrivateChannel.renderAvatar", find: "PrivateChannel.renderAvatar",
replacement: { replacement: {
match: /decorators:(\i\.isSystemDM\(\))\?(.+?):null/, match: /decorators:(\i\.isSystemDM\(\)\?.+?:null)/,
replace: "decorators:[Vencord.Api.MemberListDecorators.__getDecorators(arguments[0]),$1?$2:null]" replace: "decorators:[Vencord.Api.MemberListDecorators.__getDecorators(arguments[0],'dm'),$1]"
} }
} }
] ]

View file

@ -32,9 +32,9 @@ export default definePlugin({
} }
}, },
{ {
find: "#{intl::SERVERS}),children", find: ".setGuildsTree(",
replacement: { replacement: {
match: /(?<=#{intl::SERVERS}\),children:)\i\.map\(\i\)/, match: /(?<=#{intl::SERVERS}\),gap:"xs",children:)\i\.map\(.{0,50}\.length\)/,
replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)" replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
} }
} }

View file

@ -9,7 +9,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { getCurrentChannel } from "@utils/discord"; import { getCurrentChannel } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { findComponentByCodeLazy } from "@webpack";
import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common"; import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common";
import { User } from "discord-types/general"; import { User } from "discord-types/general";
@ -19,8 +19,7 @@ interface UserProfileProps {
originalRenderPopout: () => React.ReactNode; originalRenderPopout: () => React.ReactNode;
} }
const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); const UserProfile = findComponentByCodeLazy(".POPOUT,user");
const styles = findByPropsLazy("accountProfilePopoutWrapper");
let openAlternatePopout = false; let openAlternatePopout = false;
let accountPanelRef: React.RefObject<Record<PropertyKey, any> | null> = { current: null }; let accountPanelRef: React.RefObject<Record<PropertyKey, any> | null> = { current: null };
@ -77,7 +76,7 @@ export default definePlugin({
replace: "$self.useAccountPanelRef();$&" replace: "$self.useAccountPanelRef();$&"
}, },
{ {
match: /(\.AVATAR,children:.+?renderPopout:(\(\i,\i\))=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/, match: /(\.AVATAR,children:.+?renderPopout:\((\i),\i\)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})` replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalRenderPopout:()=>{${originalPopout}}})`
}, },
{ {
@ -121,14 +120,18 @@ export default definePlugin({
} }
const currentChannel = getCurrentChannel(); const currentChannel = getCurrentChannel();
if (currentChannel?.getGuildId() == null) { if (currentChannel?.getGuildId() == null || !UserProfile.$$vencordGetWrappedComponent()) {
return originalRenderPopout(); return originalRenderPopout();
} }
return ( return (
<div className={styles.accountProfilePopoutWrapper}> <UserProfile
<UserProfile {...popoutProps} userId={currentUser.id} guildId={currentChannel.getGuildId()} channelId={currentChannel.id} /> {...popoutProps}
</div> user={currentUser}
currentUser={currentUser}
guildId={currentChannel.getGuildId()}
channelId={currentChannel.id}
/>
); );
}, { noop: true }) }, { noop: true })
}); });

View file

@ -29,8 +29,8 @@ export default definePlugin({
{ {
find: "#{intl::GUILD_OWNER}),children:", find: "#{intl::GUILD_OWNER}),children:",
replacement: { replacement: {
match: /,isOwner:(\i),/, match: /(?<=decorators:.{0,200}?isOwner:)\i/,
replace: ",_isOwner:$1=$self.isGuildOwner(e)," replace: "$self.isGuildOwner(arguments[0])"
} }
} }
], ],

View file

@ -24,7 +24,7 @@ export default definePlugin({
patches: [ patches: [
// DM User Sidebar // DM User Sidebar
{ {
find: ".PANEL}),nicknameIcons", find: ".SIDEBAR}),nicknameIcons",
replacement: { replacement: {
match: /#{intl::USER_PROFILE_MEMBER_SINCE}\),.{0,100}userId:(\i\.id)}\)}\)/, match: /#{intl::USER_PROFILE_MEMBER_SINCE}\),.{0,100}userId:(\i\.id)}\)}\)/,
replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:true})" replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:true})"

View file

@ -66,8 +66,8 @@ export default definePlugin({
{ {
find: '="SYSTEM_TAG"', find: '="SYSTEM_TAG"',
replacement: { replacement: {
match: /\i.gradientClassName]\),style:/, match: /(?<=\.username.{0,50}?)style:/,
replace: "$&{color:$self.calculateNameColorForMessageContext(arguments[0])},_style:" replace: "style:{color:$self.calculateNameColorForMessageContext(arguments[0])},_style:"
} }
}, },
{ {

View file

@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import "./style.css";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { isNonNullish } from "@utils/guards"; import { isNonNullish } from "@utils/guards";
@ -95,6 +97,12 @@ export default definePlugin({
{ {
match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/, match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/,
replace: "$1==='MUTUAL_GDMS'?$self.renderMutualGDMs(arguments[0]):$&" replace: "$1==='MUTUAL_GDMS'?$self.renderMutualGDMs(arguments[0]):$&"
},
// Discord adds spacing between each item which pushes our tab off screen.
// set the gap to zero to ensure ours stays on screen
{
match: /className:\i\.tabBar/,
replace: "$& + ' vc-mutual-gdms-tab-bar'"
} }
] ]
}, },

View file

@ -0,0 +1,4 @@
.vc-mutual-gdms-tab-bar {
gap: 0;
justify-content: space-between;
}

View file

@ -30,7 +30,7 @@ export default definePlugin({
find: '.id,"Search Results"', find: '.id,"Search Results"',
replacement: [ replacement: [
{ {
match: /if\(.{1,10}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/, match: /if\(.{1,40}\)(.{1,10}\.show\({.{1,50}#{intl::UNBLOCK_TO_JUMP_TITLE})/,
replace: "if(false)$1" replace: "if(false)$1"
}, },
{ {