From e6994e1946ea2b34c0b6b842d3a323beb9cfa3ef Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 5 Sep 2024 02:24:10 +0200 Subject: [PATCH 01/13] MentionAvatars: Fix compatibility with ServerInfo plugin --- src/plugins/mentionAvatars/styles.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/mentionAvatars/styles.css b/src/plugins/mentionAvatars/styles.css index 64eb41416..cf6e2c14c 100644 --- a/src/plugins/mentionAvatars/styles.css +++ b/src/plugins/mentionAvatars/styles.css @@ -9,3 +9,8 @@ .vc-mentionAvatars-role-icon { margin: 0 2px 0.2rem 4px; } + +/** don't display inside the ServerInfo modal owner mention */ +.vc-gp-owner .vc-mentionAvatars-icon { + display: none; +} From 61d3c08f1f6b9c44bd193aab4f8568734ba60ad8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 5 Sep 2024 02:25:27 +0200 Subject: [PATCH 02/13] bump to v1.10.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65a2f4512..e65e1b0a7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.9", + "version": "1.10.1", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 8890c8c6b4201121c559e671e0110b45937467c2 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 5 Sep 2024 02:33:07 +0200 Subject: [PATCH 03/13] fix Commands, Badges, RoleColorEverywhere --- src/api/Commands/index.ts | 7 ++++--- src/plugins/_api/badges/fixBadgeOverflow.css | 3 --- src/plugins/_api/badges/index.tsx | 4 +--- src/plugins/roleColorEverywhere/index.tsx | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 src/plugins/_api/badges/fixBadgeOverflow.css diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index 5e3fc8f4d..e5803ba02 100644 --- a/src/api/Commands/index.ts +++ b/src/api/Commands/index.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { Logger } from "@utils/Logger"; import { makeCodeblock } from "@utils/text"; import { sendBotMessage } from "./commandHelpers"; @@ -46,10 +47,10 @@ export let RequiredMessageOption: Option = ReqPlaceholder; export const _init = function (cmds: Command[]) { try { BUILT_IN = cmds; - OptionalMessageOption = cmds.find(c => c.name === "shrug")!.options![0]; - RequiredMessageOption = cmds.find(c => c.name === "me")!.options![0]; + OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0]; + RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0]; } catch (e) { - console.error("Failed to load CommandsApi"); + new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds); } return cmds; } as never; diff --git a/src/plugins/_api/badges/fixBadgeOverflow.css b/src/plugins/_api/badges/fixBadgeOverflow.css deleted file mode 100644 index 348d0ff38..000000000 --- a/src/plugins/_api/badges/fixBadgeOverflow.css +++ /dev/null @@ -1,3 +0,0 @@ -[class*="profileBadges"] { - flex: none; -} diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index cf00a0e29..c44d98b90 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -import "./fixBadgeOverflow.css"; - import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; import DonateButton from "@components/DonateButton"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -79,7 +77,7 @@ export default definePlugin({ replace: "...$1.props,$& $1.image??" }, { - match: /(?<=text:(\i)\.description,.{0,50})children:/, + match: /(?<=text:(\i)\.description,.{0,200})children:/, replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :" }, // conditionally override their onClick with badge.onClick if it exists diff --git a/src/plugins/roleColorEverywhere/index.tsx b/src/plugins/roleColorEverywhere/index.tsx index 3e7d216b7..b5f66c098 100644 --- a/src/plugins/roleColorEverywhere/index.tsx +++ b/src/plugins/roleColorEverywhere/index.tsx @@ -57,7 +57,7 @@ export default definePlugin({ patches: [ // Chat Mentions { - find: 'location:"UserMention', + find: ".USER_MENTION)", replacement: [ { match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/, 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 04/13] 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 05/13] 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 06/13] 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 07/13] 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 08/13] 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 09/13] 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 }) }); From b82254235204a3f0e784c623d499b2e3274a83d5 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Thu, 12 Sep 2024 01:23:43 -0400 Subject: [PATCH 10/13] BetterFolders: Fix pending clan applications (#2867) --- src/plugins/betterFolders/README.md | 11 ++++++++ src/plugins/betterFolders/index.tsx | 39 +++++++++++++++++++---------- 2 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 src/plugins/betterFolders/README.md diff --git a/src/plugins/betterFolders/README.md b/src/plugins/betterFolders/README.md new file mode 100644 index 000000000..658c6f1db --- /dev/null +++ b/src/plugins/betterFolders/README.md @@ -0,0 +1,11 @@ +# Better Folders + +Better Folders offers a variety of options to improve your folder experience + +Always show the folder icon, regardless of if the folder is open or not + +Only have one folder open at a time + +Open folders in a sidebar: + +![A folder open in a separate sidebar](https://github.com/user-attachments/assets/432d3146-8091-4bae-9c1e-c19046c72947) diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 0bef0933d..c2969988b 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -30,9 +30,9 @@ enum FolderIconDisplay { MoreThanOneFolderExpanded } -const GuildsTree = findLazy(m => m.prototype?.moveNextTo); -const SortedGuildStore = findStoreLazy("SortedGuildStore"); export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); +const SortedGuildStore = findStoreLazy("SortedGuildStore"); +const GuildsTree = findLazy(m => m.prototype?.moveNextTo); const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand"); let lastGuildId = null as string | null; @@ -118,17 +118,17 @@ export default definePlugin({ // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/, - replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)` + replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0]?.isBetterFolders,betterFoldersOriginalTree,arguments[0]?.betterFoldersExpandedIds)` }, // If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children { match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/, - replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0].isBetterFolders))" + replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))" }, // If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children { match: /unreadMentionsIndicatorBottom,.+?}\)\]/, - replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0].isBetterFolders))" + replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))" }, // Export the isBetterFolders variable to the folders component { @@ -167,31 +167,31 @@ export default definePlugin({ { predicate: () => settings.store.keepIcons, match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/, - replace: (_, isExpanded) => `${isExpanded}=!!arguments[0].isBetterFolders&&${isExpanded};` + replace: (_, isExpanded) => `${isExpanded}=!!arguments[0]?.isBetterFolders&&${isExpanded};` }, // Disable expanding and collapsing folders transition in the normal GuildsBar sidebar { predicate: () => !settings.store.keepIcons, match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/, - replace: "!!arguments[0].isBetterFolders&&" + replace: "$self.shouldShowTransition(arguments[0])&&" }, // If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded { predicate: () => !settings.store.keepIcons, match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/, - replace: (m, isExpanded) => `${m}!arguments[0].isBetterFolders&&${isExpanded}?null:` + replace: (m, isExpanded) => `${m}$self.shouldRenderContents(arguments[0],${isExpanded})?null:` }, { // Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always, match: /(?<=\.wrapper,children:\[)/, - replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)&&" + replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&" }, { // Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always, match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/, - replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)?null:" + replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)?null:" } ] }, @@ -201,7 +201,7 @@ export default definePlugin({ replacement: { // Render the Better Folders sidebar match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/, - replace: ",$self.FolderSideBar($1)" + replace: ",$self.FolderSideBar({...$1})" } }, { @@ -306,7 +306,20 @@ export default definePlugin({ } }, - FolderSideBar: guildsBarProps => , + shouldShowTransition(props: any) { + // Pending guilds + if (props?.folderNode?.id === 1) return true; - closeFolders + return !!props?.isBetterFolders; + }, + + shouldRenderContents(props: any, isExpanded: boolean) { + // Pending guilds + if (props?.folderNode?.id === 1) return false; + + return !props?.isBetterFolders && isExpanded; + }, + + FolderSideBar, + closeFolders, }); From 292f7d71d3bf1ce8115bd6b7b73597ade12d0645 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:59:05 +0800 Subject: [PATCH 11/13] AppleMusicRichPresence: fix metadata fetching (#2864) --- src/plugins/appleMusic.desktop/index.tsx | 2 +- src/plugins/appleMusic.desktop/native.ts | 80 +++++++++++++----------- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index 6fa989cdd..327fafc30 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -120,7 +120,7 @@ const settings = definePluginSettings({ stateString: { type: OptionType.STRING, description: "Activity state format string", - default: "{artist}" + default: "{artist} ยท {album}" }, largeImageType: { type: OptionType.SELECT, diff --git a/src/plugins/appleMusic.desktop/native.ts b/src/plugins/appleMusic.desktop/native.ts index 2eb2a0757..7d69a85ae 100644 --- a/src/plugins/appleMusic.desktop/native.ts +++ b/src/plugins/appleMusic.desktop/native.ts @@ -11,37 +11,11 @@ import type { TrackData } from "."; const exec = promisify(execFile); -// function exec(file: string, args: string[] = []) { -// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => { -// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] }); - -// let stdout: string | null = null; -// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; }); -// let stderr: string | null = null; -// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; }); - -// process.on("exit", code => { resolve({ code, stdout, stderr }); }); -// process.on("error", err => reject(err)); -// }); -// } - async function applescript(cmds: string[]) { const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat()); return stdout; } -function makeSearchUrl(type: string, query: string) { - const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json"); - url.searchParams.set("types", type); - url.searchParams.set("limit", "1"); - url.searchParams.set("term", query); - return url; -} - -const requestOptions: RequestInit = { - headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" }, -}; - interface RemoteData { appleMusicLink?: string, songLink?: string, @@ -51,6 +25,24 @@ interface RemoteData { let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null; +const APPLE_MUSIC_BUNDLE_REGEX = /