From dfc3f05834db65fc73fa939957a39498c0428a9c Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 23 Apr 2023 23:33:55 +0200 Subject: [PATCH 001/102] Fix RoleColorEverywhere crash --- src/plugins/roleColorEverywhere.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/roleColorEverywhere.tsx b/src/plugins/roleColorEverywhere.tsx index 65a1cc060..88a6cc246 100644 --- a/src/plugins/roleColorEverywhere.tsx +++ b/src/plugins/roleColorEverywhere.tsx @@ -53,7 +53,7 @@ export default definePlugin({ replacement: [ { match: /user:(\i),channel:(\i).{0,300}?"@"\.concat\(.+?\)/, - replace: "$&,color:$self.getUserColor($1.id,{channelId:$2?.id})" + replace: "$&,color:$self.getUserColor($1?.id,{channelId:$2?.id})" } ], predicate: () => settings.store.chatMentions, @@ -99,10 +99,12 @@ export default definePlugin({ if (!(guildId ??= ChannelStore.getChannel(channelId!)?.guild_id)) return null; return GuildMemberStore.getMember(guildId, userId)?.colorString ?? null; }, + getUserColor(userId: string, ids: { channelId?: string; guildId?: string; }) { const colorString = this.getColor(userId, ids); return colorString && parseInt(colorString.slice(1), 16); }, + roleGroupColor({ id, count, title, guildId }: { id: string; count: number; title: string; guildId: string; }) { const guild = GuildStore.getGuild(guildId); const role = guild?.roles[id]; @@ -113,6 +115,7 @@ export default definePlugin({ letterSpacing: ".05em" }}>{title} — {count}; }, + getVoiceProps({ user: { id: userId }, guildId }: { user: { id: string; }; guildId: string; }) { return { style: { From 5be86f9bd160edea9a525e5a3b249ba573284d33 Mon Sep 17 00:00:00 2001 From: Hazel Summer Date: Mon, 24 Apr 2023 00:42:38 +0100 Subject: [PATCH 002/102] WhoReacted: Fix clicking user pfps also adding reaction (#977) --- src/plugins/whoReacted.tsx | 26 ++++++++++++++++---------- src/utils/constants.ts | 4 ++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/plugins/whoReacted.tsx b/src/plugins/whoReacted.tsx index 4b1c828fd..6ceb301ca 100644 --- a/src/plugins/whoReacted.tsx +++ b/src/plugins/whoReacted.tsx @@ -85,10 +85,14 @@ function makeRenderMoreUsers(users: User[]) { }; } +function handleClickAvatar(event: React.MouseEvent) { + event.stopPropagation(); +} + export default definePlugin({ name: "WhoReacted", description: "Renders the Avatars of reactors", - authors: [Devs.Ven], + authors: [Devs.Ven, Devs.KannaDev], patches: [{ find: ",reactionRef:", @@ -132,15 +136,17 @@ export default definePlugin({
- +
+ +
); } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 26430ff01..d9d106751 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -273,5 +273,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({ FieryFlames: { name: "Fiery", id: 890228870559698955n + }, + KannaDev: { + name: "Kanna", + id: 317728561106518019n } }); From 5f5d4b896193a632d3bc6e16048ec92843e01c71 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 01:13:42 +0200 Subject: [PATCH 003/102] [skip ci] UserScript: Fix cors check pt 2 --- browser/GMPolyfill.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/GMPolyfill.js b/browser/GMPolyfill.js index beee9156a..1f74a7c63 100644 --- a/browser/GMPolyfill.js +++ b/browser/GMPolyfill.js @@ -59,7 +59,9 @@ async function checkCors(url, method) { const origin = headers["access-control-allow-origin"]; if (origin !== "*" && origin !== window.location.origin) return false; - const methods = headers["access-control-allow-methods"]?.toLowerCase().split(/,\s/g); + const methods = headers["access-control-allow-methods"]?.toLowerCase() + .split(",") + .map(s => s.trim()); if (methods && !methods.includes(method.toLowerCase())) return false; return true; From 7d00b6a842cd0a6cce397fb7dcde17211a00eff6 Mon Sep 17 00:00:00 2001 From: V Date: Fri, 28 Apr 2023 02:17:33 +0200 Subject: [PATCH 004/102] README: Add screenshot & more info --- README.md | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index fa754d617..a470863cb 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,13 @@ The cutest Discord client mod + +![A screenshot of Vencord featuring the ClearVision-v6 theme](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png) + ## Features - Super easy to install (Download Installer, open, click install button, done) -- 100+ plugins built in: [See a list](https://gist.github.com/Vendicated/8696cde7b92548064a3ae92ead84d033) +- 100+ plugins built in: [See a list](https://vencord.dev/plugins) - Some highlights: SpotifyControls, GameActivityToggle, Experiments, NoTrack, MessageLogger, QuickReply, Free Emotes/Stickers, CustomCommands, ShowHiddenChannels, PronounDB - Fairly lightweight despite the many inbuilt plugins - Excellent Browser Support: Run Vencord in your Browser via extension or UserScript @@ -13,10 +16,14 @@ The cutest Discord client mod - Custom CSS and Themes: Inbuilt css editor with support to import any css files (including BetterDiscord themes) - Privacy friendly, blocks Discord analytics & crash reporting out of the box and has no telemetry - Maintained very actively, broken plugins are usually fixed within 12 hours +- Settings sync: Keep your plugins and their settings synchronised between devices / apps (optional) + ## Installing / Uninstalling -[![Download and run the Installer ](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#usage) +Click the below button to install Vencord to the Discord Desktop app + +[![Download and run the Installer](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#usage) ## Installing on Browser @@ -24,25 +31,24 @@ The cutest Discord client mod Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that the CSS Editor, Themes loaded from remote sources and co. will not work in the UserScript. Use the extension if you need any of those -## Building from Source +## Join our Support/Community Server -See the docs folder - -## Contributing - -See [CONTRIBUTING.md](CONTRIBUTING.md) and [Megu's Plugin Guide!](docs/2_PLUGINS.md) - -[contribute]: CONTRIBUTING.md - -[contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] [contribute] - -## Join - -[join]: https://discord.gg/D9uwnFnqmd - -[join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] [join] +[![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd) ## Disclaimer Discord is trademark of Discord Inc. and solely mentioned for the sake of descriptivity. Mention of it does not imply any affiliation with or endorsement by Discord Inc. + +
+Vencord violates Discord's terms of service + +Client modifications are against Discord’s Terms of Service. + +However, Discord is pretty indifferent about them and there are no known cases of users getting banned for using client mods! So you should generally be fine as long as you don’t use any plugins that implement abusive behaviour. But no worries, all inbuilt plugins are safe to use! + +Regardless, if your account is very important to you and it getting disabled would be a disaster for you, you should probably not use any client mods (not exclusive to Vencord), just to be safe + +Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it + +
From 24f161d6e95321ead6557909d1ef33cdc91bcc72 Mon Sep 17 00:00:00 2001 From: V Date: Fri, 28 Apr 2023 02:48:39 +0200 Subject: [PATCH 005/102] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a470863cb..72e1d82b2 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The cutest Discord client mod Click the below button to install Vencord to the Discord Desktop app -[![Download and run the Installer](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#usage) +[![Download and run the Installer](https://img.shields.io/github/v/release/Vencord/Installer?label=Download%20Vencord%20Installer&style=for-the-badge)](https://github.com/Vencord/Installer#vencord-installer) ## Installing on Browser @@ -31,6 +31,12 @@ Click the below button to install Vencord to the Discord Desktop app Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that the CSS Editor, Themes loaded from remote sources and co. will not work in the UserScript. Use the extension if you need any of those +## Installing our Desktop App + +As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app. It is currently in beta and we have yet to implement some features like screensharing, but you can try the beta nonetheless + +[![Download Vencord Desktop](https://img.shields.io/github/v/release/Vencord/Desktop?label=Download%20Vencord%20Desktop&style=for-the-badge)](https://github.com/Vencord/Desktop#vencord-desktop) + ## Join our Support/Community Server [![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd) From 6548163d3e58a779b991dc97af2b4ab08ec6568e Mon Sep 17 00:00:00 2001 From: V Date: Fri, 28 Apr 2023 02:49:34 +0200 Subject: [PATCH 006/102] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72e1d82b2..6fe3666ac 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Discord is trademark of Discord Inc. and solely mentioned for the sake of descri Mention of it does not imply any affiliation with or endorsement by Discord Inc.
-Vencord violates Discord's terms of service +Using Vencord violates Discord's terms of service Client modifications are against Discord’s Terms of Service. From c0954a184443e88f0ac2698e2ca3e829094c6219 Mon Sep 17 00:00:00 2001 From: V Date: Fri, 28 Apr 2023 02:51:18 +0200 Subject: [PATCH 007/102] Specify that theme in screenshot is only an example --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fe3666ac..cc1c4bdeb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ The cutest Discord client mod -![A screenshot of Vencord featuring the ClearVision-v6 theme](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png) +![](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png) +*A screenshot of Vencord featuring the [ClearVision-v6 theme](https://github.com/ClearVision/ClearVision-v6) (Vencord does not come with it pre-installed, it is only an example)* ## Features From f8ace5b53a9450d4b2f05c687960a93c1145cfb5 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 02:56:57 +0200 Subject: [PATCH 008/102] [skip ci] definePluginSettings: Add missing BigInt type --- src/utils/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/types.ts b/src/utils/types.ts index d2b5e0ed4..4d71027d8 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -133,6 +133,7 @@ export type PluginSettingDef = ( | PluginSettingSelectDef | PluginSettingSliderDef | PluginSettingComponentDef + | PluginSettingBigIntDef ) & PluginSettingCommon; export interface PluginSettingCommon { From 0cc3901e4e1d3f98b44a502ea927703dd336c277 Mon Sep 17 00:00:00 2001 From: carince <99774021+carince@users.noreply.github.com> Date: Fri, 28 Apr 2023 10:03:38 +0800 Subject: [PATCH 009/102] MuteNewGuilds: add toggles for guild, everyone, and roles. (#979) Co-authored-by: V Co-authored-by: Norikiru <99774021+Norikiru@users.noreply.github.com> --- src/plugins/muteNewGuild.tsx | 32 +++++++++++++++++++++++++++++--- src/utils/constants.ts | 4 ++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/plugins/muteNewGuild.tsx b/src/plugins/muteNewGuild.tsx index 9be1a674d..cf15b7717 100644 --- a/src/plugins/muteNewGuild.tsx +++ b/src/plugins/muteNewGuild.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import { ModalContent, ModalFooter, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { findByProps, findStoreLazy } from "@webpack"; import { Button, Text } from "@webpack/common"; @@ -49,10 +50,28 @@ function NoDMNotificationsModal({ modalProps }: { modalProps: ModalProps; }) { ); } +const settings = definePluginSettings({ + guild: { + description: "Mute Guild", + type: OptionType.BOOLEAN, + default: true + }, + everyone: { + description: "Suppress @everyone and @here", + type: OptionType.BOOLEAN, + default: true + }, + role: { + description: "Suppress All Role @mentions", + type: OptionType.BOOLEAN, + default: true + }, +}); + export default definePlugin({ name: "MuteNewGuild", description: "Mutes newly joined guilds", - authors: [Devs.Glitch, Devs.Nuckyz], + authors: [Devs.Glitch, Devs.Nuckyz, Devs.carince], patches: [ { find: ",acceptInvite:function", @@ -62,10 +81,17 @@ export default definePlugin({ } } ], + settings, handleMute(guildId: string | null) { if (guildId === "@me" || guildId === "null" || guildId == null) return; - findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, { muted: true, suppress_everyone: true, suppress_roles: true }); + findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(guildId, + { + muted: settings.store.guild, + suppress_everyone: settings.store.everyone, + suppress_roles: settings.store.role + } + ); }, start() { diff --git a/src/utils/constants.ts b/src/utils/constants.ts index d9d106751..69eb60441 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -277,5 +277,9 @@ export const Devs = /* #__PURE__*/ Object.freeze({ KannaDev: { name: "Kanna", id: 317728561106518019n + }, + carince: { + name: "carince", + id: 818323528755314698n } }); From c1fca76f9434a8ce6fd31a8f9e40752bc3da151f Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 03:08:01 +0200 Subject: [PATCH 010/102] SilentMessageToggle: Add missing dependency on MessageEventsApi --- src/plugins/silentMessageToggle.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/silentMessageToggle.tsx b/src/plugins/silentMessageToggle.tsx index f90ba8ad0..5e42444a1 100644 --- a/src/plugins/silentMessageToggle.tsx +++ b/src/plugins/silentMessageToggle.tsx @@ -98,6 +98,8 @@ export default definePlugin({ name: "SilentMessageToggle", authors: [Devs.Nuckyz], description: "Adds a button to the chat bar to toggle sending a silent message.", + dependencies: ["MessageEventsAPI"], + settings, patches: [ { From 0fe0fecba25b060830c524f50cb9b046273831da Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 04:23:42 +0200 Subject: [PATCH 011/102] MessageLogger: Nicer context menu --- src/plugins/messageLogger/index.tsx | 31 ++++++++++++++++------------- src/webpack/common/types/menu.d.ts | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index d134cd267..484429fbf 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -51,11 +51,28 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) = if (!deleted && !editHistory?.length) return; + toggle: { + if (!deleted) break toggle; + + const domElement = document.getElementById(`chat-messages-${channel_id}-${id}`); + if (!domElement) break toggle; + + children.push(( + domElement.classList.toggle("messagelogger-deleted")} + /> + )); + } + children.push(( { if (deleted) { FluxDispatcher.dispatch({ @@ -70,20 +87,6 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) = }} /> )); - - if (!deleted) return; - - const domElement = document.getElementById(`chat-messages-${channel_id}-${id}`); - if (!domElement) return; - - children.push(( - domElement.classList.toggle("messagelogger-deleted")} - /> - )); }; export default definePlugin({ diff --git a/src/webpack/common/types/menu.d.ts b/src/webpack/common/types/menu.d.ts index b52e78fdb..39e15307a 100644 --- a/src/webpack/common/types/menu.d.ts +++ b/src/webpack/common/types/menu.d.ts @@ -38,6 +38,7 @@ export interface Menu { label: string; action?(e: MouseEvent): void; + color?: string; render?: ComponentType; onChildrenScroll?: Function; childRowHeight?: number; From 1b2cb52dac86bc97fc42b3b040460cff68c9bf0a Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 18:36:22 +0200 Subject: [PATCH 012/102] ViewIcons: Fix viewing banners --- src/plugins/viewIcons.tsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx index 7519d74f2..dea5bf8a0 100644 --- a/src/plugins/viewIcons.tsx +++ b/src/plugins/viewIcons.tsx @@ -167,26 +167,30 @@ export default definePlugin({ }, patches: [ + // Make pfps clickable { find: "onAddFriend:", replacement: { - // global because Discord has two components that are 99% identical with one small change ._. - match: /\{src:(\i),avatarDecoration/g, - replace: "{src:$1,onClick:()=>$self.openImage($1),avatarDecoration" + match: /\{src:(\i)(?=,avatarDecoration)/, + replace: "{src:$1,onClick:()=>$self.openImage($1)" } - }, { - find: ".popoutNoBannerPremium", + }, + // Make banners clickable + { + find: ".NITRO_BANNER,", replacement: { - match: /style:.{0,10}\{\},(\i)\)/, + // style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl, + match: /style:\{(?=backgroundImage:(\i&&\i)\?"url\("\.concat\((\i),)/, replace: - "onClick:$1.backgroundImage&&($1.cursor=\"pointer\"," + - "()=>$self.openImage($1.backgroundImage.replace(\"url(\", \"\"))),$&" + // onClick: () => shouldShowBanner && openImage(bannerUrl), style: { cursor: shouldShowBanner ? "pointer" : void 0, + 'onClick:()=>$1&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,' } - }, { + }, + { find: "().avatarWrapperNonUserBot", replacement: { - match: /(avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/, - replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" + match: /(?<=avatarPositionPanel.+?)onClick:(\i\|\|\i)\?void 0(?<=,(\i)=\i\.avatarSrc.+?)/, + replace: "style:($1)?{cursor:\"pointer\"}:{},onClick:$1?()=>{$self.openImage($2)}" } } ] From 7b13b9a53ea92c337b9840c0050c6a47266efdcc Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 19:15:07 +0200 Subject: [PATCH 013/102] PronounDB: Fix not working in profiles --- .../components/PronounsChatComponent.tsx | 51 +++++++-------- .../components/PronounsProfileWrapper.tsx | 61 ----------------- src/plugins/pronoundb/index.ts | 65 +++++-------------- src/plugins/pronoundb/pronoundbUtils.ts | 22 ++++++- src/plugins/pronoundb/settings.ts | 55 ++++++++++++++++ 5 files changed, 112 insertions(+), 142 deletions(-) delete mode 100644 src/plugins/pronoundb/components/PronounsProfileWrapper.tsx create mode 100644 src/plugins/pronoundb/settings.ts diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 70a2bf3b0..e302676b9 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -16,66 +16,59 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; import { classes } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; import { UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { awaitAndFormatPronouns } from "../pronoundbUtils"; +import { useFormattedPronouns } from "../pronoundbUtils"; +import { settings } from "../settings"; const styles: Record = findByPropsLazy("timestampInline"); function shouldShow(message: Message): boolean { - // Respect showInMessages - if (!Settings.plugins.PronounDB.showInMessages) + if (!settings.store.showInMessages) return false; - // Don't bother fetching bot or system users if (message.author.bot || message.author.system) return false; - // Respect showSelf options - if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id) + if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id) return false; return true; } export function PronounsChatComponentWrapper({ message }: { message: Message; }) { - if (!shouldShow(message)) - return null; - - return ; + return shouldShow(message) + ? + : null; } export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) { - if (!shouldShow(message)) - return null; - - return ; + return shouldShow(message) + ? + : null; } function PronounsChatComponent({ message }: { message: Message; }) { - const result = awaitAndFormatPronouns(message.author.id); - if (result != null) { - return ( + const result = useFormattedPronouns(message.author.id); + + return result + ? ( • {result} - ); - } - - return null; + ) + : null; } export function CompactPronounsChatComponent({ message }: { message: Message; }) { - const result = awaitAndFormatPronouns(message.author.id); - if (result != null) { - return ( + const result = useFormattedPronouns(message.author.id); + + return result + ? ( • {result} - ); - } - - return null; + ) + : null; } diff --git a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx deleted file mode 100644 index 34cfab5a5..000000000 --- a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 . -*/ - -import { Settings } from "@api/settings"; -import { UserStore } from "@webpack/common"; - -import { awaitAndFormatPronouns } from "../pronoundbUtils"; -import { UserProfilePronounsProps, UserProfileProps } from "../types"; - -export default function PronounsProfileWrapper(PronounsComponent: React.ElementType, props: UserProfilePronounsProps, profileProps: UserProfileProps) { - const user = UserStore.getUser(profileProps.userId) ?? {}; - // Respect showInProfile - if (!Settings.plugins.PronounDB.showInProfile) - return null; - // Don't bother fetching bot or system users - if (user.bot || user.system) - return null; - // Respect showSelf options - if (!Settings.plugins.PronounDB.showSelf && user.id === UserStore.getCurrentUser().id) - return null; - - return ; -} - -function ProfilePronouns( - { userId, Component, leProps }: { - userId: string; - Component: React.ElementType; - leProps: UserProfilePronounsProps; - } -) { - const result = awaitAndFormatPronouns(userId); - - // If the promise completed, the result was not "unspecified", and there is a mapping for the code, then render - if (result != null) { - // First child is the header, second is a div with the actual text - leProps.currentPronouns ||= result; - return ; - } - - return null; -} diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 59ade8da8..bc01e1d28 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -19,20 +19,16 @@ import "./styles.css"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; +import definePlugin from "@utils/types"; import PronounsAboutComponent from "./components/PronounsAboutComponent"; import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent"; -import PronounsProfileWrapper from "./components/PronounsProfileWrapper"; - -export enum PronounsFormat { - Lowercase = "LOWERCASE", - Capitalized = "CAPITALIZED" -} +import { useProfilePronouns } from "./pronoundbUtils"; +import { settings } from "./settings"; export default definePlugin({ name: "PronounDB", - authors: [Devs.Tyman, Devs.TheKodeToad], + authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven], description: "Adds pronouns to user messages using pronoundb", patches: [ // Add next to username (compact mode) @@ -51,59 +47,30 @@ export default definePlugin({ replace: "[$1, $self.PronounsChatComponentWrapper(e)]" } }, - // Hijack the discord pronouns section and add a wrapper around the text section + // Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns { - find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", + find: ".userTagNoNickname", replacement: { - match: /\(0,.\.jsx\)\((?\i\..),(?{currentPronouns.+?:(?\i)\.pronouns.+?})\)/, - replace: "$&&$self.PronounsProfileWrapper($,$,$)" + match: /=(\i)\.pronouns/, + replace: "=$self.useProfilePronouns($1.user.id)" } }, - // Force enable pronouns component ignoring the experiment value + // Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns { - find: ".Messages.USER_POPOUT_PRONOUNS", + find: ".USER_PROFILE_ACTIVITY", replacement: { - match: /\.showPronouns/, - replace: ".showPronouns||true" + match: /\).showPronouns/, + replace: ").showPronouns||true;if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=$self.useProfilePronouns(arguments[0].user.id)" } } ], - options: { - pronounsFormat: { - type: OptionType.SELECT, - description: "The format for pronouns to appear in chat", - options: [ - { - label: "Lowercase", - value: PronounsFormat.Lowercase, - default: true - }, - { - label: "Capitalized", - value: PronounsFormat.Capitalized - } - ] - }, - showSelf: { - type: OptionType.BOOLEAN, - description: "Enable or disable showing pronouns for the current user", - default: true - }, - showInMessages: { - type: OptionType.BOOLEAN, - description: "Show in messages", - default: true - }, - showInProfile: { - type: OptionType.BOOLEAN, - description: "Show in profile", - default: true - } - }, + settings, + settingsAboutComponent: PronounsAboutComponent, + // Re-export the components on the plugin object so it is easily accessible in patches PronounsChatComponentWrapper, CompactPronounsChatComponentWrapper, - PronounsProfileWrapper + useProfilePronouns }); diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index c2354c353..c079e36b0 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -20,10 +20,16 @@ import { Settings } from "@api/settings"; import { VENCORD_USER_AGENT } from "@utils/constants"; import { debounce } from "@utils/debounce"; import { useAwaiter } from "@utils/misc"; +import { UserStore } from "@webpack/common"; -import { PronounsFormat } from "."; +import { settings } from "./settings"; import { PronounCode, PronounMapping, PronounsResponse } from "./types"; +export const enum PronounsFormat { + Lowercase = "LOWERCASE", + Capitalized = "CAPITALIZED" +} + // A map of cached pronouns so the same request isn't sent twice const cache: Record = {}; // A map of ids and callbacks that should be triggered on fetch @@ -40,8 +46,8 @@ const bulkFetch = debounce(async () => { } }); -export function awaitAndFormatPronouns(id: string): string | null { - const [result, , isPending] = useAwaiter(() => fetchPronouns(id), { +export function useFormattedPronouns(id: string): string | null { + const [result] = useAwaiter(() => fetchPronouns(id), { fallbackValue: getCachedPronouns(id), onError: e => console.error("Fetching pronouns failed: ", e) }); @@ -53,6 +59,16 @@ export function awaitAndFormatPronouns(id: string): string | null { return null; } +export function useProfilePronouns(id: string) { + const pronouns = useFormattedPronouns(id); + + if (!settings.store.showInProfile) return null; + if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return null; + + return pronouns; +} + + // Gets the cached pronouns, if you're too impatient for a promise! export function getCachedPronouns(id: string): PronounCode | null { return cache[id] ?? null; diff --git a/src/plugins/pronoundb/settings.ts b/src/plugins/pronoundb/settings.ts new file mode 100644 index 000000000..4ccadaa14 --- /dev/null +++ b/src/plugins/pronoundb/settings.ts @@ -0,0 +1,55 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * 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 . +*/ + +import { definePluginSettings } from "@api/settings"; +import { OptionType } from "@utils/types"; + +import { PronounsFormat } from "./pronoundbUtils"; + +export const settings = definePluginSettings({ + pronounsFormat: { + type: OptionType.SELECT, + description: "The format for pronouns to appear in chat", + options: [ + { + label: "Lowercase", + value: PronounsFormat.Lowercase, + default: true + }, + { + label: "Capitalized", + value: PronounsFormat.Capitalized + } + ] + }, + showSelf: { + type: OptionType.BOOLEAN, + description: "Enable or disable showing pronouns for the current user", + default: true + }, + showInMessages: { + type: OptionType.BOOLEAN, + description: "Show in messages", + default: true + }, + showInProfile: { + type: OptionType.BOOLEAN, + description: "Show in profile", + default: true + } +}); From e7d0fc258d5283973e68ae698b0f172f951546be Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 19:32:29 +0200 Subject: [PATCH 014/102] [skip ci] WebContextMenus: fix false ci test positives --- src/plugins/webContextMenus.web.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/webContextMenus.web.ts b/src/plugins/webContextMenus.web.ts index 2e9d58147..4ded483c7 100644 --- a/src/plugins/webContextMenus.web.ts +++ b/src/plugins/webContextMenus.web.ts @@ -121,7 +121,7 @@ export default definePlugin({ predicate: () => settings.store.addBack, replacement: { // return IS_DESKTOP ? React.createElement(Menu, ...) - match: /return \i\.\i\?(?=\(0,\i\.jsxs?\)\(\i\.Menu)/, + match: /return \i\.\i\?/, replace: "return true?" } }, @@ -146,7 +146,7 @@ export default definePlugin({ } }, { - find: 'navId:"textarea-context"', + find: ':"command-suggestions"', predicate: () => settings.store.addBack, replacement: [ { From d70d7c7b498b1a08c2b50544e8e7c0ffada86f38 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 19:34:21 +0200 Subject: [PATCH 015/102] [skip ci] reporter: reduce sleep time --- scripts/generateReport.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index b5e705bdc..61e0e8f10 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -267,7 +267,7 @@ function runTime(token: string) { if (!isWasm) await wreq.e(id as any); - await new Promise(r => setTimeout(r, 500)); + await new Promise(r => setTimeout(r, 150)); } console.error("[PUP_DEBUG]", "Finished loading chunks!"); From ec72b4c91d422fa95ee93d71f3be839fdad679de Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Apr 2023 02:02:24 +0200 Subject: [PATCH 016/102] PronounDB: Oop, conditional hooks are bad :> --- src/plugins/pronoundb/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index bc01e1d28..227e07d55 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -60,7 +60,7 @@ export default definePlugin({ find: ".USER_PROFILE_ACTIVITY", replacement: { match: /\).showPronouns/, - replace: ").showPronouns||true;if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=$self.useProfilePronouns(arguments[0].user.id)" + replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=vcPronounce" } } ], From a2e03084b001a154bf1b33b213480028bb2d4e59 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Apr 2023 02:06:52 +0200 Subject: [PATCH 017/102] BadgeAPI: Add support for multiple donor badges --- src/api/Badges.ts | 4 +- src/plugins/apiBadges.tsx | 139 +++++++++++++++++++------------------- 2 files changed, 70 insertions(+), 73 deletions(-) diff --git a/src/api/Badges.ts b/src/api/Badges.ts index 9abaefe2b..a0961c46d 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -79,8 +79,8 @@ export function _getBadges(args: BadgeUserArgs) { : badges.push({ ...badge, ...args }); } } - const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id); - if (donorBadge) badges.unshift(donorBadge); + const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/apiBadges").default).getDonorBadges(args.user.id); + if (donorBadges) badges.unshift(...donorBadges); return badges; } diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index 57c5b385a..a156b63c2 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -48,7 +48,7 @@ const ContributorBadge: ProfileBadge = { link: "https://github.com/Vendicated/Vencord" }; -const DonorBadges = {} as Record>; +const DonorBadges = {} as Record[]>; export default definePlugin({ name: "BadgeAPI", @@ -97,78 +97,75 @@ export default definePlugin({ } for (const line of lines) { const [id, description, image] = line.split(","); - DonorBadges[id] = { image, description }; + (DonorBadges[id] ??= []).push({ image, description }); } }, - getDonorBadge(userId: string) { - const badge = DonorBadges[userId]; - if (badge) { - return { - ...badge, - position: BadgePosition.START, - props: { - style: { - borderRadius: "50%", - transform: "scale(0.9)" // The image is a bit too big compared to default badges - } - }, - onClick() { - const modalKey = openModal(props => ( - { - closeModal(modalKey); - VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); - }}> - - - - - - Vencord Donor - - - - - - - - -
- - This Badge is a special perk for Vencord Donors - - - Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! - -
-
- - - - - -
-
- )); - }, - }; - } + getDonorBadges(userId: string) { + return DonorBadges[userId]?.map(badge => ({ + ...badge, + position: BadgePosition.START, + props: { + style: { + borderRadius: "50%", + transform: "scale(0.9)" // The image is a bit too big compared to default badges + } + }, + onClick() { + const modalKey = openModal(props => ( + { + closeModal(modalKey); + VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); + }}> + + + + + + Vencord Donor + + + + + + + + +
+ + This Badge is a special perk for Vencord Donors + + + Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! + +
+
+ + + + + +
+
+ )); + }, + })); } }); From bf795c49dfe988f3013cda35cfe18e124456f23f Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Apr 2023 04:16:28 +0200 Subject: [PATCH 018/102] [skip ci] Update Monaco; Fix code scanning errors --- browser/background.js | 2 +- src/components/monacoWin.html | 104 +++++++++++++++++------------- src/plugins/messageLinkEmbeds.tsx | 2 +- src/utils/types.ts | 2 + 4 files changed, 63 insertions(+), 47 deletions(-) diff --git a/browser/background.js b/browser/background.js index 7fc4a8224..1f2d5ec17 100644 --- a/browser/background.js +++ b/browser/background.js @@ -16,7 +16,7 @@ chrome.webRequest.onHeadersReceived.addListener( // In main frame requests, the CSP needs to be removed to enable fetching of custom css // as desired by the user removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-security-policy"); - } else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com")) { + } else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com/")) { // Most users will load css from GitHub, but GitHub doesn't set the correct content type, // so we fix it here removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type"); diff --git a/src/components/monacoWin.html b/src/components/monacoWin.html index d9d24121f..57d321410 100644 --- a/src/components/monacoWin.html +++ b/src/components/monacoWin.html @@ -1,52 +1,66 @@ - + + + + Vencord QuickCSS Editor + + + - - - Vencord QuickCSS Editor - - - + +
+ - -
- + - - + + diff --git a/src/plugins/messageLinkEmbeds.tsx b/src/plugins/messageLinkEmbeds.tsx index e3a28a737..951835abc 100644 --- a/src/plugins/messageLinkEmbeds.tsx +++ b/src/plugins/messageLinkEmbeds.tsx @@ -51,7 +51,7 @@ const SearchResultClasses = findByPropsLazy("message", "searchResult"); let AutoModEmbed: React.ComponentType = () => null; const messageLinkRegex = /(? void; }; + + tags?: string[]; } export enum OptionType { From b95c5c6619bdd9d2d42089d02f553a43bfb68dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20Ho=C3=A0i=20Tu=C3=A2n?= Date: Sat, 29 Apr 2023 15:08:04 -0700 Subject: [PATCH 019/102] Fix USRBG (#1000) Co-authored-by: V --- src/plugins/usrbg/index.css | 21 --------------------- src/plugins/usrbg/index.tsx | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/plugins/usrbg/index.css b/src/plugins/usrbg/index.css index 6d1bd9bd7..819d9751d 100644 --- a/src/plugins/usrbg/index.css +++ b/src/plugins/usrbg/index.css @@ -4,27 +4,6 @@ z-index: -1; } -[class*="userPopout"] [class*="NonPremium"] [class*="bannerPremium"] { - top: -30px; -} - -[class*="NonPremium"]:has([class*="bannerPremium"]) [class*="bannerSVGWrapper"] { - min-height: 120px !important; -} - -[class*="NonPremium"]:has([class*="bannerPremium"]) [class*="bannerSVGWrapper"] foreignObject { - height: 360px; -} - -[class*="userPopout"] [class*="NonPremium"]:has([class*="bannerPremium"]) [class*="bannerSVGWrapper"] rect { - height: 120px; - y: -30; -} - -[class*="userPopout"] [class*="NonPremium"]:has([class*="bannerPremium"]) [class*="bannerSVGWrapper"] circle { - cy: 86; -} - [class*="NonPremium"]:has([class*="bannerPremium"]) [class*="avatarPositionNormal"], [class*="PremiumWithoutBanner"]:has([class*="bannerPremium"]) [class*="avatarPositionPremiumNoBanner"] { top: 76px; diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index c898d929a..09ecd573e 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -46,11 +46,17 @@ export default definePlugin({ settings, patches: [ { - find: ".bannerSrc,", - replacement: { - match: /(\i)\.bannerSrc,/, - replace: "$self.useBannerHook($1)," - } + find: ".NITRO_BANNER,", + replacement: [ + { + match: /(\i)\.premiumType/, + replace: "$self.premiumHook($1)||$&" + }, + { + match: /(\i)\.bannerSrc,/, + replace: "$self.useBannerHook($1)," + } + ] } ], @@ -65,6 +71,10 @@ export default definePlugin({ if (data[user.id]) return data[user.id]; }, + premiumHook({ userId }: any) { + if (data[userId]) return 2; + }, + async start() { enableStyle(style); From 070aa343efdf2b6c006434b5f10660e9f999a667 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Apr 2023 23:19:14 +0200 Subject: [PATCH 020/102] Remove migratePluginSettings calls --- src/plugins/betterRoleDot.ts | 3 +-- src/plugins/clearURLs/index.ts | 2 -- src/plugins/fakeNitro.tsx | 4 +--- src/plugins/messageClickActions.ts | 3 --- src/plugins/moreKaomoji.ts | 2 -- src/plugins/noDevtoolsWarning.ts | 3 --- src/plugins/noF1.ts | 2 -- src/plugins/noRPC.discordDesktop.ts | 2 -- src/plugins/quickReply.ts | 3 +-- src/plugins/spotifyCrack.ts | 3 +-- src/plugins/spotifyShareCommands.ts | 2 -- src/plugins/vcDoubleClick.ts | 2 -- 12 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/plugins/betterRoleDot.ts b/src/plugins/betterRoleDot.ts index 1fc18c370..fc13b7b89 100644 --- a/src/plugins/betterRoleDot.ts +++ b/src/plugins/betterRoleDot.ts @@ -16,12 +16,11 @@ * along with this program. If not, see . */ -import { migratePluginSettings, Settings } from "@api/settings"; +import { Settings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Clipboard, Toasts } from "@webpack/common"; -migratePluginSettings("BetterRoleDot", "ClickableRoleDot"); export default definePlugin({ name: "BetterRoleDot", authors: [Devs.Ven], diff --git a/src/plugins/clearURLs/index.ts b/src/plugins/clearURLs/index.ts index 178a0e11f..d1be6c6f5 100644 --- a/src/plugins/clearURLs/index.ts +++ b/src/plugins/clearURLs/index.ts @@ -23,7 +23,6 @@ import { removePreEditListener, removePreSendListener } from "@api/MessageEvents"; -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; @@ -33,7 +32,6 @@ import { defaultRules } from "./defaultRules"; const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; const reHasRegExpChar = RegExp(reRegExpChar.source); -migratePluginSettings("ClearURLs", "clearURLs"); export default definePlugin({ name: "ClearURLs", description: "Removes tracking garbage from URLs", diff --git a/src/plugins/fakeNitro.tsx b/src/plugins/fakeNitro.tsx index fda9b6b7c..b067f2a35 100644 --- a/src/plugins/fakeNitro.tsx +++ b/src/plugins/fakeNitro.tsx @@ -17,7 +17,7 @@ */ import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; -import { definePluginSettings, migratePluginSettings, Settings } from "@api/settings"; +import { definePluginSettings, Settings } from "@api/settings"; import { Devs } from "@utils/constants"; import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies"; import { getCurrentGuild } from "@utils/discord"; @@ -149,8 +149,6 @@ const settings = definePluginSettings({ } }); -migratePluginSettings("FakeNitro", "NitroBypass"); - export default definePlugin({ name: "FakeNitro", authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity, Devs.captain, Devs.Nuckyz, Devs.AutumnVN], diff --git a/src/plugins/messageClickActions.ts b/src/plugins/messageClickActions.ts index c54a09c02..03f1eb76d 100644 --- a/src/plugins/messageClickActions.ts +++ b/src/plugins/messageClickActions.ts @@ -17,7 +17,6 @@ */ import { addClickListener, removeClickListener } from "@api/MessageEvents"; -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -29,8 +28,6 @@ const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = const MANAGE_CHANNELS = 1n << 4n; -migratePluginSettings("MessageClickActions", "MessageQuickActions"); - export default definePlugin({ name: "MessageClickActions", description: "Hold Backspace and click to delete, double click to edit", diff --git a/src/plugins/moreKaomoji.ts b/src/plugins/moreKaomoji.ts index 6be80d661..959910848 100644 --- a/src/plugins/moreKaomoji.ts +++ b/src/plugins/moreKaomoji.ts @@ -17,11 +17,9 @@ */ import { findOption, OptionalMessageOption } from "@api/Commands"; -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("MoreKaomoji", "moarKaomojis"); export default definePlugin({ name: "MoreKaomoji", description: "Adds more Kaomoji to discord. ヽ(´▽`)/", diff --git a/src/plugins/noDevtoolsWarning.ts b/src/plugins/noDevtoolsWarning.ts index 2dd514ee5..188b8fa3f 100644 --- a/src/plugins/noDevtoolsWarning.ts +++ b/src/plugins/noDevtoolsWarning.ts @@ -16,12 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("NoDevtoolsWarning", "STFU"); - export default definePlugin({ name: "NoDevtoolsWarning", description: "Disables the 'HOLD UP' banner in the console. As a side effect, also prevents Discord from hiding your token, which prevents random logouts.", diff --git a/src/plugins/noF1.ts b/src/plugins/noF1.ts index c951149e4..a40be5acc 100644 --- a/src/plugins/noF1.ts +++ b/src/plugins/noF1.ts @@ -16,11 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("NoF1", "No F1"); export default definePlugin({ name: "NoF1", description: "Disables F1 help bind.", diff --git a/src/plugins/noRPC.discordDesktop.ts b/src/plugins/noRPC.discordDesktop.ts index ebd7b1a34..ebbbd5e8f 100644 --- a/src/plugins/noRPC.discordDesktop.ts +++ b/src/plugins/noRPC.discordDesktop.ts @@ -16,11 +16,9 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -migratePluginSettings("NoRPC", "No RPC"); export default definePlugin({ name: "NoRPC", description: "Disables Discord's RPC server.", diff --git a/src/plugins/quickReply.ts b/src/plugins/quickReply.ts index d059b3327..b038b6961 100644 --- a/src/plugins/quickReply.ts +++ b/src/plugins/quickReply.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings, migratePluginSettings, Settings } from "@api/settings"; +import { definePluginSettings, Settings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -29,7 +29,6 @@ const isMac = navigator.platform.includes("Mac"); // bruh let replyIdx = -1; let editIdx = -1; -migratePluginSettings("QuickReply", "InteractionKeybinds"); const enum MentionOptions { DISABLED, diff --git a/src/plugins/spotifyCrack.ts b/src/plugins/spotifyCrack.ts index 2682ccb46..c4033271d 100644 --- a/src/plugins/spotifyCrack.ts +++ b/src/plugins/spotifyCrack.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { definePluginSettings, migratePluginSettings } from "@api/settings"; +import { definePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -35,7 +35,6 @@ const settings = definePluginSettings({ } }); -migratePluginSettings("SpotifyCrack", "Ify"); export default definePlugin({ name: "SpotifyCrack", description: "Free listen along, no auto-pausing in voice chat, and allows activity to continue playing when idling", diff --git a/src/plugins/spotifyShareCommands.ts b/src/plugins/spotifyShareCommands.ts index ce29b7503..7634e9d57 100644 --- a/src/plugins/spotifyShareCommands.ts +++ b/src/plugins/spotifyShareCommands.ts @@ -17,7 +17,6 @@ */ import { ApplicationCommandInputType, sendBotMessage } from "@api/Commands"; -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -74,7 +73,6 @@ function sendMessage(channelId, message) { }); } -migratePluginSettings("SpotifyShareCommands", "Sendify"); export default definePlugin({ name: "SpotifyShareCommands", description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)", diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index 6d124a6cd..31543510e 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -import { migratePluginSettings } from "@api/settings"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { ChannelStore, SelectedChannelStore } from "@webpack/common"; @@ -26,7 +25,6 @@ const timers = {} as Record; -migratePluginSettings("VoiceChatDoubleClick", "vcDoubleClick"); export default definePlugin({ name: "VoiceChatDoubleClick", description: "Join voice chats via double click instead of single click", From a35b4171943eb1c7212084bb60c1499646e1a430 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Apr 2023 23:26:12 +0200 Subject: [PATCH 021/102] BetterRoleDot: Fix copying colour --- src/plugins/betterRoleDot.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/betterRoleDot.ts b/src/plugins/betterRoleDot.ts index fc13b7b89..6e026c78e 100644 --- a/src/plugins/betterRoleDot.ts +++ b/src/plugins/betterRoleDot.ts @@ -29,10 +29,10 @@ export default definePlugin({ patches: [ { - find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z", + find: ".dotBorderBase", replacement: { - match: /viewBox:"0 0 20 20"/, - replace: "$&,onClick:()=>$self.copyToClipBoard(e.color),style:{cursor:'pointer'}", + match: /,viewBox:"0 0 20 20"/, + replace: "$&,onClick:()=>$self.copyToClipBoard(arguments[0].color),style:{cursor:'pointer'}", }, }, { From 29c994648b1ea556c3b355063e40acea6444617f Mon Sep 17 00:00:00 2001 From: Kode Date: Sat, 29 Apr 2023 23:49:27 +0100 Subject: [PATCH 022/102] ShowConnections plugin (#923) Co-authored-by: Vendicated --- src/plugins/showConnections/index.tsx | 173 +++++++++++++++++++++++++ src/plugins/showConnections/styles.css | 5 + 2 files changed, 178 insertions(+) create mode 100644 src/plugins/showConnections/index.tsx create mode 100644 src/plugins/showConnections/styles.css diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx new file mode 100644 index 000000000..7c0a46aaa --- /dev/null +++ b/src/plugins/showConnections/index.tsx @@ -0,0 +1,173 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * 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 . +*/ + +import "./styles.css"; + +import { definePluginSettings } from "@api/settings"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import { copyWithToast, LazyComponent } from "@utils/misc"; +import definePlugin, { OptionType } from "@utils/types"; +import { findByCode, findByCodeLazy, findByPropsLazy, findStoreLazy } from "@webpack"; +import { Text, Tooltip } from "@webpack/common"; +import { User } from "discord-types/general"; + +const Section = LazyComponent(() => findByCode("().lastSection")); +const UserProfileStore = findStoreLazy("UserProfileStore"); +const ThemeStore = findStoreLazy("ThemeStore"); +const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); +const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"'); + +const enum Spacing { + COMPACT, + COZY, + ROOMY +} +const getSpacingPx = (spacing: Spacing | undefined) => (spacing ?? Spacing.COMPACT) * 2 + 4; + +const settings = definePluginSettings({ + iconSize: { + type: OptionType.NUMBER, + description: "Icon size (px)", + default: 32 + }, + iconSpacing: { + type: OptionType.SELECT, + description: "Icon margin", + default: Spacing.COZY, + options: [ + { label: "Compact", value: Spacing.COMPACT }, + { label: "Cozy", value: Spacing.COZY }, // US Spelling :/ + { label: "Roomy", value: Spacing.ROOMY } + ] + } +}); + +interface Connection { + type: string; + id: string; + name: string; + verified: boolean; +} + +interface ConnectionPlatform { + getPlatformUserUrl(connection: Connection): string; + icon: { lightSVG: string, darkSVG: string; }; +} + +const profilePopoutComponent = ErrorBoundary.wrap(e => + +); + +const profilePanelComponent = ErrorBoundary.wrap(e => + +); + +function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) { + const profile = UserProfileStore.getUserProfile(id); + if (!profile) + return null; + + const connections: Connection[] = profile.connectedAccounts; + if (!connections?.length) + return null; + + return ( +
+ + Connections + + {connections.map(connection => )} +
+ ); +} + +function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { + const platform = platforms.get(connection.type); + const url = platform.getPlatformUserUrl?.(connection); + + const img = ( + + ); + + return ( + + {tooltipProps => + url + ? + {img} + + : + + } + + ); +} + +export default definePlugin({ + name: "ShowConnections", + description: "Show connected accounts in user popouts", + authors: [Devs.TheKodeToad], + patches: [ + { + find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", + replacement: { + match: /,theme:\i\}\)(?=,.{0,100}setNote:)/, + replace: "$&,$self.profilePopoutComponent(arguments[0])" + } + }, + { + find: "\"Profile Panel: user cannot be undefined\"", + replacement: { + // createElement(Divider, {}), createElement(NoteComponent) + match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:/, + replace: "$self.profilePanelComponent(arguments[0]),$&" + } + } + ], + settings, + profilePopoutComponent, + profilePanelComponent +}); diff --git a/src/plugins/showConnections/styles.css b/src/plugins/showConnections/styles.css new file mode 100644 index 000000000..71a835b9a --- /dev/null +++ b/src/plugins/showConnections/styles.css @@ -0,0 +1,5 @@ +.vc-user-connection { + all: unset; + display: inline-block; + cursor: pointer; +} From 5b485806eaf5cdf893746ff85f495aad2427b986 Mon Sep 17 00:00:00 2001 From: LordElias <55048695+LordEliasTM@users.noreply.github.com> Date: Sun, 30 Apr 2023 00:52:20 +0200 Subject: [PATCH 023/102] Plugin Settings: Better margin for plugin settings modal (#1008) --- src/components/PluginSettings/PluginModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index 6240c17ff..3c5fc78f2 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -150,7 +150,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti ); }); - return {options}; + return {options}; } } @@ -180,7 +180,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti {plugin.name} - + About {plugin.name} {plugin.description} From 043381963bf7c3899c3224c05c18ff8542773a3e Mon Sep 17 00:00:00 2001 From: Manti <67705577+mantikafasi@users.noreply.github.com> Date: Sun, 30 Apr 2023 01:53:37 +0300 Subject: [PATCH 024/102] ReviewDB: make warning review disableable; add timestamps (#948) --- src/plugins/reviewDB/Utils/ReviewDBAPI.ts | 18 ++++++++---- src/plugins/reviewDB/Utils/Utils.tsx | 9 ++---- .../reviewDB/components/ReviewComponent.tsx | 15 ++++++++-- .../reviewDB/components/ReviewsView.tsx | 19 +++++++++++-- src/plugins/reviewDB/entities/Review.ts | 1 + src/plugins/reviewDB/entities/User.ts | 28 +++++++++++++++++++ src/plugins/reviewDB/index.tsx | 26 ++++++++++++----- 7 files changed, 93 insertions(+), 23 deletions(-) create mode 100644 src/plugins/reviewDB/entities/User.ts diff --git a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts index 74415bbec..b9f48d28a 100644 --- a/src/plugins/reviewDB/Utils/ReviewDBAPI.ts +++ b/src/plugins/reviewDB/Utils/ReviewDBAPI.ts @@ -19,6 +19,7 @@ import { Settings } from "@api/settings"; import { Review } from "../entities/Review"; +import { ReviewDBUser } from "../entities/User"; import { authorize, showToast } from "./Utils"; const API_URL = "https://manti.vendicated.dev"; @@ -32,8 +33,12 @@ interface Response { updated: boolean; } +const WarningFlag = 0b00000010; + export async function getReviews(id: string): Promise { - const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews`); + var flags = 0; + if (!Settings.plugins.ReviewDB.showWarning) flags |= WarningFlag; + const req = await fetch(API_URL + `/api/reviewdb/users/${id}/reviews?flags=${flags}`); const res = (req.status === 200) ? await req.json() as Response : { success: false, message: "An Error occured while fetching reviews. Please try again later.", reviews: [], updated: false }; if (!res.success) { @@ -43,6 +48,7 @@ export async function getReviews(id: string): Promise { id: 0, comment: "An Error occured while fetching reviews. Please try again later.", star: 0, + timestamp: 0, sender: { id: 0, username: "Error", @@ -108,8 +114,10 @@ export async function reportReview(id: number) { showToast(await res.message); } -export function getLastReviewID(id: string): Promise { - return fetch(API_URL + "/getLastReviewID?discordid=" + id) - .then(r => r.text()) - .then(Number); +export function getCurrentUserInfo(token: string): Promise { + return fetch(API_URL + "/api/reviewdb/users", { + body: JSON.stringify({ token }), + method: "POST", + }) + .then(r => r.json()); } diff --git a/src/plugins/reviewDB/Utils/Utils.tsx b/src/plugins/reviewDB/Utils/Utils.tsx index b3cb6cd89..7fb907b3f 100644 --- a/src/plugins/reviewDB/Utils/Utils.tsx +++ b/src/plugins/reviewDB/Utils/Utils.tsx @@ -17,13 +17,13 @@ */ import { Settings } from "@api/settings"; -import { Devs } from "@utils/constants"; import Logger from "@utils/Logger"; import { openModal } from "@utils/modal"; import { findByProps } from "@webpack"; import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common"; import { Review } from "../entities/Review"; +import { UserType } from "../entities/User"; export async function openUserProfileModal(userId: string) { await UserUtils.fetchUser(userId); @@ -86,10 +86,5 @@ export function showToast(text: string) { export const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); export function canDeleteReview(review: Review, userId: string) { - if (review.sender.discordID === userId) return true; - - const myId = BigInt(userId); - return myId === Devs.mantikafasi.id || - myId === Devs.Ven.id || - myId === Devs.rushii.id; + if (review.sender.discordID === userId || Settings.plugins.ReviewDB.userType === UserType.Admin) return true; } diff --git a/src/plugins/reviewDB/components/ReviewComponent.tsx b/src/plugins/reviewDB/components/ReviewComponent.tsx index 7eadeff8a..76497d19a 100644 --- a/src/plugins/reviewDB/components/ReviewComponent.tsx +++ b/src/plugins/reviewDB/components/ReviewComponent.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ +import { Settings } from "@api/settings"; import { classes, LazyComponent } from "@utils/misc"; import { filters, findBulk } from "@webpack"; -import { Alerts, UserStore } from "@webpack/common"; +import { Alerts, moment, Timestamp, UserStore } from "@webpack/common"; import { Review } from "../entities/Review"; import { deleteReview, reportReview } from "../Utils/ReviewDBAPI"; @@ -32,7 +33,7 @@ export default LazyComponent(() => { const [ { cozyMessage, buttons, message, groupStart }, { container, isHeader }, - { avatar, clickable, username, messageContent, wrapper, cozy }, + { avatar, clickable, username, messageContent, wrapper, cozy, timestampInline, timestamp }, { contents }, buttonClasses, { defaultColor } @@ -102,6 +103,16 @@ export default LazyComponent(() => { {review.sender.username} {review.sender.badges.map(badge => )} + + { + !Settings.plugins.ReviewDB.hideTimestamps && ( + + ) + } +

. */ +import { Settings } from "@api/settings"; import { classes, useAwaiter } from "@utils/misc"; import { findLazy } from "@webpack"; import { Forms, React, Text, UserStore } from "@webpack/common"; import type { KeyboardEvent } from "react"; import { addReview, getReviews } from "../Utils/ReviewDBAPI"; -import { showToast } from "../Utils/Utils"; +import { authorize, showToast } from "../Utils/Utils"; import ReviewComponent from "./ReviewComponent"; const Classes = findLazy(m => typeof m.textarea === "string"); export default function ReviewsView({ userId }: { userId: string; }) { + const { token } = Settings.plugins.ReviewDB; const [refetchCount, setRefetchCount] = React.useState(0); const [reviews, _, isLoading] = useAwaiter(() => getReviews(userId), { fallbackValue: [], @@ -83,8 +85,21 @@ export default function ReviewsView({ userId }: { userId: string; }) {