From 43b6933fe69fbf30f542c7da41d0e812150f8447 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:47:57 -0300 Subject: [PATCH 01/12] Reporter: Include page errors; load wasm chunks --- scripts/generateReport.ts | 9 ++++++++- src/debug/loadLazyChunks.ts | 14 ++++++++------ src/plugins/appleMusic.desktop/index.tsx | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index cf4210779..2a802da8c 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -286,7 +286,14 @@ page.on("console", async e => { }); page.on("error", e => console.error("[Error]", e.message)); -page.on("pageerror", e => console.error("[Page Error]", e.message)); +page.on("pageerror", e => { + if (!e.message.startsWith("Object") && !e.message.includes("Cannot find module")) { + console.error("[Page Error]", e.message); + report.otherErrors.push(e.message); + } else { + report.ignoredErrors.push(e.message); + } +}); async function reporterRuntime(token: string) { Vencord.Webpack.waitFor( diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index d8f84335c..0aeae732b 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -47,11 +47,11 @@ export async function loadLazyChunks() { for (const id of chunkIds) { if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; - const isWasm = await fetch(wreq.p + wreq.u(id)) + const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); + .then(t => t.includes("importScripts(")); - if (isWasm && IS_WEB) { + if (isWorkerAsset) { invalidChunks.add(id); invalidChunkGroup = true; continue; @@ -149,13 +149,15 @@ export async function loadLazyChunks() { }); await Promise.all(chunksLeft.map(async id => { - const isWasm = await fetch(wreq.p + wreq.u(id)) + const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); + .then(t => t.includes("importScripts(")); // Loads and requires a chunk - if (!isWasm) { + if (!isWorkerAsset) { await wreq.e(id as any); + // Technically, the id of the chunk does not match the entry point + // But, still try it because we have no way to get the actual entry point if (wreq.m[id]) wreq(id as any); } })); diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index 16591028d..ef3ee3efc 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -6,7 +6,7 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType, PluginNative } from "@utils/types"; +import definePlugin, { OptionType, PluginNative, ReporterTestable } from "@utils/types"; import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common"; const Native = VencordNative.pluginHelpers.AppleMusic as PluginNative; @@ -171,6 +171,7 @@ export default definePlugin({ description: "Discord rich presence for your Apple Music!", authors: [Devs.RyanCaoDev], hidden: !navigator.platform.startsWith("Mac"), + reporterTestable: ReporterTestable.None, settingsAboutComponent() { return <> From c54650b29a4af243aa7f79d01340235bedc3172b Mon Sep 17 00:00:00 2001 From: NuclideK <88620225+NuclideK@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:24:49 +0300 Subject: [PATCH 02/12] customRPC: fix typos in settings descriptions (#2559) --- src/plugins/customRPC/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/customRPC/index.tsx b/src/plugins/customRPC/index.tsx index f1b2fbf53..ed354cba4 100644 --- a/src/plugins/customRPC/index.tsx +++ b/src/plugins/customRPC/index.tsx @@ -178,7 +178,7 @@ const settings = definePluginSettings({ }, startTime: { type: OptionType.NUMBER, - description: "Start timestamp in milisecond (only for custom timestamp mode)", + description: "Start timestamp in milliseconds (only for custom timestamp mode)", onChange: onChange, disabled: isTimestampDisabled, isValid: (value: number) => { @@ -188,7 +188,7 @@ const settings = definePluginSettings({ }, endTime: { type: OptionType.NUMBER, - description: "End timestamp in milisecond (only for custom timestamp mode)", + description: "End timestamp in milliseconds (only for custom timestamp mode)", onChange: onChange, disabled: isTimestampDisabled, isValid: (value: number) => { From 40db2f507808d200c8a4037d047ffc4db942a11c Mon Sep 17 00:00:00 2001 From: Lumap Date: Fri, 7 Jun 2024 23:04:40 +0200 Subject: [PATCH 03/12] AppleMusicRichPresence: add option to disable large/small image (#2562) --- src/plugins/appleMusic.desktop/index.tsx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index ef3ee3efc..0d81204e9 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -68,6 +68,7 @@ export interface TrackData { const enum AssetImageType { Album = "Album", Artist = "Artist", + Disabled = "Disabled" } const applicationId = "1239490006054207550"; @@ -126,7 +127,8 @@ const settings = definePluginSettings({ description: "Activity assets large image type", options: [ { label: "Album artwork", value: AssetImageType.Album, default: true }, - { label: "Artist artwork", value: AssetImageType.Artist } + { label: "Artist artwork", value: AssetImageType.Artist }, + { label: "Disabled", value: AssetImageType.Disabled } ], }, largeTextString: { @@ -139,7 +141,8 @@ const settings = definePluginSettings({ description: "Activity assets small image type", options: [ { label: "Album artwork", value: AssetImageType.Album }, - { label: "Artist artwork", value: AssetImageType.Artist, default: true } + { label: "Artist artwork", value: AssetImageType.Artist, default: true }, + { label: "Disabled", value: AssetImageType.Disabled } ], }, smallTextString: { @@ -207,12 +210,17 @@ export default definePlugin({ getImageAsset(settings.store.smallImageType, trackData) ]); - const assets: ActivityAssets = { - large_image: largeImageAsset, - large_text: customFormat(settings.store.largeTextString, trackData), - small_image: smallImageAsset, - small_text: customFormat(settings.store.smallTextString, trackData), - }; + const assets: ActivityAssets = {}; + + if (settings.store.largeImageType !== AssetImageType.Disabled) { + assets.large_image = largeImageAsset; + assets.large_text = customFormat(settings.store.largeTextString, trackData); + } + + if (settings.store.smallImageType !== AssetImageType.Disabled) { + assets.small_image = smallImageAsset; + assets.small_text = customFormat(settings.store.smallTextString, trackData); + } const buttons: ActivityButton[] = []; From 1bc9a800a66e3cef6ef8d8cd54c4db6db7a73007 Mon Sep 17 00:00:00 2001 From: Elvyra <88881326+EdVraz@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:05:14 +0200 Subject: [PATCH 04/12] fix moreUserTags (#2563) --- src/plugins/moreUserTags/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index 9c848df6d..9d2790d0e 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -200,7 +200,7 @@ export default definePlugin({ } }, { - find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP,", + find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP_OFFICIAL,", replacement: [ // make the tag show the right text { From 29c65948b43df64c9d8f527bb0967ad05685221c Mon Sep 17 00:00:00 2001 From: Nickyux <30734036+nmsturcke@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:28:17 +0200 Subject: [PATCH 05/12] MessageLogger: add context menu option to clear channel history (#2008) Co-authored-by: vee --- src/api/MessageUpdater.ts | 2 +- src/plugins/messageLogger/index.tsx | 121 ++++++++++++++++------------ 2 files changed, 70 insertions(+), 53 deletions(-) diff --git a/src/api/MessageUpdater.ts b/src/api/MessageUpdater.ts index 5cac80528..284a20886 100644 --- a/src/api/MessageUpdater.ts +++ b/src/api/MessageUpdater.ts @@ -14,7 +14,7 @@ import { Message } from "discord-types/general"; * @param messageId The message id * @param fields The fields of the message to change. Leave empty if you just want to re-render */ -export function updateMessage(channelId: string, messageId: string, fields?: Partial) { +export function updateMessage(channelId: string, messageId: string, fields?: Partial>) { const channelMessageCache = MessageCache.getOrCreate(channelId); if (!channelMessageCache.has(messageId)) return; diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 892c819b7..daafeb2dc 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -18,7 +18,8 @@ import "./messageLogger.css"; -import { NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { updateMessage } from "@api/MessageUpdater"; import { Settings } from "@api/Settings"; import { disableStyle, enableStyle } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -26,11 +27,17 @@ import { Devs } from "@utils/constants"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, FluxDispatcher, i18n, Menu, Parser, Timestamp, UserStore } from "@webpack/common"; +import { ChannelStore, FluxDispatcher, i18n, Menu, MessageStore, Parser, Timestamp, UserStore, useStateFromStores } from "@webpack/common"; +import { Message } from "discord-types/general"; import overlayStyle from "./deleteStyleOverlay.css?managed"; import textStyle from "./deleteStyleText.css?managed"; +interface MLMessage extends Message { + deleted?: boolean; + editHistory?: { timestamp: Date; content: string; }[]; +} + const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage"); function addDeleteStyle() { @@ -89,35 +96,77 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) = )); }; +const patchChannelContextMenu: NavContextMenuPatchCallback = (children, { channel }) => { + const messages = MessageStore.getMessages(channel?.id) as MLMessage[]; + if (!messages?.some(msg => msg.deleted || msg.editHistory?.length)) return; + + const group = findGroupChildrenByChildId("mark-channel-read", children) ?? children; + group.push( + { + messages.forEach(msg => { + if (msg.deleted) + FluxDispatcher.dispatch({ + type: "MESSAGE_DELETE", + channelId: channel.id, + id: msg.id, + mlDeleted: true + }); + else + updateMessage(channel.id, msg.id, { + editHistory: [] + }); + }); + }} + /> + ); +}; + export default definePlugin({ name: "MessageLogger", description: "Temporarily logs deleted and edited messages.", - authors: [Devs.rushii, Devs.Ven, Devs.AutumnVN], + authors: [Devs.rushii, Devs.Ven, Devs.AutumnVN, Devs.Nickyux], + dependencies: ["MessageUpdaterAPI"], contextMenus: { - "message": patchMessageContextMenu + "message": patchMessageContextMenu, + "channel-context": patchChannelContextMenu, + "user-context": patchChannelContextMenu, + "gdm-context": patchChannelContextMenu }, start() { addDeleteStyle(); }, - renderEdit(edit: { timestamp: any, content: string; }) { - return ( - -
- {Parser.parse(edit.content)} - - {" "}({i18n.Messages.MESSAGE_EDITED}) - -
-
+ renderEdits: ErrorBoundary.wrap(({ message: { id: messageId, channel_id: channelId } }: { message: Message; }) => { + const message = useStateFromStores( + [MessageStore], + () => MessageStore.getMessage(channelId, messageId) as MLMessage, + null, + (oldMsg, newMsg) => oldMsg.editHistory === newMsg.editHistory ); - }, + + return ( + <> + {message.editHistory?.map(edit => ( +
+ {Parser.parse(edit.content)} + + {" "}({i18n.Messages.MESSAGE_EDITED}) + +
+ ))} + + ); + }, { noop: true }), makeEdit(newMessage: any, oldMessage: any): any { return { @@ -222,11 +271,9 @@ export default definePlugin({ (message.channel_id === "1026515880080842772" && message.author?.id === "1017176847865352332"); }, - // Based on canary 63b8f1b4f2025213c5cf62f0966625bee3d53136 patches: [ { // MessageStore - // Module 171447 find: '"MessageStore"', replacement: [ { @@ -271,7 +318,6 @@ export default definePlugin({ { // Message domain model - // Module 451 find: "}addReaction(", replacement: [ { @@ -285,14 +331,8 @@ export default definePlugin({ { // Updated message transformer(?) - // Module 819525 find: "THREAD_STARTER_MESSAGE?null===", replacement: [ - // { - // // DEBUG: Log the params of the target function to the patch below - // match: /function N\(e,t\){/, - // replace: "function L(e,t){console.log('pre-transform', e, t);" - // }, { // Pass through editHistory & deleted & original attachments to the "edited message" transformer match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/, @@ -300,11 +340,6 @@ export default definePlugin({ "Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory, attachments:$1.attachments })" }, - // { - // // DEBUG: Log the params of the target function to the patch below - // match: /function R\(e\){/, - // replace: "function R(e){console.log('after-edit-transform', arguments);" - // }, { // Construct new edited message and add editHistory & deleted (ref above) // Pass in custom data to attachment parser to mark attachments deleted as well @@ -335,7 +370,6 @@ export default definePlugin({ { // Attachment renderer - // Module 96063 find: ".removeMosaicItemHoverButton", group: true, replacement: [ @@ -352,7 +386,6 @@ export default definePlugin({ { // Base message component renderer - // Module 748241 find: "Message must not be a thread starter message", replacement: [ { @@ -365,20 +398,18 @@ export default definePlugin({ { // Message content renderer - // Module 43016 find: "Messages.MESSAGE_EDITED,\")\"", replacement: [ { // Render editHistory in the deepest div for message content match: /(\)\("div",\{id:.+?children:\[)/, - replace: "$1 (arguments[0].message.editHistory?.length > 0 ? arguments[0].message.editHistory.map(edit => $self.renderEdit(edit)) : null), " + replace: "$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0]))," } ] }, { // ReferencedMessageStore - // Module 778667 find: '"ReferencedMessageStore"', replacement: [ { @@ -394,7 +425,6 @@ export default definePlugin({ { // Message context base menu - // Module 600300 find: "useMessageMenu:", replacement: [ { @@ -404,18 +434,5 @@ export default definePlugin({ } ] } - - // { - // // MessageStore caching internals - // // Module 819525 - // find: "e.getOrCreate=function(t)", - // replacement: [ - // // { - // // // DEBUG: log getOrCreate return values from MessageStore caching internals - // // match: /getOrCreate=function(.+?)return/, - // // replace: "getOrCreate=function$1console.log('getOrCreate',n);return" - // // } - // ] - // } ] }); From 5996e67c7d9d6512f734592f1e44e72897d37797 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sat, 8 Jun 2024 04:42:12 +0700 Subject: [PATCH 06/12] fix USRBG & ViewIcons in new profiles (#2557) Co-authored-by: Vendicated --- src/plugins/usrbg/index.tsx | 40 ++++++++++++++++----------------- src/plugins/viewIcons/index.tsx | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index b8e9f14b3..32da95af6 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -61,11 +61,7 @@ export default definePlugin({ replacement: [ { match: /(\i)\.premiumType/, - replace: "$self.premiumHook($1)||$&" - }, - { - match: /(?<=function \i\((\i)\)\{)(?=var.{30,50},bannerSrc:)/, - replace: "$1.bannerSrc=$self.useBannerHook($1);" + replace: "$self.patchPremiumType($1)||$&" }, { match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/, @@ -74,17 +70,19 @@ export default definePlugin({ ] }, { - find: /overrideBannerSrc:\i,overrideBannerWidth:/, - replacement: [ - { - match: /(\i)\.premiumType/, - replace: "$self.premiumHook($1)||$&" - }, - { - match: /function \i\((\i)\)\{/, - replace: "$&$1.overrideBannerSrc=$self.useBannerHook($1);" - } - ] + find: "=!1,canUsePremiumCustomization:", + replacement: { + match: /(\i)\.premiumType/, + replace: "$self.patchPremiumType($1)||$&" + } + }, + { + find: "BannerLoadingStatus:function", + replacement: { + match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/, + replace: "$self.patchBannerUrl(arguments[0])||$&" + + } }, { find: "\"data-selenium-video-tile\":", @@ -92,7 +90,7 @@ export default definePlugin({ replacement: [ { match: /(?<=function\((\i),\i\)\{)(?=let.{20,40},style:)/, - replace: "$1.style=$self.voiceBackgroundHook($1);" + replace: "$1.style=$self.getVoiceBackgroundStyles($1);" } ] } @@ -106,7 +104,7 @@ export default definePlugin({ ); }, - voiceBackgroundHook({ className, participantUserId }: any) { + getVoiceBackgroundStyles({ className, participantUserId }: any) { if (className.includes("tile_")) { if (this.userHasBackground(participantUserId)) { return { @@ -119,12 +117,12 @@ export default definePlugin({ } }, - useBannerHook({ displayProfile, user }: any) { + patchBannerUrl({ displayProfile }: any) { if (displayProfile?.banner && settings.store.nitroFirst) return; - if (this.userHasBackground(user.id)) return this.getImageUrl(user.id); + if (this.userHasBackground(displayProfile?.userId)) return this.getImageUrl(displayProfile?.userId); }, - premiumHook({ userId }: any) { + patchPremiumType({ userId }: any) { if (this.userHasBackground(userId)) return 2; }, diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index a94689689..9d1745116 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -192,7 +192,7 @@ export default definePlugin({ } })), // Banners - ...[".NITRO_BANNER,", /overrideBannerSrc:\i,overrideBannerWidth:/].map(find => ({ + ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ find, replacement: { // style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl, From 239da032ecf3136da5f9eade7ecb8321b971ef93 Mon Sep 17 00:00:00 2001 From: vee Date: Sat, 8 Jun 2024 00:48:17 +0200 Subject: [PATCH 07/12] README: add shiggy background on github --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a43c9f834..e67db93a2 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ The cutest Discord client mod | ![image](https://github.com/Vendicated/Vencord/assets/45497981/706722b1-32de-4d99-bee9-93993b504334) | -|:--:| -| A screenshot of vencord showcasing the [vencord-theme](https://github.com/synqat/vencord-theme) | +| :--------------------------------------------------------------------------------------------------: | +| A screenshot of vencord showcasing the [vencord-theme](https://github.com/synqat/vencord-theme) | ## Features @@ -32,9 +32,9 @@ https://discord.gg/D9uwnFnqmd ## Sponsors -| **Thanks a lot to all Vencord [sponsors](https://github.com/sponsors/Vendicated)!!** | -|:--:| -| [![](https://meow.vendicated.dev/sponsors.png)](https://github.com/sponsors/Vendicated) | +| **Thanks a lot to all Vencord [sponsors](https://github.com/sponsors/Vendicated)!!** | +| :------------------------------------------------------------------------------------------: | +| [![](https://meow.vendicated.dev/sponsors.png)](https://github.com/sponsors/Vendicated) | | *generated using [github-sponsor-graph](https://github.com/Vendicated/github-sponsor-graph)* | @@ -65,3 +65,8 @@ Regardless, if your account is very important to you and it getting disabled wou Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it + +```math +\ce{$\unicode[goombafont; color:red; z-index: -10; position: fixed; top: 0; left: 0; height: 100%; object-fit: cover; width: 100%; opacity: 1; background: url('https://github.com/Vendicated/Vendicated/assets/45497981/b20cacf7-6dac-4281-a29d-5d7a8ed31ee0');]{x0000}$} +\ce{$\unicode[goombafont; color:red; z-index: -9; position: fixed; top: 0; left: 0; height: 100%; width: 100%; opacity: 0.9; background: var(--bgColor-default);]{x0000}$} +``` From 2c5079b49fb3731acaa73ada69ec282a1eeb4428 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 8 Jun 2024 04:15:29 +0200 Subject: [PATCH 08/12] MessageLogger: fix potential error --- src/plugins/messageLogger/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index daafeb2dc..39a059b8c 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -147,7 +147,7 @@ export default definePlugin({ [MessageStore], () => MessageStore.getMessage(channelId, messageId) as MLMessage, null, - (oldMsg, newMsg) => oldMsg.editHistory === newMsg.editHistory + (oldMsg, newMsg) => oldMsg?.editHistory === newMsg?.editHistory ); return ( From 914b211a91f21e827ffe9d333f19c1d8d31cb193 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sat, 8 Jun 2024 09:21:01 +0700 Subject: [PATCH 09/12] betterRoleDot: fix click to copy role color in profile (#2551) Co-authored-by: vee --- src/plugins/betterRoleDot/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/betterRoleDot/index.ts b/src/plugins/betterRoleDot/index.ts index 3886de3f7..a8cadd8b0 100644 --- a/src/plugins/betterRoleDot/index.ts +++ b/src/plugins/betterRoleDot/index.ts @@ -48,6 +48,7 @@ export default definePlugin({ { find: ".ADD_ROLE_A11Y_LABEL", + all: true, predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles, noWarn: true, replacement: { @@ -57,6 +58,7 @@ export default definePlugin({ }, { find: ".roleVerifiedIcon", + all: true, predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles, noWarn: true, replacement: { From 810ff894dc9cb5ec5d62d16851b705cb0e88ef31 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sat, 8 Jun 2024 09:21:27 +0700 Subject: [PATCH 10/12] ui(RestartCard): fix yellow button now being blue (#2550) --- src/components/PluginSettings/index.tsx | 2 +- src/components/PluginSettings/styles.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 9c26a9cf1..978d2e85a 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -69,7 +69,7 @@ function ReloadRequiredCard({ required }: { required: boolean; }) { Restart now to apply new plugins and their settings - diff --git a/src/components/PluginSettings/styles.css b/src/components/PluginSettings/styles.css index 66b2a2158..d3d182e58 100644 --- a/src/components/PluginSettings/styles.css +++ b/src/components/PluginSettings/styles.css @@ -78,6 +78,7 @@ .vc-plugins-restart-card button { margin-top: 0.5em; + background: var(--info-warning-foreground) !important; } .vc-plugins-info-button svg:not(:hover, :focus) { From 65970618d89d4c7383fc88dde8380423e67cd5e5 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 8 Jun 2024 05:26:03 +0200 Subject: [PATCH 11/12] fix badges in new profiles --- src/api/Badges.ts | 5 +- src/plugins/_api/badges/index.tsx | 58 +++++++++++++++++++++--- src/plugins/platformIndicators/index.tsx | 4 +- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/api/Badges.ts b/src/api/Badges.ts index 061bdeb8a..24c68c4ed 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -17,7 +17,6 @@ */ import ErrorBoundary from "@components/ErrorBoundary"; -import { User } from "discord-types/general"; import { ComponentType, HTMLProps } from "react"; import Plugins from "~plugins"; @@ -79,14 +78,14 @@ export function _getBadges(args: BadgeUserArgs) { : badges.push({ ...badge, ...args }); } } - const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.user.id); + const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.userId); if (donorBadges) badges.unshift(...donorBadges); return badges; } export interface BadgeUserArgs { - user: User; + userId: string; guildId: string; } diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index bbccf0a11..b4ee45a1d 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -18,18 +18,20 @@ import "./fixBadgeOverflow.css"; -import { BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; +import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; import DonateButton from "@components/DonateButton"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Heart } from "@components/Heart"; import { openContributorModal } from "@components/PluginSettings/ContributorModal"; import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import { isPluginDev } from "@utils/misc"; import { closeModal, Modals, openModal } from "@utils/modal"; import definePlugin from "@utils/types"; -import { Forms, Toasts } from "@webpack/common"; +import { Forms, Toasts, UserStore } from "@webpack/common"; +import { User } from "discord-types/general"; const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png"; @@ -37,8 +39,8 @@ const ContributorBadge: ProfileBadge = { description: "Vencord Contributor", image: CONTRIBUTOR_BADGE, position: BadgePosition.START, - shouldShow: ({ user }) => isPluginDev(user.id), - onClick: (_, { user }) => openContributorModal(user) + shouldShow: ({ userId }) => isPluginDev(userId), + onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId)) }; let DonorBadges = {} as Record>>; @@ -66,7 +68,7 @@ export default definePlugin({ replacement: [ { match: /&&(\i)\.push\(\{id:"premium".+?\}\);/, - replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));", + replace: "$&$1.unshift(...$self.getBadges(arguments[0]));", }, { // alt: "", aria-hidden: false, src: originalSrc @@ -82,7 +84,40 @@ export default definePlugin({ // conditionally override their onClick with badge.onClick if it exists { match: /href:(\i)\.link/, - replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, arguments[0]) }),$&" + replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&" + } + ] + }, + + /* new profiles */ + { + find: ".PANEL]:14", + replacement: { + match: /(?<=\i=\(0,\i\.default\)\(\i\);)return 0===\i.length/, + replace: "$& && $self.getBadges(arguments[0]?.displayProfile).length===0" + } + }, + { + find: ".description,delay:", + replacement: [ + { + match: /...(\i)\}=\(0,\i\.useUserProfileAnalyticsContext\)\(\);/, + replace: "$&arguments[0].badges?.unshift(...$self.getBadges($1));" + }, + { + // alt: "", aria-hidden: false, src: originalSrc + match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/, + // ...badge.props, ..., src: badge.image ?? ... + replace: "...$1.props,$& $1.image??" + }, + { + match: /(?<=text:(\i)\.description,.{0,50})children:/, + replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :" + }, + // conditionally override their onClick with badge.onClick if it exists + { + match: /href:(\i)\.link/, + replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&" } ] } @@ -104,6 +139,17 @@ export default definePlugin({ await loadBadges(); }, + getBadges(props: { userId: string; user?: User; guildId: string; }) { + try { + props.userId ??= props.user?.id!; + + return _getBadges(props); + } catch (e) { + new Logger("BadgeAPI#hasBadges").error(e); + return []; + } + }, + renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => { const Component = badge.component!; return ; diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index ea2ae125c..eef74d65e 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -130,9 +130,9 @@ const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false, sma }; const badge: ProfileBadge = { - component: p => , + component: p => , position: BadgePosition.START, - shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length, + shouldShow: userInfo => !!Object.keys(getStatus(userInfo.userId) ?? {}).length, key: "indicator" }; From 4ec01d0f40a4b1d4ca8fb7fb8a78a23a9ea3055e Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 8 Jun 2024 05:54:36 +0200 Subject: [PATCH 12/12] disable UseEcoQoSForBackgroundProcess --- src/main/patcher.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/patcher.ts b/src/main/patcher.ts index a3725ef9b..e5b87290d 100644 --- a/src/main/patcher.ts +++ b/src/main/patcher.ts @@ -131,11 +131,16 @@ if (!IS_VANILLA) { process.env.DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); - // Monkey patch commandLine to disable WidgetLayering: Fix DevTools context menus https://github.com/electron/electron/issues/38790 + // Monkey patch commandLine to: + // - disable WidgetLayering: Fix DevTools context menus https://github.com/electron/electron/issues/38790 + // - disable UseEcoQoSForBackgroundProcess: Work around Discord unloading when in background const originalAppend = app.commandLine.appendSwitch; app.commandLine.appendSwitch = function (...args) { - if (args[0] === "disable-features" && !args[1]?.includes("WidgetLayering")) { - args[1] += ",WidgetLayering"; + if (args[0] === "disable-features") { + const disabledFeatures = new Set((args[1] ?? "").split(",")); + disabledFeatures.add("WidgetLayering"); + disabledFeatures.add("UseEcoQoSForBackgroundProcess"); + args[1] += [...disabledFeatures].join(","); } return originalAppend.apply(this, args); };