Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Vendicated/Vencord
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 23, 2025
2 parents d6ca214 + ea0182a commit 24a88f8
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.10.9",
"version": "1.11.0",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/_api/badges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default definePlugin({
replace: "...$1.props,$& $1.image??"
},
{
match: /(?<=text:(\i)\.description,.{0,200})children:/,
match: /(?<="aria-label":(\i)\.description,.{0,200})children:/,
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
},
// conditionally override their onClick with badge.onClick if it exists
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/_api/messageEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ export default definePlugin({
replace: (match, args) => "" +
`async ${match}` +
`if(await Vencord.Api.MessageEvents._handlePreEdit(${args}))` +
"return Promise.resolve({shoudClear:true,shouldRefocus:true});"
"return Promise.resolve({shouldClear:false,shouldRefocus:true});"
}
},
{
find: ".handleSendMessage,onResize",
replacement: {
// props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply);
// Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid)
match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/,
match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/,
// props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true };
replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" +
`${rest1}async ${rest2}` +
`if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` +
"return{shoudClear:true,shouldRefocus:true};"
"return{shouldClear:false,shouldRefocus:true};"
}
},
{
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/accountPanelServerProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { User } from "discord-types/general";
interface UserProfileProps {
popoutProps: Record<string, any>;
currentUser: User;
originalPopout: () => React.ReactNode;
originalRenderPopout: () => React.ReactNode;
}

const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined");
Expand Down Expand Up @@ -73,12 +73,12 @@ export default definePlugin({
group: true,
replacement: [
{
match: /(?<=\.SIZE_32\)}\);)/,
match: /(?<=\.AVATAR_SIZE\);)/,
replace: "$self.useAccountPanelRef();"
},
{
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:)/,
Expand Down Expand Up @@ -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 originalPopout();
return originalRenderPopout();
}

const currentChannel = getCurrentChannel();
if (currentChannel?.getGuildId() == null) {
return originalPopout();
return originalRenderPopout();
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/betterUploadButton/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,",
},
},
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/consoleShortcuts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ export default definePlugin({
description: "Adds shorter Aliases for many things on the window. Run `shortcutList` for a list.",
authors: [Devs.Ven],

patches: [
{
find: 'this,"_changeCallbacks",',
replacement: {
match: /\i\(this,"_changeCallbacks",/,
replace: "Reflect.defineProperty(this,Symbol.toStringTag,{value:this.getName(),configurable:!0,writable:!0,enumerable:!1}),$&"
}
}
],

startAt: StartAt.Init,
start() {
const shortcuts = makeShortcuts();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/fixImagesQuality/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/fullUserInChatbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface UserMentionComponentProps {
id: string;
channelId: string;
guildId: string;
OriginalComponent: ReactNode;
originalComponent: () => ReactNode;
}

export default definePlugin({
Expand All @@ -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}});"
}
}
],
Expand All @@ -42,6 +42,6 @@ export default definePlugin({
channelId={props.channelId}
/>
), {
fallback: ({ wrappedProps }) => wrappedProps.OriginalComponent
fallback: ({ wrappedProps: { originalComponent } }) => originalComponent()
})
});
17 changes: 6 additions & 11 deletions src/plugins/replyTimestamp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ import "./style.css";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
import { Timestamp } from "@webpack/common";
import { findByPropsLazy } from "@webpack";
import { DateUtils, Timestamp } from "@webpack/common";
import type { Message } from "discord-types/general";
import type { HTMLAttributes } from "react";

const { calendarFormat, dateFormat, isSameDay } = mapMangledModuleLazy("millisecondsInUnit:", {
calendarFormat: filters.byCode("sameElse"),
dateFormat: filters.byCode('":'),
isSameDay: filters.byCode("Math.abs(+"),
});
const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp");

function Sep(props: HTMLAttributes<HTMLElement>) {
Expand Down Expand Up @@ -46,14 +41,14 @@ function ReplyTimestamp({
return (
<Timestamp
className="vc-reply-timestamp"
compact={isSameDay(refTimestamp, baseTimestamp)}
compact={DateUtils.isSameDay(refTimestamp, baseTimestamp)}
timestamp={refTimestamp}
isInline={false}
>
<Sep>[</Sep>
{isSameDay(refTimestamp, baseTimestamp)
? dateFormat(refTimestamp, "LT")
: calendarFormat(refTimestamp)
{DateUtils.isSameDay(refTimestamp, baseTimestamp)
? DateUtils.dateFormat(refTimestamp, "LT")
: DateUtils.calendarFormat(refTimestamp)
}
<Sep>]</Sep>
</Timestamp>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/revealAllSpoilers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";

const SpoilerClasses = findByPropsLazy("spoilerContent");
const MessagesClasses = findByPropsLazy("messagesWrapper");
const MessagesClasses = findByPropsLazy("messagesWrapper", "navigationDescription");

export default definePlugin({
name: "RevealAllSpoilers",
Expand Down
49 changes: 32 additions & 17 deletions src/plugins/sortFriendRequests/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import "./styles.css";

import { definePluginSettings } from "@api/Settings";
import { Flex } from "@components/Flex";
import { classNameFactory } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { RelationshipStore } from "@webpack/common";
import { DateUtils, RelationshipStore, Text, TooltipContainer } from "@webpack/common";
import { User } from "discord-types/general";
import { PropsWithChildren } from "react";

const formatter = new Intl.DateTimeFormat(undefined, {
month: "numeric",
day: "numeric",
year: "numeric",
});

const cl = classNameFactory("vc-sortFriendRequests-");

function getSince(user: User) {
return new Date(RelationshipStore.getSince(user.id));
}

const settings = definePluginSettings({
showDates: {
Expand All @@ -48,28 +64,27 @@ export default definePlugin({
find: "#{intl::FRIEND_REQUEST_CANCEL}",
replacement: {
predicate: () => settings.store.showDates,
match: /subText:(\i)(?<=user:(\i).+?)/,
replace: (_, subtext, user) => `subText:$self.makeSubtext(${subtext},${user})`
match: /(?<=\.listItemContents,children:\[)\(0,.+?(?=,\(0)(?<=user:(\i).+?)/,
replace: (children, user) => `$self.WrapperDateComponent({user:${user},children:${children}})`
}
}],

wrapSort(comparator: Function, row: any) {
return row.type === 3 || row.type === 4
? -this.getSince(row.user)
? -getSince(row.user)
: comparator(row);
},

getSince(user: User) {
return new Date(RelationshipStore.getSince(user.id));
},
WrapperDateComponent: ErrorBoundary.wrap(({ user, children }: PropsWithChildren<{ user: User; }>) => {
const since = getSince(user);

makeSubtext(text: string, user: User) {
const since = this.getSince(user);
return (
<Flex flexDirection="column" style={{ gap: 0, flexWrap: "wrap", lineHeight: "0.9rem" }}>
<span>{text}</span>
{!isNaN(since.getTime()) && <span>Received &mdash; {since.toDateString()}</span>}
</Flex>
);
}
return <div className={cl("wrapper")}>
{children}
{!isNaN(since.getTime()) && (
<TooltipContainer text={DateUtils.dateFormat(since, "LLLL")} tooltipClassName={cl("tooltip")}>
<Text variant="text-xs/normal" className={cl("date")}>{formatter.format(since)}</Text>
</TooltipContainer>
)}
</div>;
})
});
18 changes: 18 additions & 0 deletions src/plugins/sortFriendRequests/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.vc-sortFriendRequests-wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: 100%;
margin-right: 0.5em;
}

.vc-sortFriendRequests-tooltip {
max-width: none;
white-space: nowrap;
}

.vc-sortFriendRequests-date {
color: var(--text-muted);
font-family: var(--font-code);
}
7 changes: 7 additions & 0 deletions src/webpack/common/types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,10 @@ export interface DisplayProfileUtils {
getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
}

export interface DateUtils {
isSameDay(date1: Date, date2: Date): boolean;
calendarFormat(date: Date): string;
dateFormat(date: Date, format: string): string;
diffAsUnits(start: Date, end: Date, stopAtOneSecond?: boolean): Record<"days" | "hours" | "minutes" | "seconds", number>;
}
7 changes: 7 additions & 0 deletions src/webpack/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,10 @@ export const DisplayProfileUtils: t.DisplayProfileUtils = mapMangledModuleLazy(/
getDisplayProfile: filters.byCode(".getGuildMemberProfile("),
useDisplayProfile: filters.byCode(/\[\i\.\i,\i\.\i],\(\)=>/)
});

export const DateUtils: t.DateUtils = mapMangledModuleLazy("millisecondsInUnit:", {
calendarFormat: filters.byCode("sameElse"),
dateFormat: filters.byCode('":'),
isSameDay: filters.byCode("Math.abs(+"),
diffAsUnits: filters.byCode("days:0", "millisecondsInUnit")
});

0 comments on commit 24a88f8

Please sign in to comment.