From e5a4db646061de526f91c1849809bae28597c0b5 Mon Sep 17 00:00:00 2001 From: niko <57009359+hauntii@users.noreply.github.com> Date: Fri, 6 Sep 2024 07:40:29 -0400 Subject: [PATCH 1/6] TimeBarAllActivities: Fix not working (#2847) --- src/plugins/timeBarAllActivities/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/timeBarAllActivities/index.tsx b/src/plugins/timeBarAllActivities/index.tsx index 04f7ff9e7..91b1bc2f1 100644 --- a/src/plugins/timeBarAllActivities/index.tsx +++ b/src/plugins/timeBarAllActivities/index.tsx @@ -40,7 +40,7 @@ export default definePlugin({ settings, patches: [ { - find: ".Messages.USER_ACTIVITY_PLAYING", + find: ".gameState,children:", replacement: [ // Insert Spotify time bar component { From 9e7f8829f24f447c726dbf6002d16324df0e944d Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:20:15 -0300 Subject: [PATCH 2/6] CustomRPC: Fix activity preview styling --- src/plugins/customRPC/index.tsx | 7 +++---- src/utils/constants.ts | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index eebcd4ddb..f4b9ab060 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -26,12 +26,11 @@ import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { useAwaiter } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common"; const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color"); const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile"); -const ActivityClassName = findByPropsLazy("activity", "buttonColor"); const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; @@ -436,8 +435,8 @@ export default definePlugin({ -
- {activity[0] && + {activity[0] && } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index b0ad77fb1..6f98db607 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -39,7 +39,8 @@ export const Devs = /* #__PURE__*/ Object.freeze({ }, Arjix: { name: "ArjixWasTaken", - id: 674710789138939916n + id: 674710789138939916n, + badge: false }, Cyn: { name: "Cynosphere", From 868b2ea9f0134200d469bb7e8d037d709d9581a8 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:40:10 -0300 Subject: [PATCH 3/6] Fix SortFriendRequests received date --- src/plugins/index.ts | 4 ++-- src/plugins/sortFriendRequests/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/index.ts b/src/plugins/index.ts index e6caf7340..ac6821a63 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -66,14 +66,14 @@ export function addPatch(newPatch: Omit, pluginName: string) { patch.replacement = [patch.replacement]; } - patch.replacement = patch.replacement.filter(({ predicate }) => !predicate || predicate()); - if (IS_REPORTER) { patch.replacement.forEach(r => { delete r.predicate; }); } + patch.replacement = patch.replacement.filter(({ predicate }) => !predicate || predicate()); + patches.push(patch); } diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index 7033591bd..64eb13fe5 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -48,7 +48,7 @@ export default definePlugin({ find: ".Messages.FRIEND_REQUEST_CANCEL", replacement: { predicate: () => settings.store.showDates, - match: /subText:(\i)(?=,className:\i\.userInfo}\))(?<=user:(\i).+?)/, + match: /subText:(\i)(?<=user:(\i).+?)/, replace: (_, subtext, user) => `subText:$self.makeSubtext(${subtext},${user})` } }], @@ -66,7 +66,7 @@ export default definePlugin({ makeSubtext(text: string, user: User) { const since = this.getSince(user); return ( - + {text} {!isNaN(since.getTime()) && Received — {since.toDateString()}} From 56459bdcad39b8accacd05f715fab8a544555a6e Mon Sep 17 00:00:00 2001 From: Relitrix <46451374+relitrix@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:33:23 +0300 Subject: [PATCH 4/6] new plugin AccountPanelServerProfile (#2836) --- .../accountPanelServerProfile/README.md | 7 + .../accountPanelServerProfile/index.tsx | 134 ++++++++++++++++++ src/utils/constants.ts | 4 + 3 files changed, 145 insertions(+) create mode 100644 src/plugins/accountPanelServerProfile/README.md create mode 100644 src/plugins/accountPanelServerProfile/index.tsx diff --git a/src/plugins/accountPanelServerProfile/README.md b/src/plugins/accountPanelServerProfile/README.md new file mode 100644 index 000000000..f837864b7 --- /dev/null +++ b/src/plugins/accountPanelServerProfile/README.md @@ -0,0 +1,7 @@ +# AccountPanelServerProfile + +Right click your account panel in the bottom left to view your profile in the current server + +![](https://github.com/user-attachments/assets/3228497d-488f-479c-93d2-a32ccdb08f0f) + +![](https://github.com/user-attachments/assets/6fc45363-d95f-4810-812f-2f9fb28b41b5) diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx new file mode 100644 index 000000000..fe5df48ad --- /dev/null +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -0,0 +1,134 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import { getCurrentChannel } from "@utils/discord"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common"; +import { User } from "discord-types/general"; + +interface UserProfileProps { + popoutProps: Record; + currentUser: User; + originalPopout: () => React.ReactNode; +} + +const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined"); +const styles = findByPropsLazy("accountProfilePopoutWrapper"); + +let openAlternatePopout = false; +let accountPanelRef: React.MutableRefObject | null> = { current: null }; + +const AccountPanelContextMenu = ErrorBoundary.wrap(() => { + const { prioritizeServerProfile } = settings.use(["prioritizeServerProfile"]); + + return ( + + { + openAlternatePopout = true; + accountPanelRef.current?.props.onMouseDown(); + accountPanelRef.current?.props.onClick(e); + }} + /> + settings.store.prioritizeServerProfile = !prioritizeServerProfile} + /> + + ); +}, { noop: true }); + +const settings = definePluginSettings({ + prioritizeServerProfile: { + type: OptionType.BOOLEAN, + description: "Prioritize Server Profile when left clicking your account panel", + default: false + } +}); + +export default definePlugin({ + name: "AccountPanelServerProfile", + description: "Right click your account panel in the bottom left to view your profile in the current server", + authors: [Devs.Nuckyz, Devs.relitrix], + settings, + + patches: [ + { + find: ".Messages.ACCOUNT_SPEAKING_WHILE_MUTED", + group: true, + replacement: [ + { + match: /(?<=\.SIZE_32\)}\);)/, + 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}}})` + }, + { + match: /\.AVATAR,children:.+?(?=renderPopout:)/, + replace: "$&onRequestClose:$self.onPopoutClose," + }, + { + match: /(?<=.avatarWrapper,)/, + replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu," + } + ] + } + ], + + get accountPanelRef() { + return accountPanelRef; + }, + + useAccountPanelRef() { + useEffect(() => () => { + accountPanelRef.current = null; + }, []); + + return (accountPanelRef = useRef(null)); + }, + + openAccountPanelContextMenu(event: React.UIEvent) { + ContextMenuApi.openContextMenu(event, AccountPanelContextMenu); + }, + + onPopoutClose() { + openAlternatePopout = false; + }, + + UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalPopout }: UserProfileProps) => { + if ( + (settings.store.prioritizeServerProfile && openAlternatePopout) || + (!settings.store.prioritizeServerProfile && !openAlternatePopout) + ) { + return originalPopout(); + } + + const currentChannel = getCurrentChannel(); + if (currentChannel?.getGuildId() == null) { + return originalPopout(); + } + + return ( +
+ +
+ ); + }, { noop: true }) +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 6f98db607..0572fa102 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -567,6 +567,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "niko", id: 341377368075796483n, }, + relitrix: { + name: "Relitrix", + id: 423165393901715456n, + }, RamziAH: { name: "RamziAH", id: 1279957227612147747n, From a765212cfea712f67dd82d025f8f9a56558cdbbe Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:50:55 -0400 Subject: [PATCH 5/6] NoTrack: Fix blocking analytics (#2857) --- src/plugins/_core/noTrack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index de1c20562..8d6a1e76d 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -48,7 +48,7 @@ export default definePlugin({ }, }, { - find: ".METRICS,", + find: ".METRICS", replacement: [ { match: /this\._intervalId=/, From f27361f017330e8957b12b6eabcf4930ffcf7eb4 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 11 Sep 2024 08:13:23 -0300 Subject: [PATCH 6/6] TimeBarAllActivities: Fix timestamp component --- src/plugins/ignoreActivities/index.tsx | 9 +------ src/plugins/noPendingCount/index.ts | 11 +-------- src/plugins/timeBarAllActivities/index.tsx | 28 ++++++++++++++-------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 02261b5ba..8c36e1d75 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -266,7 +266,7 @@ export default definePlugin({ replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),` } }, - // Discord has 3 different components for activities. Currently, the last is the one being used + // Discord has 2 different components for activities. Currently, the last is the one being used { find: ".activityTitleText,variant", replacement: { @@ -274,13 +274,6 @@ export default definePlugin({ replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` }, }, - { - find: ".activityCardDetails,children", - replacement: { - match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/, - replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` - } - }, { find: ".promotedLabelWrapperNonBanner,children", replacement: { diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 0995621fa..d3e27563b 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -62,16 +62,7 @@ export default definePlugin({ replace: "return 0;" } }, - // New message requests hook - { - find: 'location:"use-message-requests-count"', - predicate: () => settings.store.hideMessageRequestsCount, - replacement: { - match: /getNonChannelAckId\(\i\.\i\.MESSAGE_REQUESTS\).+?return /, - replace: "$&0;" - } - }, - // Old message requests hook + // Message requests hook { find: "getMessageRequestsCount(){", predicate: () => settings.store.hideMessageRequestsCount, diff --git a/src/plugins/timeBarAllActivities/index.tsx b/src/plugins/timeBarAllActivities/index.tsx index 91b1bc2f1..660d20bbf 100644 --- a/src/plugins/timeBarAllActivities/index.tsx +++ b/src/plugins/timeBarAllActivities/index.tsx @@ -5,9 +5,11 @@ */ import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; +import { RequiredDeep } from "type-fest"; interface Activity { timestamps?: ActivityTimestamps; @@ -18,7 +20,15 @@ interface ActivityTimestamps { end?: string; } -const ActivityTimeBar = findComponentByCodeLazy(".Millis.HALF_SECOND", ".bar", ".progress"); +interface TimebarComponentProps { + activity: Activity; +} + +const ActivityTimeBar = findComponentByCodeLazy(".bar", ".progress", "(100*"); + +function isActivityTimestamped(activity: Activity): activity is RequiredDeep { + return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; +} export const settings = definePluginSettings({ hideActivityDetailText: { @@ -45,7 +55,7 @@ export default definePlugin({ // Insert Spotify time bar component { match: /\(0,.{0,30}activity:(\i),className:\i\.badges\}\)/g, - replace: "$&,$self.getTimeBar($1)" + replace: "$&,$self.TimebarComponent({activity:$1})" }, // Hide the large title on listening activities, to make them look more like Spotify (also visible from hovering over the large icon) { @@ -64,13 +74,11 @@ export default definePlugin({ } ], - isActivityTimestamped(activity: Activity) { - return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; - }, + isActivityTimestamped, - getTimeBar(activity: Activity) { - if (this.isActivityTimestamped(activity)) { - return ; - } - } + TimebarComponent: ErrorBoundary.wrap(({ activity }: TimebarComponentProps) => { + if (!isActivityTimestamped(activity)) return null; + + return ; + }, { noop: true }) });