diff --git a/src/plugins/_api/memberListDecorators.ts b/src/plugins/_api/memberListDecorators.ts index bf7377e8..1251c357 100644 --- a/src/plugins/_api/memberListDecorators.ts +++ b/src/plugins/_api/memberListDecorators.ts @@ -38,17 +38,10 @@ export default definePlugin({ }, { find: "PrivateChannel.renderAvatar", - replacement: [ - // props are shadowed by nested props so we have to do this - { - match: /let\{[^}]*applicationStream:\i[^}]*\}=(\i),/, - replace: "$&vencordProps=$1," - }, - { - match: /decorators:(\i\.isSystemDM\(\))\?(.+?):null/, - replace: "decorators:[...(typeof vencordProps=='undefined'?[]:Vencord.Api.MemberListDecorators.__getDecorators(vencordProps)), $1?$2:null]" - } - ] + replacement: { + match: /decorators:(\i\.isSystemDM\(\))\?(.+?):null/, + replace: "decorators:[...Vencord.Api.MemberListDecorators.__getDecorators(arguments[0]), $1?$2:null]" + } } ], }); diff --git a/src/plugins/_api/messageDecorations.ts b/src/plugins/_api/messageDecorations.ts index 3f0fd11d..1646ad64 100644 --- a/src/plugins/_api/messageDecorations.ts +++ b/src/plugins/_api/messageDecorations.ts @@ -25,7 +25,7 @@ export default definePlugin({ authors: [Devs.TheSun], patches: [ { - find: "UsernameDecorationTypes:", + find: '"Message Username"', replacement: { match: /currentUserIsPremium:.{0,70}{children:\i(?=}\))/, replace: "$&.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))" diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index a7406aa4..ac5957b3 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -66,7 +66,7 @@ export default definePlugin({ // filter Discord's privateChannelIds list to remove pins, and pass // pinCount as prop. This needs to be here so that the entire DM list receives // updates on pin/unpin - match: /privateChannelIds:(\i),/, + match: /(?<=\i,{channels:\i,)privateChannelIds:(\i),/, replace: "privateChannelIds:$1.filter(c=>!$self.isPinned(c)),pinCount:$self.usePinCount($1)," }, { @@ -75,39 +75,39 @@ export default definePlugin({ // - Section 1: buttons for pages like Friends & Library // - Section 2: our pinned dms // - Section 3: the normal dm list - match: /(?<=renderRow:(\i)\.renderRow,)sections:\[\i,/, + match: /(?<=renderRow:this\.renderRow,)sections:\[\i,/, // For some reason, adding our sections when no private channels are ready yet // makes DMs infinitely load. Thus usePinCount returns either a single element // array with the count, or an empty array. Due to spreading, only in the former // case will an element be added to the outer array // Thanks for the fix, Strencher! - replace: "$&...($1.props.pinCount ?? [])," + replace: "$&...this.props.pinCount??[]," }, { // Patch renderSection (renders the header) to set the text to "Pinned DMs" instead of "Direct Messages" // lookbehind is used to lookup parameter name. We could use arguments[0], but // if children ever is wrapped in an iife, it will break - match: /children:(\i\.\i\.Messages.DIRECT_MESSAGES)(?<=renderSection=function\((\i)\).+?)/, + match: /children:(\i\.\i\.Messages.DIRECT_MESSAGES)(?<=renderSection=(\i)=>{.+?)/, replace: "children:$2.section===1?'Pinned DMs':$1" }, { // Patch channel lookup inside renderDM // channel=channels[channelIds[row]]; - match: /(?<=preRenderedChildren,(\i)=)((\i)\[\i\[\i\]\]);/, + match: /(?<=renderDM=\((\i),(\i)\)=>{.*?this.state,\i=\i\[\i\],\i=)((\i)\[\i\]);/, // section 1 is us, manually get our own channel // section === 1 ? getChannel(channels, row) : channels[channelIds[row]]; - replace: "arguments[0]===1?$self.getChannel($3,arguments[1]):$2;" + replace: "$1===1?$self.getChannel($4,$2):$3;" }, { // Fix getRowHeight's check for whether this is the DMs section // section === DMS - match: /===\i.DMS&&0/, + match: /===\i\.DMS&&0/, // section -1 === DMS replace: "-1$&" }, { // Override scrollToChannel to properly account for pinned channels - match: /(?<=else\{\i\+=)(\i)\*\(.+?(?=;)/, + match: /(?<=scrollTo\(\{to:\i\}\):\(\i\+=)(\d+)\*\(.+?(?=,)/, replace: "$self.getScrollOffset(arguments[0],$1,this.props.padding,this.state.preRenderedChildren,$&)" } ] @@ -115,19 +115,19 @@ export default definePlugin({ // Fix Alt Up/Down navigation { - find: '"mod+alt+right"', + find: ".Routes.APPLICATION_STORE&&", replacement: { - // channelIds = __OVERLAY__ ? stuff : toArray(getStaticPaths()).concat(toArray(channelIds)) - match: /(?<=(\i)=__OVERLAY__\?\i:.{0,10})\.concat\((.{0,10})\)/, + // channelIds = __OVERLAY__ ? stuff : [...getStaticPaths(),...channelIds)] + match: /(?<=\i=__OVERLAY__\?\i:\[\.\.\.\i\(\),\.\.\.)\i/, // ....concat(pins).concat(toArray(channelIds).filter(c => !isPinned(c))) - replace: ".concat($self.getSnapshot()).concat($2.filter(c=>!$self.isPinned(c)))" + replace: "$self.getSnapshot().concat($&.filter(c=>!$self.isPinned(c)))" } }, // fix alt+shift+up/down { - find: '"alt+shift+down"', + find: ".getFlattenedGuildIds()],", replacement: { - match: /(?<=return \i===\i\.ME\?)\i\.\i\.getPrivateChannelIds\(\)/, + match: /(?<=\i===\i\.ME\?)\i\.\i\.getPrivateChannelIds\(\)/, replace: "$self.getSnapshot().concat($&.filter(c=>!$self.isPinned(c)))" } }, diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index 4ccaeea8..6986f69f 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -1,20 +1,8 @@ /* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Sofia Lima - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ + * Vencord, a Discord client mod + * Copyright (c) 2023 rini + * SPDX-License-Identifier: GPL-3.0-or-later + */ import "./styles.css"; @@ -56,13 +44,13 @@ const settings = definePluginSettings({ export default definePlugin({ name: "ShowMeYourName", description: "Display usernames next to nicks, or no nicks at all", - authors: [Devs.dzshn, Devs.TheKodeToad], + authors: [Devs.Rini, Devs.TheKodeToad], patches: [ { - find: ".withMentionPrefix", + find: '"Message Username"', replacement: { - match: /(?<=onContextMenu:\i,children:)\i\+\i/, - replace: "$self.renderUsername(arguments[0])" + match: /(?<=onContextMenu:\i,children:).*?\}/, + replace: "$self.renderUsername(arguments[0])}" } }, ], diff --git a/src/plugins/silentTyping/index.tsx b/src/plugins/silentTyping/index.tsx index a4dc2568..d4cb27ba 100644 --- a/src/plugins/silentTyping/index.tsx +++ b/src/plugins/silentTyping/index.tsx @@ -74,13 +74,13 @@ function SilentTypingToggle(chatBoxProps: { export default definePlugin({ name: "SilentTyping", - authors: [Devs.Ven, Devs.dzshn], + authors: [Devs.Ven, Devs.Rini], description: "Hide that you are typing", patches: [ { - find: "startTyping:", + find: '.dispatch({type:"TYPING_START_LOCAL"', replacement: { - match: /startTyping:.+?,stop/, + match: /startTyping\(\i\){.+?},stop/, replace: "startTyping:$self.startTyping,stop" } }, diff --git a/src/plugins/validUser/index.tsx b/src/plugins/validUser/index.tsx index a3862d4d..b0c77cb4 100644 --- a/src/plugins/validUser/index.tsx +++ b/src/plugins/validUser/index.tsx @@ -21,14 +21,11 @@ import { Devs } from "@utils/constants"; import { sleep } from "@utils/misc"; import { Queue } from "@utils/Queue"; import definePlugin from "@utils/types"; -import { findByCodeLazy } from "@webpack"; -import { UserStore, useState } from "@webpack/common"; -import type { User } from "discord-types/general"; +import { UserStore, UserUtils, useState } from "@webpack/common"; import type { ComponentType, ReactNode } from "react"; const fetching = new Set(); const queue = new Queue(5); -const fetchUser = findByCodeLazy("USER(") as (id: string) => Promise; interface MentionProps { data: { @@ -88,7 +85,7 @@ function MentionWrapper({ data, UserMention, RoleMention, parse, props }: Mentio fetching.add(id); queue.unshift(() => - fetchUser(id) + UserUtils.getUser(id) .then(() => { setUserId(id); fetching.delete(id); @@ -122,9 +119,9 @@ export default definePlugin({ find: 'className:"mention"', replacement: { // mention = { react: function (data, parse, props) { if (data.userId == null) return RoleMention() else return UserMention() - match: /react:(?=function\(\i,\i,\i\).{0,50}return null==\i\?\(0,\i\.jsx\)\((\i),.+?jsx\)\((\i),\{className:"mention")/, + match: /react(?=\(\i,\i,\i\).{0,50}return null==\i\?\(0,\i\.jsx\)\((\i\.\i),.+?jsx\)\((\i\.\i),\{className:"mention")/, // react: (...args) => OurWrapper(RoleMention, UserMention, ...args), originalReact: theirFunc - replace: "react:(...args)=>$self.renderMention($1,$2,...args),originalReact:" + replace: "react:(...args)=>$self.renderMention($1,$2,...args),originalReact" } }],