From 43501bad07632b586950b5bddfb81e5823786ce9 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 24 Jan 2025 00:33:10 +0100 Subject: [PATCH 01/35] bump to v1.11.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index abb11ee5c..a7dca5793 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.11.0", + "version": "1.11.2", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 78c2f0d61a475d6a714918a54fc4f4c30720729f Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 24 Jan 2025 00:43:33 -0300 Subject: [PATCH 02/35] Fix calling option onChange listeners for legacy settings --- src/plugins/ignoreActivities/index.tsx | 2 -- src/plugins/index.ts | 15 +++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 08e146ab9..ee09ef432 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -73,8 +73,6 @@ function handleActivityToggle(e: React.MouseEvent const ignoredActivityIndex = settings.store.ignoredActivities.findIndex(act => act.id === activity.id); if (ignoredActivityIndex === -1) settings.store.ignoredActivities.push(activity); else settings.store.ignoredActivities.splice(ignoredActivityIndex, 1); - - recalculateActivities(); } function recalculateActivities() { diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 545169b1f..50523e98f 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -141,14 +141,21 @@ for (const p of neededApiPlugins) { for (const p of pluginsValues) { if (p.settings) { - p.settings.pluginName = p.name; p.options ??= {}; - for (const [name, def] of Object.entries(p.settings.def)) { + + p.settings.pluginName = p.name; + for (const name in p.settings.def) { + const def = p.settings.def[name]; const checks = p.settings.checks?.[name]; p.options[name] = { ...def, ...checks }; + } + } - if (def.onChange != null) { - SettingsStore.addChangeListener(`plugins.${p.name}.${name}`, def.onChange); + if (p.options) { + for (const name in p.options) { + const opt = p.options[name]; + if (opt.onChange != null) { + SettingsStore.addChangeListener(`plugins.${p.name}.${name}`, opt.onChange); } } } From e45b867ff0309aca02e6165230d8706c00bb41d9 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 24 Jan 2025 23:42:05 +0000 Subject: [PATCH 03/35] ServerInfo: Add Ignored Users tab (#3127) --- src/plugins/serverInfo/GuildInfoModal.tsx | 23 ++++++++++++++++++++--- src/webpack/common/stores.ts | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/plugins/serverInfo/GuildInfoModal.tsx b/src/plugins/serverInfo/GuildInfoModal.tsx index be77ca1c7..14b7e1dc8 100644 --- a/src/plugins/serverInfo/GuildInfoModal.tsx +++ b/src/plugins/serverInfo/GuildInfoModal.tsx @@ -31,7 +31,8 @@ export function openGuildInfoModal(guild: Guild) { const enum Tabs { ServerInfo, Friends, - BlockedUsers + BlockedUsers, + IgnoredUsers } interface GuildProps { @@ -44,7 +45,8 @@ interface RelationshipProps extends GuildProps { const fetched = { friends: false, - blocked: false + blocked: false, + ignored: false }; function renderTimestamp(timestamp: number) { @@ -56,10 +58,12 @@ function renderTimestamp(timestamp: number) { function GuildInfoModal({ guild }: GuildProps) { const [friendCount, setFriendCount] = useState(); const [blockedCount, setBlockedCount] = useState(); + const [ignoredCount, setIgnoredCount] = useState(); useEffect(() => { fetched.friends = false; fetched.blocked = false; + fetched.ignored = false; }, []); const [currentTab, setCurrentTab] = useState(Tabs.ServerInfo); @@ -132,12 +136,19 @@ function GuildInfoModal({ guild }: GuildProps) { > Blocked Users{blockedCount !== undefined ? ` (${blockedCount})` : ""} + + Ignored Users{ignoredCount !== undefined ? ` (${ignoredCount})` : ""} +
{currentTab === Tabs.ServerInfo && } {currentTab === Tabs.Friends && } {currentTab === Tabs.BlockedUsers && } + {currentTab === Tabs.IgnoredUsers && }
); @@ -211,7 +222,13 @@ function BlockedUsersTab({ guild, setCount }: RelationshipProps) { return UserList("blocked", guild, blockedIds, setCount); } -function UserList(type: "friends" | "blocked", guild: Guild, ids: string[], setCount: (count: number) => void) { +function IgnoredUserTab({ guild, setCount }: RelationshipProps) { + const ignoredIds = Object.keys(RelationshipStore.getRelationships()).filter(id => RelationshipStore.isIgnored(id)); + return UserList("ignored", guild, ignoredIds, setCount); +} + + +function UserList(type: "friends" | "blocked" | "ignored", guild: Guild, ids: string[], setCount: (count: number) => void) { const missing = [] as string[]; const members = [] as string[]; diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index 8579f8b92..ff668425f 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -50,6 +50,7 @@ export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore; export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & { /** Get the date (as a string) that the relationship was created */ getSince(userId: string): string; + isIgnored(userId: string): boolean; }; export let EmojiStore: t.EmojiStore; From 7ee70e831a00b6ca48f73667e6e8f220415abf9e Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 24 Jan 2025 23:46:47 +0000 Subject: [PATCH 04/35] MessageLogger: Make collapseDeleted require a restart (#2923) --- src/plugins/messageLogger/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 333de9a4e..9b6b864a6 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -211,7 +211,8 @@ export default definePlugin({ collapseDeleted: { type: OptionType.BOOLEAN, description: "Whether to collapse deleted messages, similar to blocked messages", - default: false + default: false, + restartNeeded: true, }, logEdits: { type: OptionType.BOOLEAN, From 79cbfe96c8a444a51644d366ec6ecae00ad6a735 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 24 Jan 2025 23:56:39 +0000 Subject: [PATCH 05/35] HideAttachments, UnsupressEmbeds: Work with forwarded messages (#2928) --- src/plugins/hideAttachments/index.tsx | 8 +++++++- src/plugins/unsuppressEmbeds/index.tsx | 10 ++++++++-- src/webpack/common/types/utils.d.ts | 6 +++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/plugins/hideAttachments/index.tsx b/src/plugins/hideAttachments/index.tsx index e122e3cb5..39935d038 100644 --- a/src/plugins/hideAttachments/index.tsx +++ b/src/plugins/hideAttachments/index.tsx @@ -21,6 +21,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { ChannelStore } from "@webpack/common"; +import { MessageSnapshot } from "@webpack/types"; let style: HTMLStyleElement; @@ -39,7 +40,12 @@ export default definePlugin({ authors: [Devs.Ven], renderMessagePopoverButton(msg) { - if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length) return null; + // @ts-ignore - discord-types lags behind discord. + const hasAttachmentsInShapshots = msg.messageSnapshots.some( + (snapshot: MessageSnapshot) => snapshot?.message.attachments.length + ); + + if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInShapshots) return null; const isHidden = hiddenMessages.has(msg.id); diff --git a/src/plugins/unsuppressEmbeds/index.tsx b/src/plugins/unsuppressEmbeds/index.tsx index 16debf711..2df64b72e 100644 --- a/src/plugins/unsuppressEmbeds/index.tsx +++ b/src/plugins/unsuppressEmbeds/index.tsx @@ -21,12 +21,18 @@ import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common"; +import { MessageSnapshot } from "@webpack/types"; + const EMBED_SUPPRESSED = 1 << 2; -const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, embeds, flags, id: messageId } }) => { +const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => { const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0; - if (!isEmbedSuppressed && !embeds.length) return; + const hasEmbedsInSnapshots = messageSnapshots.some( + (snapshot: MessageSnapshot) => snapshot?.message.embeds.length + ); + + if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return; const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS); if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return; diff --git a/src/webpack/common/types/utils.d.ts b/src/webpack/common/types/utils.d.ts index de1ce1829..cfea5d760 100644 --- a/src/webpack/common/types/utils.d.ts +++ b/src/webpack/common/types/utils.d.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Channel, Guild, GuildMember, User } from "discord-types/general"; +import { Channel, Guild, GuildMember, Message, User } from "discord-types/general"; import type { ReactNode } from "react"; import { LiteralUnion } from "type-fest"; @@ -133,6 +133,10 @@ export type Permissions = "CREATE_INSTANT_INVITE" export type PermissionsBits = Record; +export interface MessageSnapshot { + message: Message; +} + export interface Locale { name: string; value: string; From 4036fbab92d5534417dedd6a5e8e7ecdc4e41dc6 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:01:12 -0500 Subject: [PATCH 06/35] ConsoleJanitor: Remove old patch and add getLastCrash (#3151) --- src/plugins/consoleJanitor/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index d251ff740..aa28e8856 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -95,10 +95,9 @@ export default definePlugin({ } }, { - find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");', - all: true, + find: '"AppCrashedFatalReport: getLastCrash not supported."', replacement: { - match: /console\.warn\("\[DEPRECATED\] Please use `subscribeWithSelector` middleware"\);/, + match: /console\.log\("AppCrashedFatalReport: getLastCrash not supported\."\);/, replace: "" } }, From aac5242dc8e4cbac6a7fc99a084707b973eabfbc Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:11:26 -0500 Subject: [PATCH 07/35] ImageZoom: Fix incorrectly adding context menu in some places (#3150) --- src/plugins/imageZoom/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 06e1dcd55..8c50ae9f4 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -81,7 +81,12 @@ export const settings = definePluginSettings({ }); -const imageContextMenuPatch: NavContextMenuPatchCallback = children => { +const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => { + // Discord re-uses the image context menu for links to for the copy and open buttons + if ("href" in props) return; + // emojis in user statuses + if (props.target?.classList?.contains("emoji")) return; + const { square, nearestNeighbour } = settings.use(["square", "nearestNeighbour"]); children.push( From 87cb1fd930811b28784b70a5f8f7a58e5aaf6282 Mon Sep 17 00:00:00 2001 From: Suffocate <70031311+lolsuffocate@users.noreply.github.com> Date: Sun, 26 Jan 2025 15:32:34 +0000 Subject: [PATCH 08/35] Fix top level settings notifying global listeners (#3166) --- src/shared/SettingsStore.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/SettingsStore.ts b/src/shared/SettingsStore.ts index 25dd05b19..0b6aa25b6 100644 --- a/src/shared/SettingsStore.ts +++ b/src/shared/SettingsStore.ts @@ -167,6 +167,8 @@ export class SettingsStore { this.globalListeners.forEach(cb => cb(root, settingPathStr)); this.pathListeners.get(settingPathStr)?.forEach(cb => cb(settingValue)); + } else { + this.globalListeners.forEach(cb => cb(root, pathStr)); } this.pathListeners.get(pathStr)?.forEach(cb => cb(value)); From cf28c65374ea9ac2c71358640b9d979221360b40 Mon Sep 17 00:00:00 2001 From: Grzesiek11 Date: Mon, 27 Jan 2025 03:34:00 +0100 Subject: [PATCH 09/35] Add IrcColors plugin (#2048) Co-authored-by: V --- src/plugins/ircColors/README.md | 17 ++++++ src/plugins/ircColors/index.ts | 94 +++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 src/plugins/ircColors/README.md create mode 100644 src/plugins/ircColors/index.ts diff --git a/src/plugins/ircColors/README.md b/src/plugins/ircColors/README.md new file mode 100644 index 000000000..9d9c7634b --- /dev/null +++ b/src/plugins/ircColors/README.md @@ -0,0 +1,17 @@ +# IrcColors + +Makes username colors in chat unique, like in IRC clients + +![Chat with IrcColors and Compact++ enabled](https://github.com/Vendicated/Vencord/assets/33988779/88e05c0b-a60a-4d10-949e-8b46e1d7226c) + +Improves chat readability by assigning every user an unique nickname color, +making distinguishing between different users easier. Inspired by the feature +in many IRC clients, such as HexChat or WeeChat. + +Keep in mind this overrides role colors in chat, so if you wish to know +someone's role color without checking their profile, enable the role dot: go to +**User Settings**, **Accessibility** and switch **Role Colors** to **Show role +colors next to names**. + +Created for use with the [Compact++](https://gitlab.com/Grzesiek11/compactplusplus-discord-theme) +theme. diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts new file mode 100644 index 000000000..d5cc5f3e4 --- /dev/null +++ b/src/plugins/ircColors/index.ts @@ -0,0 +1,94 @@ +/* + * 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 { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +// Compute a 64-bit FNV-1a hash of the passed data +function hash(id: bigint) { + const fnvPrime = 1099511628211n; + const offsetBasis = 14695981039346656037n; + + let result = offsetBasis; + for (let i = 7n; i >= 0n; i--) { + result ^= (id >> (8n * i)) & 0xffn; + result = (result * fnvPrime) % 2n ** 32n; + } + + return result; +} + +// Calculate a CSS color string based on the user ID +function calculateNameColorForUser(id: bigint) { + const idHash = hash(id); + + return `hsl(${idHash % 360n}, 100%, ${settings.store.lightness}%)`; +} + +const settings = definePluginSettings({ + lightness: { + description: "Lightness, in %. Change if the colors are too light or too dark. Reopen the chat to apply.", + type: OptionType.NUMBER, + default: 70, + }, + memberListColors: { + description: "Replace role colors in the member list", + restartNeeded: true, + type: OptionType.BOOLEAN, + default: true, + }, +}); + +export default definePlugin({ + name: "IrcColors", + description: "Makes username colors in chat unique, like in IRC clients", + authors: [Devs.Grzesiek11], + patches: [ + { + find: '="SYSTEM_TAG"', + replacement: { + match: /(?<=className:\i\.username,style:.{0,50}:void 0,)/, + replace: "style:{color:$self.calculateNameColorForMessageContext(arguments[0])},", + }, + }, + { + find: ".NameWithRole,{roleName:", + replacement: { + match: /(?<=color:)null!=.{0,50}?(?=,)/, + replace: "$self.calculateNameColorForListContext(arguments[0])", + }, + predicate: () => settings.store.memberListColors, + }, + ], + settings, + calculateNameColorForMessageContext(context: any) { + const id = context?.message?.author?.id; + if (id == null) { + return null; + } + return calculateNameColorForUser(BigInt(id)); + }, + calculateNameColorForListContext(context: any) { + const id = context?.user?.id; + if (id == null) { + return null; + } + return calculateNameColorForUser(BigInt(id)); + }, +}); From f29662c5b315a3579e14bcfb062d96bf047b7d39 Mon Sep 17 00:00:00 2001 From: vishnyanetchereshnya <151846235+vishnyanetchereshnya@users.noreply.github.com> Date: Mon, 27 Jan 2025 06:12:26 +0300 Subject: [PATCH 10/35] feat(ViewRaw): add View Role option (#3083) Co-authored-by: v --- src/plugins/betterRoleContext/index.tsx | 30 ++++++++++++------------- src/plugins/viewRaw/index.tsx | 27 ++++++++++++++++++---- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/plugins/betterRoleContext/index.tsx b/src/plugins/betterRoleContext/index.tsx index 1029c07e2..afef63908 100644 --- a/src/plugins/betterRoleContext/index.tsx +++ b/src/plugins/betterRoleContext/index.tsx @@ -83,7 +83,7 @@ export default definePlugin({ if (!role) return; if (role.colorString) { - children.push( + children.unshift( { + await GuildSettingsActions.open(guild.id, "ROLES"); + GuildSettingsActions.selectRole(id); + }} + icon={PencilIcon} + /> + ); + } + if (role.icon) { children.push( { - await GuildSettingsActions.open(guild.id, "ROLES"); - GuildSettingsActions.selectRole(id); - }} - icon={PencilIcon} - /> - ); - } } } }); diff --git a/src/plugins/viewRaw/index.tsx b/src/plugins/viewRaw/index.tsx index b45919a21..ddcbd3b46 100644 --- a/src/plugins/viewRaw/index.tsx +++ b/src/plugins/viewRaw/index.tsx @@ -22,12 +22,12 @@ import { CodeBlock } from "@components/CodeBlock"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Devs } from "@utils/constants"; -import { getIntlMessage } from "@utils/discord"; +import { getCurrentGuild, getIntlMessage } from "@utils/discord"; import { Margins } from "@utils/margins"; import { copyWithToast } from "@utils/misc"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ChannelStore, Forms, Menu, Text } from "@webpack/common"; +import { Button, ChannelStore, Forms, GuildStore, Menu, Text } from "@webpack/common"; import { Message } from "discord-types/general"; @@ -118,7 +118,7 @@ const settings = definePluginSettings({ } }); -function MakeContextCallback(name: "Guild" | "User" | "Channel"): NavContextMenuPatchCallback { +function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel"): NavContextMenuPatchCallback { return (children, props) => { const value = props[name.toLowerCase()]; if (!value) return; @@ -144,6 +144,23 @@ function MakeContextCallback(name: "Guild" | "User" | "Channel"): NavContextMenu }; } +const devContextCallback: NavContextMenuPatchCallback = (children, { id }: { id: string; }) => { + const guild = getCurrentGuild(); + if (!guild) return; + + const role = GuildStore.getRole(guild.id, id); + if (!role) return; + + children.push( + openViewRawModal(JSON.stringify(role, null, 4), "Role")} + icon={CopyIcon} + /> + ); +}; + export default definePlugin({ name: "ViewRaw", description: "Copy and view the raw content/data of any message, channel or guild", @@ -152,10 +169,12 @@ export default definePlugin({ contextMenus: { "guild-context": MakeContextCallback("Guild"), + "guild-settings-role-context": MakeContextCallback("Role"), "channel-context": MakeContextCallback("Channel"), "thread-context": MakeContextCallback("Channel"), "gdm-context": MakeContextCallback("Channel"), - "user-context": MakeContextCallback("User") + "user-context": MakeContextCallback("User"), + "dev-context": devContextCallback }, renderMessagePopoverButton(msg) { From 3350922c09ea1e9ad0f4f4f40320e7e80b7ce940 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 27 Jan 2025 04:25:37 +0100 Subject: [PATCH 11/35] LastFmRPC: Add option to hide if there is another presence closes #2866 Co-Authored-By: 54ac --- src/plugins/lastfm/index.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/lastfm/index.tsx b/src/plugins/lastfm/index.tsx index 02fd694f8..77fa27841 100644 --- a/src/plugins/lastfm/index.tsx +++ b/src/plugins/lastfm/index.tsx @@ -86,7 +86,7 @@ const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f"; const logger = new Logger("LastFMRichPresence"); -const presenceStore = findByPropsLazy("getLocalPresence"); +const PresenceStore = findByPropsLazy("getLocalPresence"); async function getApplicationAsset(key: string): Promise { return (await ApplicationAssetUtils.fetchAssetIds(applicationId, [key]))[0]; @@ -124,6 +124,11 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, default: true, }, + hideWithActivity: { + description: "Hide Last.fm presence if you have any other presence", + type: OptionType.BOOLEAN, + default: false, + }, statusName: { description: "custom status text", type: OptionType.STRING, @@ -274,12 +279,16 @@ export default definePlugin({ }, async getActivity(): Promise { + if (settings.store.hideWithActivity) { + if (PresenceStore.getActivities().some(a => a.application_id !== applicationId)) { + return null; + } + } + if (settings.store.hideWithSpotify) { - for (const activity of presenceStore.getActivities()) { - if (activity.type === ActivityType.LISTENING && activity.application_id !== applicationId) { - // there is already music status because of Spotify or richerCider (probably more) - return null; - } + if (PresenceStore.getActivities().some(a => a.type === ActivityType.LISTENING && a.application_id !== applicationId)) { + // there is already music status because of Spotify or richerCider (probably more) + return null; } } From c4f8221f75157c6f23f4aaba22b17e06a785917d Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:30:11 -0300 Subject: [PATCH 12/35] IrcColors: Make lightness apply without restart --- src/plugins/ircColors/index.ts | 53 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts index d5cc5f3e4..208b327e9 100644 --- a/src/plugins/ircColors/index.ts +++ b/src/plugins/ircColors/index.ts @@ -17,33 +17,22 @@ */ import { definePluginSettings } from "@api/Settings"; +import { hash as h64 } from "@intrnl/xxhash64"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; - -// Compute a 64-bit FNV-1a hash of the passed data -function hash(id: bigint) { - const fnvPrime = 1099511628211n; - const offsetBasis = 14695981039346656037n; - - let result = offsetBasis; - for (let i = 7n; i >= 0n; i--) { - result ^= (id >> (8n * i)) & 0xffn; - result = (result * fnvPrime) % 2n ** 32n; - } - - return result; -} +import { useMemo } from "@webpack/common"; // Calculate a CSS color string based on the user ID -function calculateNameColorForUser(id: bigint) { - const idHash = hash(id); +function calculateNameColorForUser(id: string) { + const { lightness } = settings.use(["lightness"]); + const idHash = useMemo(() => h64(id), [id]); - return `hsl(${idHash % 360n}, 100%, ${settings.store.lightness}%)`; + return `hsl(${idHash % 360n}, 100%, ${lightness}%)`; } const settings = definePluginSettings({ lightness: { - description: "Lightness, in %. Change if the colors are too light or too dark. Reopen the chat to apply.", + description: "Lightness, in %. Change if the colors are too light or too dark", type: OptionType.NUMBER, default: 70, }, @@ -51,44 +40,46 @@ const settings = definePluginSettings({ description: "Replace role colors in the member list", restartNeeded: true, type: OptionType.BOOLEAN, - default: true, - }, + default: true + } }); export default definePlugin({ name: "IrcColors", description: "Makes username colors in chat unique, like in IRC clients", authors: [Devs.Grzesiek11], + settings, + patches: [ { find: '="SYSTEM_TAG"', replacement: { match: /(?<=className:\i\.username,style:.{0,50}:void 0,)/, - replace: "style:{color:$self.calculateNameColorForMessageContext(arguments[0])},", - }, + replace: "style:{color:$self.calculateNameColorForMessageContext(arguments[0])}," + } }, { - find: ".NameWithRole,{roleName:", + find: "#{intl::GUILD_OWNER}),children:", replacement: { - match: /(?<=color:)null!=.{0,50}?(?=,)/, - replace: "$self.calculateNameColorForListContext(arguments[0])", + match: /(?<=\.MEMBER_LIST}\),\[\]\),)(.+?color:)null!=.{0,50}?(?=,)/, + replace: (_, rest) => `ircColor=$self.calculateNameColorForListContext(arguments[0]),${rest}ircColor` }, - predicate: () => settings.store.memberListColors, - }, + predicate: () => settings.store.memberListColors + } ], - settings, + calculateNameColorForMessageContext(context: any) { const id = context?.message?.author?.id; if (id == null) { return null; } - return calculateNameColorForUser(BigInt(id)); + return calculateNameColorForUser(id); }, calculateNameColorForListContext(context: any) { const id = context?.user?.id; if (id == null) { return null; } - return calculateNameColorForUser(BigInt(id)); - }, + return calculateNameColorForUser(id); + } }); From ceba9776c4be12288dbf618b5bc36e0e41d3f70f Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 27 Jan 2025 20:44:54 +0100 Subject: [PATCH 13/35] Delete MoreUserTags for now because it's unstable This plugin is written in a way that makes it susceptible to crashes. This is not the first time it has caused crashes and will not be the last. A rewrite is necessary to make it more robust --- src/plugins/moreUserTags/index.tsx | 372 ----------------------------- 1 file changed, 372 deletions(-) delete mode 100644 src/plugins/moreUserTags/index.tsx diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx deleted file mode 100644 index 8029b4833..000000000 --- a/src/plugins/moreUserTags/index.tsx +++ /dev/null @@ -1,372 +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 { definePluginSettings } from "@api/Settings"; -import { Flex } from "@components/Flex"; -import { Devs } from "@utils/constants"; -import { getIntlMessage } from "@utils/discord"; -import { Margins } from "@utils/margins"; -import definePlugin, { OptionType } from "@utils/types"; -import { findByCodeLazy, findLazy } from "@webpack"; -import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip } from "@webpack/common"; -import type { Permissions, RC } from "@webpack/types"; -import type { Channel, Guild, Message, User } from "discord-types/general"; - -interface Tag { - // name used for identifying, must be alphanumeric + underscores - name: string; - // name shown on the tag itself, can be anything probably; automatically uppercase'd - displayName: string; - description: string; - permissions?: Permissions[]; - condition?(message: Message | null, user: User, channel: Channel): boolean; -} - -interface TagSetting { - text: string; - showInChat: boolean; - showInNotChat: boolean; -} -interface TagSettings { - WEBHOOK: TagSetting, - OWNER: TagSetting, - ADMINISTRATOR: TagSetting, - MODERATOR_STAFF: TagSetting, - MODERATOR: TagSetting, - VOICE_MODERATOR: TagSetting, - TRIAL_MODERATOR: TagSetting, - [k: string]: TagSetting; -} - -// PermissionStore.computePermissions will not work here since it only gets permissions for the current user -const computePermissions: (options: { - user?: { id: string; } | string | null; - context?: Guild | Channel | null; - overwrites?: Channel["permissionOverwrites"] | null; - checkElevated?: boolean /* = true */; - excludeGuildPermissions?: boolean /* = false */; -}) => bigint = findByCodeLazy(".getCurrentUser()", ".computeLurkerPermissionsAllowList()"); - -const Tag = findLazy(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record; }; - -const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot(); - -const tags: Tag[] = [ - { - name: "WEBHOOK", - displayName: "Webhook", - description: "Messages sent by webhooks", - condition: isWebhook - }, { - name: "OWNER", - displayName: "Owner", - description: "Owns the server", - condition: (_, user, channel) => GuildStore.getGuild(channel?.guild_id)?.ownerId === user.id - }, { - name: "ADMINISTRATOR", - displayName: "Admin", - description: "Has the administrator permission", - permissions: ["ADMINISTRATOR"] - }, { - name: "MODERATOR_STAFF", - displayName: "Staff", - description: "Can manage the server, channels or roles", - permissions: ["MANAGE_GUILD", "MANAGE_CHANNELS", "MANAGE_ROLES"] - }, { - name: "MODERATOR", - displayName: "Mod", - description: "Can manage messages or kick/ban people", - permissions: ["MANAGE_MESSAGES", "KICK_MEMBERS", "BAN_MEMBERS"] - }, { - name: "VOICE_MODERATOR", - displayName: "VC Mod", - description: "Can manage voice chats", - permissions: ["MOVE_MEMBERS", "MUTE_MEMBERS", "DEAFEN_MEMBERS"] - }, { - name: "CHAT_MODERATOR", - displayName: "Chat Mod", - description: "Can timeout people", - permissions: ["MODERATE_MEMBERS"] - } -]; -const defaultSettings = Object.fromEntries( - tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }]) -) as TagSettings; - -function SettingsComponent() { - const tagSettings = settings.store.tagSettings ??= defaultSettings; - - return ( - - {tags.map(t => ( - - - - {({ onMouseEnter, onMouseLeave }) => ( -
- {t.displayName} Tag -
- )} -
-
- - tagSettings[t.name].text = v} - className={Margins.bottom16} - /> - - tagSettings[t.name].showInChat = v} - hideBorder - > - Show in messages - - - tagSettings[t.name].showInNotChat = v} - hideBorder - > - Show in member list and profiles - -
- ))} -
- ); -} - -const settings = definePluginSettings({ - dontShowForBots: { - description: "Don't show extra tags for bots (excluding webhooks)", - type: OptionType.BOOLEAN - }, - dontShowBotTag: { - description: "Only show extra tags for bots / Hide [BOT] text", - type: OptionType.BOOLEAN - }, - tagSettings: { - type: OptionType.COMPONENT, - component: SettingsComponent, - description: "fill me" - } -}); - -export default definePlugin({ - name: "MoreUserTags", - description: "Adds tags for webhooks and moderative roles (owner, admin, etc.)", - authors: [Devs.Cyn, Devs.TheSun, Devs.RyanCaoDev, Devs.LordElias, Devs.AutumnVN], - settings, - patches: [ - // add tags to the tag list - { - find: ".ORIGINAL_POSTER=", - replacement: { - match: /(?=(\i)\[\i\.BOT)/, - replace: "$self.genTagTypes($1);" - } - }, - { - find: "#{intl::DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP_OFFICIAL}", - replacement: [ - // make the tag show the right text - { - match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=(.{0,40}#{intl::APP_TAG}\))/, - replace: (_, origSwitch, variant, tags, displayedText, originalText) => - `${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}],${originalText})}` - }, - // show OP tags correctly - { - match: /(\i)=(\i)===\i(?:\.\i)?\.ORIGINAL_POSTER/, - replace: "$1=$self.isOPTag($2)" - }, - // add HTML data attributes (for easier theming) - { - match: /.botText,children:(\i)}\)]/, - replace: "$&,'data-tag':$1.toLowerCase()" - } - ], - }, - // in messages - { - find: ".Types.ORIGINAL_POSTER", - replacement: { - match: /;return\((\(null==\i\?void 0:\i\.isSystemDM\(\).+?.Types.ORIGINAL_POSTER\)),null==(\i)\)/, - replace: ";$1;$2=$self.getTag({...arguments[0],origType:$2,location:'chat'});return $2 == null" - } - }, - // in the member list - { - find: "#{intl::GUILD_OWNER}),children:", - replacement: { - match: /(?\i)=\(null==.{0,100}\.BOT;return null!=(?\i)&&\i\.bot/, - replace: "$ = $self.getTag({user: $, channel: arguments[0].channel, origType: $.bot ? 0 : null, location: 'not-chat' }); return typeof $ === 'number'" - } - }, - // pass channel id down props to be used in profiles - { - find: ".hasAvatarForGuild(null==", - replacement: { - match: /(?=usernameIcon:)/, - replace: "moreTags_channelId:arguments[0].channelId," - } - }, - { - find: "#{intl::USER_PROFILE_PRONOUNS}", - replacement: { - match: /(?=,hideBotTag:!0)/, - replace: ",moreTags_channelId:arguments[0].moreTags_channelId" - } - }, - // in profiles - { - find: ",overrideDiscriminator:", - group: true, - replacement: [ - { - // prevent channel id from getting ghosted - // it's either this or extremely long lookbehind - match: /user:\i,nick:\i,/, - replace: "$&moreTags_channelId," - }, { - match: /,botType:(\i),botVerified:(\i),(?!discriminatorClass:)(?<=user:(\i).+?)/g, - replace: ",botType:$self.getTag({user:$3,channelId:moreTags_channelId,origType:$1,location:'not-chat'}),botVerified:$2," - } - ] - }, - ], - - start() { - settings.store.tagSettings ??= defaultSettings; - - // newly added field might be missing from old users - settings.store.tagSettings.CHAT_MODERATOR ??= { - text: "Chat Mod", - showInChat: true, - showInNotChat: true - }; - }, - - getPermissions(user: User, channel: Channel): string[] { - const guild = GuildStore.getGuild(channel?.guild_id); - if (!guild) return []; - - const permissions = computePermissions({ user, context: guild, overwrites: channel.permissionOverwrites }); - return Object.entries(PermissionsBits) - .map(([perm, permInt]) => - permissions & permInt ? perm : "" - ) - .filter(Boolean); - }, - - genTagTypes(obj) { - let i = 100; - tags.forEach(({ name }) => { - obj[name] = ++i; - obj[i] = name; - obj[`${name}-BOT`] = ++i; - obj[i] = `${name}-BOT`; - obj[`${name}-OP`] = ++i; - obj[i] = `${name}-OP`; - }); - }, - - isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]), - - getTagText(passedTagName: string, originalText: string) { - try { - const [tagName, variant] = passedTagName.split("-"); - if (!passedTagName) return getIntlMessage("APP_TAG"); - const tag = tags.find(({ name }) => tagName === name); - if (!tag) return getIntlMessage("APP_TAG"); - if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return getIntlMessage("APP_TAG"); - - const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName; - switch (variant) { - case "OP": - return `${getIntlMessage("BOT_TAG_FORUM_ORIGINAL_POSTER")} • ${tagText}`; - case "BOT": - return `${getIntlMessage("APP_TAG")} • ${tagText}`; - default: - return tagText; - } - } catch { - return originalText; - } - }, - - getTag({ - message, user, channelId, origType, location, channel - }: { - message?: Message, - user: User & { isClyde(): boolean; }, - channel?: Channel & { isForumPost(): boolean; isMediaPost(): boolean; }, - channelId?: string; - origType?: number; - location: "chat" | "not-chat"; - }): number | null { - if (!user) - return null; - if (location === "chat" && user.id === "1") - return Tag.Types.OFFICIAL; - if (user.isClyde()) - return Tag.Types.AI; - - let type = typeof origType === "number" ? origType : null; - - channel ??= ChannelStore.getChannel(channelId!) as any; - if (!channel) return type; - - const settings = this.settings.store; - const perms = this.getPermissions(user, channel); - - for (const tag of tags) { - if (location === "chat" && !settings.tagSettings[tag.name].showInChat) continue; - if (location === "not-chat" && !settings.tagSettings[tag.name].showInNotChat) continue; - - // If the owner tag is disabled, and the user is the owner of the guild, - // avoid adding other tags because the owner will always match the condition for them - if ( - tag.name !== "OWNER" && - GuildStore.getGuild(channel?.guild_id)?.ownerId === user.id && - (location === "chat" && !settings.tagSettings.OWNER.showInChat) || - (location === "not-chat" && !settings.tagSettings.OWNER.showInNotChat) - ) continue; - - if ( - tag.permissions?.some(perm => perms.includes(perm)) || - (tag.condition?.(message!, user, channel)) - ) { - if ((channel.isForumPost() || channel.isMediaPost()) && channel.ownerId === user.id) - type = Tag.Types[`${tag.name}-OP`]; - else if (user.bot && !isWebhook(message!, user) && !settings.dontShowBotTag) - type = Tag.Types[`${tag.name}-BOT`]; - else - type = Tag.Types[tag.name]; - break; - } - } - return type; - } -}); From ea1e96185b1f1a613a2100c1d7899603790dc862 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 27 Jan 2025 20:54:16 +0100 Subject: [PATCH 14/35] MessageLatency: ErrorBoundary should be noop --- src/plugins/messageLatency/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/messageLatency/index.tsx b/src/plugins/messageLatency/index.tsx index e4e5b8771..1bc18580e 100644 --- a/src/plugins/messageLatency/index.tsx +++ b/src/plugins/messageLatency/index.tsx @@ -162,7 +162,7 @@ export default definePlugin({ } ; - }); + }, { noop: true }); }, Icon({ delta, fill, props }: { From 21ded874a3e94415639ee14b3e8716d894e3456a Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Mon, 27 Jan 2025 20:47:27 -0300 Subject: [PATCH 15/35] Settings API: Add utility to migrate a setting --- src/api/Settings.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/Settings.ts b/src/api/Settings.ts index c99d030d0..8c05d9bb3 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -220,6 +220,19 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) { } } +export function migratePluginSetting(pluginName: string, oldSetting: string, newSetting: string) { + const { plugins } = SettingsStore.plain; + + if ( + plugins[pluginName][newSetting] != null || + plugins[pluginName][oldSetting] == null + ) return; + + plugins[pluginName][newSetting] = plugins[pluginName][oldSetting]; + delete plugins[pluginName][oldSetting]; + SettingsStore.markAsChanged(); +} + export function definePluginSettings< Def extends SettingsDefinition, Checks extends SettingsChecks, From f43baddc550dfd30c1a6b44f7e42544b03084a5a Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Tue, 28 Jan 2025 01:57:16 +0000 Subject: [PATCH 16/35] NoBlockedMessages: Add ignored messages (#3126) --- src/plugins/noBlockedMessages/index.ts | 59 +++++++++++++++++--------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 48ca63d18..95b53c6b3 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/Settings"; +import { definePluginSettings, migratePluginSetting } from "@api/Settings"; import { Devs } from "@utils/constants"; import { runtimeHashMessageKey } from "@utils/intlHash"; import { Logger } from "@utils/Logger"; @@ -32,10 +32,29 @@ interface MessageDeleteProps { collapsedReason: () => any; } +// Remove this migration once enough time has passed +migratePluginSetting("NoBlockedMessages", "ignoreBlockedMessages", "ignoreMessages"); +const settings = definePluginSettings({ + ignoreMessages: { + description: "Completely ignores incoming messages from blocked and ignored (if enabled) users", + type: OptionType.BOOLEAN, + default: false, + restartNeeded: true + }, + applyToIgnoredUsers: { + description: "Additionally apply to 'ignored' users", + type: OptionType.BOOLEAN, + default: true, + restartNeeded: false + } +}); + export default definePlugin({ name: "NoBlockedMessages", - description: "Hides all blocked messages from chat completely.", - authors: [Devs.rushii, Devs.Samu], + description: "Hides all blocked/ignored messages from chat completely", + authors: [Devs.rushii, Devs.Samu, Devs.jamesbt365], + settings, + patches: [ { find: "#{intl::BLOCKED_MESSAGES_HIDE}", @@ -51,38 +70,40 @@ export default definePlugin({ '"ReadStateStore"' ].map(find => ({ find, - predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true, + predicate: () => settings.store.ignoreMessages, replacement: [ { match: /(?<=function (\i)\((\i)\){)(?=.*MESSAGE_CREATE:\1)/, - replace: (_, _funcName, props) => `if($self.isBlocked(${props}.message))return;` + replace: (_, _funcName, props) => `if($self.shouldIgnoreMessage(${props}.message))return;` } ] })) ], - options: { - ignoreBlockedMessages: { - description: "Completely ignores (recent) incoming messages from blocked users (locally).", - type: OptionType.BOOLEAN, - default: false, - restartNeeded: true, - }, - }, - isBlocked(message: Message) { + shouldIgnoreMessage(message: Message) { try { - return RelationshipStore.isBlocked(message.author.id); + if (RelationshipStore.isBlocked(message.author.id)) { + return true; + } + return settings.store.applyToIgnoredUsers && RelationshipStore.isIgnored(message.author.id); } catch (e) { - new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e); + new Logger("NoBlockedMessages").error("Failed to check if user is blocked or ignored:", e); + return false; } }, - shouldHide(props: MessageDeleteProps) { + shouldHide(props: MessageDeleteProps): boolean { try { - return props.collapsedReason() === i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")](); + const collapsedReason = props.collapsedReason(); + const blockedReason = i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")](); + const ignoredReason = settings.store.applyToIgnoredUsers + ? i18n.t[runtimeHashMessageKey("IGNORED_MESSAGE_COUNT")]() + : null; + + return collapsedReason === blockedReason || collapsedReason === ignoredReason; } catch (e) { console.error(e); + return false; } - return false; } }); From cdc756193e93914d3f644f52ecc4d65dbd02d5a9 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 28 Jan 2025 01:13:36 -0300 Subject: [PATCH 17/35] Settings API: Fix erroring if plugin settings don't exist --- src/api/Settings.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/Settings.ts b/src/api/Settings.ts index 8c05d9bb3..262722b14 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -224,8 +224,8 @@ export function migratePluginSetting(pluginName: string, oldSetting: string, new const { plugins } = SettingsStore.plain; if ( - plugins[pluginName][newSetting] != null || - plugins[pluginName][oldSetting] == null + plugins?.[pluginName]?.[oldSetting] == null || + plugins[pluginName][newSetting] != null ) return; plugins[pluginName][newSetting] = plugins[pluginName][oldSetting]; From 33d4f13a242fb4b5124010546773a7bda3d9d962 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 29 Jan 2025 01:04:36 -0300 Subject: [PATCH 18/35] Fix everything broken by recent Discord update (#3177) Co-authored-by: sadan <117494111+sadan4@users.noreply.github.com> Co-authored-by: Vendicated --- src/api/ChatButtons.tsx | 4 +- src/api/ContextMenu.ts | 8 +- src/api/Settings.ts | 12 +- src/debug/runReporter.ts | 15 +- src/plugins/_api/badges/index.tsx | 18 +-- src/plugins/_api/chatButtons.ts | 16 ++- src/plugins/_api/contextMenu.ts | 20 ++- src/plugins/_api/menuItemDemangler.ts | 68 +++++++++ src/plugins/_core/settings.tsx | 2 +- src/plugins/betterFolders/index.tsx | 4 +- src/plugins/betterSessions/index.tsx | 4 +- src/plugins/betterSettings/index.tsx | 4 +- src/plugins/consoleJanitor/index.ts | 4 +- src/plugins/consoleShortcuts/index.ts | 37 ++++- src/plugins/ctrlEnterSend/index.ts | 6 +- src/plugins/fakeNitro/index.tsx | 8 +- src/plugins/fullSearchContext/index.tsx | 4 +- src/plugins/gameActivityToggle/index.tsx | 2 +- src/plugins/iLoveSpam/index.ts | 2 +- src/plugins/ignoreActivities/index.tsx | 2 +- src/plugins/implicitRelationships/index.ts | 2 +- src/plugins/mentionAvatars/index.tsx | 2 +- src/plugins/messageLatency/index.tsx | 4 +- src/plugins/messageLogger/index.tsx | 2 +- src/plugins/openInApp/index.ts | 4 +- src/plugins/permissionFreeWill/index.ts | 4 +- .../pinDms/components/CreateCategoryModal.tsx | 4 +- src/plugins/platformIndicators/index.tsx | 8 +- src/plugins/showHiddenChannels/index.tsx | 22 +-- src/plugins/showTimeoutDuration/index.tsx | 4 +- src/plugins/typingIndicator/index.tsx | 4 +- src/plugins/userVoiceShow/components.tsx | 2 +- src/plugins/vencordToolbox/index.tsx | 4 +- src/plugins/viewIcons/index.tsx | 8 +- src/utils/modal.tsx | 81 ++++++----- src/webpack/common/components.ts | 130 +++++++++--------- src/webpack/common/menu.ts | 20 ++- src/webpack/common/types/components.d.ts | 3 - src/webpack/common/types/iconNames.d.ts | 14 -- src/webpack/patchWebpack.ts | 40 ++++-- src/webpack/webpack.ts | 31 +++-- 41 files changed, 389 insertions(+), 244 deletions(-) create mode 100644 src/plugins/_api/menuItemDemangler.ts delete mode 100644 src/webpack/common/types/iconNames.d.ts diff --git a/src/api/ChatButtons.tsx b/src/api/ChatButtons.tsx index c24e3886f..6f4285ff5 100644 --- a/src/api/ChatButtons.tsx +++ b/src/api/ChatButtons.tsx @@ -9,7 +9,7 @@ import "./ChatButton.css"; import ErrorBoundary from "@components/ErrorBoundary"; import { Logger } from "@utils/Logger"; import { waitFor } from "@webpack"; -import { Button, ButtonLooks, ButtonWrapperClasses, Tooltip } from "@webpack/common"; +import { Button, ButtonWrapperClasses, Tooltip } from "@webpack/common"; import { Channel } from "discord-types/general"; import { HTMLProps, JSX, MouseEventHandler, ReactNode } from "react"; @@ -110,7 +110,7 @@ export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => { + ) } }); diff --git a/src/plugins/reviewDB/settings.tsx b/src/plugins/reviewDB/settings.tsx index eeebd0aa1..2b58d080c 100644 --- a/src/plugins/reviewDB/settings.tsx +++ b/src/plugins/reviewDB/settings.tsx @@ -27,7 +27,6 @@ import { cl } from "./utils"; export const settings = definePluginSettings({ authorize: { type: OptionType.COMPONENT, - description: "Authorize with ReviewDB", component: () => ( diff --git a/src/plugins/textReplace/index.tsx b/src/plugins/textReplace/index.tsx index 3d1e891d1..4bec9b6f9 100644 --- a/src/plugins/textReplace/index.tsx +++ b/src/plugins/textReplace/index.tsx @@ -45,7 +45,6 @@ const makeEmptyRuleArray = () => [makeEmptyRule()]; const settings = definePluginSettings({ replace: { type: OptionType.COMPONENT, - description: "", component: () => { const { stringRules, regexRules } = settings.use(["stringRules", "regexRules"]); diff --git a/src/utils/types.ts b/src/utils/types.ts index 54de59e34..8f0ec3860 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -198,15 +198,16 @@ export type SettingsChecks = { (IsDisabled> & IsValid, DefinedSettings>); }; -export type PluginSettingDef = (PluginSettingCustomDef & Pick) | (( - | PluginSettingStringDef - | PluginSettingNumberDef - | PluginSettingBooleanDef - | PluginSettingSelectDef - | PluginSettingSliderDef - | PluginSettingComponentDef - | PluginSettingBigIntDef -) & PluginSettingCommon); +export type PluginSettingDef = + (PluginSettingCustomDef & Pick) | + (PluginSettingComponentDef & Omit) | (( + | PluginSettingStringDef + | PluginSettingNumberDef + | PluginSettingBooleanDef + | PluginSettingSelectDef + | PluginSettingSliderDef + | PluginSettingBigIntDef + ) & PluginSettingCommon); export interface PluginSettingCommon { description: string; @@ -226,12 +227,14 @@ export interface PluginSettingCommon { */ target?: "WEB" | "DESKTOP" | "BOTH"; } + interface IsDisabled { /** * Checks if this setting should be disabled */ disabled?(this: D): boolean; } + interface IsValid { /** * Prevents the user from saving settings if this is false or a string @@ -320,7 +323,7 @@ type PluginSettingType = O extends PluginSettingStri O extends PluginSettingBooleanDef ? boolean : O extends PluginSettingSelectDef ? O["options"][number]["value"] : O extends PluginSettingSliderDef ? number : - O extends PluginSettingComponentDef ? any : + O extends PluginSettingComponentDef ? O extends { default: infer Default; } ? Default : any : O extends PluginSettingCustomDef ? O extends { default: infer Default; } ? Default : any : never; @@ -382,7 +385,7 @@ export type PluginOptionNumber = (PluginSettingNumberDef | PluginSettingBigIntDe export type PluginOptionBoolean = PluginSettingBooleanDef & PluginSettingCommon & IsDisabled & IsValid; export type PluginOptionSelect = PluginSettingSelectDef & PluginSettingCommon & IsDisabled & IsValid; export type PluginOptionSlider = PluginSettingSliderDef & PluginSettingCommon & IsDisabled & IsValid; -export type PluginOptionComponent = PluginSettingComponentDef & PluginSettingCommon; +export type PluginOptionComponent = PluginSettingComponentDef & Omit; export type PluginOptionCustom = PluginSettingCustomDef & Pick; export type PluginNative any>> = { From 240195f9bfb59294c11294282b140bcd55523432 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 29 Jan 2025 20:44:15 +0100 Subject: [PATCH 23/35] Bump to v1.11.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a7dca5793..057175f9c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.11.2", + "version": "1.11.3", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 7d45862023510838206e76cc9b08f72da213dea0 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Wed, 29 Jan 2025 20:28:11 -0500 Subject: [PATCH 24/35] Fix IgnoreActivities and AlwaysAnimate for canary (#3182) --- src/plugins/alwaysAnimate/index.ts | 4 ++-- src/plugins/ignoreActivities/index.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/alwaysAnimate/index.ts b/src/plugins/alwaysAnimate/index.ts index fc528466f..a5297445b 100644 --- a/src/plugins/alwaysAnimate/index.ts +++ b/src/plugins/alwaysAnimate/index.ts @@ -43,8 +43,8 @@ export default definePlugin({ // Status emojis find: "#{intl::GUILD_OWNER}),children:", replacement: { - match: /(?<=\.activityEmoji,.+?animate:)\i/, - replace: "!0" + match: /(\.CUSTOM_STATUS.+?animate:)\i/, + replace: (_, rest) => `${rest}!0` } }, { diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 0a88aa1f5..d21f05799 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -241,7 +241,7 @@ export default definePlugin({ find: '"LocalActivityStore"', replacement: [ { - match: /HANG_STATUS.+?(?=!?\i\(\)\(\i,\i\))(?<=(\i)\.push.+?)/, + match: /\.LISTENING.+?(?=!?\i\(\)\(\i,\i\))(?<=(\i)\.push.+?)/, replace: (m, activities) => `${m}${activities}=${activities}.filter($self.isActivityNotIgnored);` } ] From 68662c96255f617189411d97a9f11cabe2f5584d Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Thu, 30 Jan 2025 01:36:56 +0000 Subject: [PATCH 25/35] QuickReply: Fix showing toggle mention in guilds (#3181) --- src/plugins/quickReply/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/quickReply/index.ts b/src/plugins/quickReply/index.ts index 4a7060c59..f6ca5b459 100644 --- a/src/plugins/quickReply/index.ts +++ b/src/plugins/quickReply/index.ts @@ -196,7 +196,7 @@ function nextReply(isUp: boolean) { channel, message, shouldMention: shouldMention(message), - showMentionToggle: channel.isPrivate() && message.author.id !== meId, + showMentionToggle: !channel.isPrivate() && message.author.id !== meId, _isQuickReply: true }); ComponentDispatch.dispatchToLastSubscribed("TEXTAREA_FOCUS"); From 8fccda4a249b843c094e944c2051e951a7a43235 Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Thu, 30 Jan 2025 14:41:32 +1300 Subject: [PATCH 26/35] WhoReacted, TypingIndicator: Fix triggering other actions (#3161) Prevents typing in message user box from activating parent click handlers Fixes https://github.com/Vendicated/Vencord/issues/3128 --- src/plugins/typingIndicator/index.tsx | 28 +++++++++++++++++---------- src/plugins/whoReacted/index.tsx | 4 ++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index 642dcc29f..e6903bcde 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -100,16 +100,24 @@ function TypingIndicator({ channelId, guildId }: { channelId: string; guildId: s {props => (
{((settings.store.indicatorMode & IndicatorMode.Avatars) === IndicatorMode.Avatars) && ( - UserStore.getUser(id))} - guildId={guildId} - renderIcon={false} - max={3} - showDefaultAvatarsForNullUsers - showUserPopout - size={16} - className="vc-typing-indicator-avatars" - /> +
{ + e.stopPropagation(); + e.preventDefault(); + }} + onKeyPress={e => e.stopPropagation()} + > + UserStore.getUser(id))} + guildId={guildId} + renderIcon={false} + max={3} + showDefaultAvatarsForNullUsers + showUserPopout + size={16} + className="vc-typing-indicator-avatars" + /> +
)} {((settings.store.indicatorMode & IndicatorMode.Dots) === IndicatorMode.Dots) && (
diff --git a/src/plugins/whoReacted/index.tsx b/src/plugins/whoReacted/index.tsx index 803cc7156..aea57fef2 100644 --- a/src/plugins/whoReacted/index.tsx +++ b/src/plugins/whoReacted/index.tsx @@ -93,7 +93,7 @@ function makeRenderMoreUsers(users: User[]) { }; } -function handleClickAvatar(event: React.MouseEvent) { +function handleClickAvatar(event: React.UIEvent) { event.stopPropagation(); } @@ -165,7 +165,7 @@ export default definePlugin({
-
+
Date: Thu, 30 Jan 2025 14:54:41 -0300 Subject: [PATCH 27/35] Ignore more modules on webpack searching --- src/webpack/patchWebpack.ts | 51 ++++++------------------- src/webpack/webpack.ts | 74 ++++++++++++++++++++++++------------- 2 files changed, 60 insertions(+), 65 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 0fddf472f..1122d55bb 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -24,7 +24,7 @@ import { WebpackInstance } from "discord-types/other"; import { traceFunction } from "../debug/Tracer"; import { patches } from "../plugins"; -import { _initWebpack, beforeInitListeners, factoryListeners, moduleListeners, subscriptions, wreq } from "."; +import { _initWebpack, _shouldIgnoreModule, beforeInitListeners, factoryListeners, moduleListeners, subscriptions, wreq } from "."; const logger = new Logger("WebpackInterceptor", "#8caaee"); @@ -173,35 +173,9 @@ function patchFactories(factories: Record { const filter = filters.byCode(...code); return m => { - if (filter(m)) return true; - if (!m.$$typeof) return false; - if (m.type) - return m.type.render - ? filter(m.type.render) // memo + forwardRef - : filter(m.type); // memo - if (m.render) return filter(m.render); // forwardRef + let inner = m; + + while (inner != null) { + if (filter(inner)) return true; + else if (!inner.$$typeof) return false; + else if (inner.type) inner = inner.type; // memos + else if (inner.render) inner = inner.render; // forwardRefs + else return false; + } + return false; }; } @@ -95,6 +98,38 @@ export function _initWebpack(webpackRequire: WebpackInstance) { cache = webpackRequire.c; } +// Credits to Zerebos for implementing this in BD, thus giving the idea for us to implement it too +const TypedArray = Object.getPrototypeOf(Int8Array); + +function _shouldIgnoreValue(value: any) { + if (value == null) return true; + if (value === window) return true; + if (value === document || value === document.documentElement) return true; + if (value[Symbol.toStringTag] === "DOMTokenList") return true; + if (value instanceof TypedArray) return true; + + return false; +} + +export function _shouldIgnoreModule(exports: any) { + if (_shouldIgnoreValue(exports)) { + return true; + } + + if (typeof exports !== "object") { + return false; + } + + let allNonEnumerable = true; + for (const exportKey in exports) { + if (!_shouldIgnoreValue(exports[exportKey])) { + allNonEnumerable = false; + } + } + + return allNonEnumerable; +} + let devToolsOpen = false; if (IS_DEV && IS_DISCORD_DESKTOP) { // At this point in time, DiscordNative has not been exposed yet, so setImmediate is needed @@ -121,7 +156,7 @@ export const find = traceFunction("find", function find(filter: FilterFn, { isIn for (const key in cache) { const mod = cache[key]; - if (!mod.loaded || !mod?.exports) continue; + if (!mod?.loaded || mod.exports == null) continue; if (filter(mod.exports)) { return isWaitFor ? [mod.exports, key] : mod.exports; @@ -129,11 +164,6 @@ export const find = traceFunction("find", function find(filter: FilterFn, { isIn if (typeof mod.exports !== "object") continue; - if (mod.exports.default && filter(mod.exports.default)) { - const found = mod.exports.default; - return isWaitFor ? [found, key] : found; - } - for (const nestedMod in mod.exports) { const nested = mod.exports[nestedMod]; if (nested && filter(nested)) { @@ -156,16 +186,15 @@ export function findAll(filter: FilterFn) { const ret = [] as any[]; for (const key in cache) { const mod = cache[key]; - if (!mod.loaded || !mod?.exports) continue; + if (!mod?.loaded || mod.exports == null) continue; if (filter(mod.exports)) ret.push(mod.exports); - else if (typeof mod.exports !== "object") + + if (typeof mod.exports !== "object") continue; - if (mod.exports.default && filter(mod.exports.default)) - ret.push(mod.exports.default); - else for (const nestedMod in mod.exports) { + for (const nestedMod in mod.exports) { const nested = mod.exports[nestedMod]; if (nested && filter(nested)) ret.push(nested); } @@ -204,7 +233,7 @@ export const findBulk = traceFunction("findBulk", function findBulk(...filterFns outer: for (const key in cache) { const mod = cache[key]; - if (!mod.loaded || !mod?.exports) continue; + if (!mod?.loaded || mod.exports == null) continue; for (let j = 0; j < length; j++) { const filter = filters[j]; @@ -221,13 +250,6 @@ export const findBulk = traceFunction("findBulk", function findBulk(...filterFns if (typeof mod.exports !== "object") continue; - if (mod.exports.default && filter(mod.exports.default)) { - results[j] = mod.exports.default; - filters[j] = undefined; - if (++found === length) break outer; - break; - } - for (const nestedMod in mod.exports) { const nested = mod.exports[nestedMod]; if (nested && filter(nested)) { From a492f7657b7552e32cdfa7630e38601ae9a26ecf Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 30 Jan 2025 15:15:40 -0300 Subject: [PATCH 28/35] MessageEventsAPI: Fix for upcoming change --- src/plugins/_api/messageEvents.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index 97ed1746d..25a46711d 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -37,12 +37,13 @@ export default definePlugin({ { find: ".handleSendMessage,onResize", replacement: { + // FIXME: Simplify this change once all branches share the same code // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/, + match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\((?:async )?)(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/, // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + - `${rest1}async ${rest2}` + + `${rest1}${rest1.includes("async") ? "" : "async "}${rest2}` + `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + "return{shouldClear:false,shouldRefocus:true};" } From b2d5c00a23e598ee398c0045e9f44b4eeff569d4 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:01:36 -0300 Subject: [PATCH 29/35] Delete NoScreensharePreview ~now a stock feature --- src/plugins/noScreensharePreview/index.ts | 42 ----------------------- 1 file changed, 42 deletions(-) delete mode 100644 src/plugins/noScreensharePreview/index.ts diff --git a/src/plugins/noScreensharePreview/index.ts b/src/plugins/noScreensharePreview/index.ts deleted file mode 100644 index d4bb9c1eb..000000000 --- a/src/plugins/noScreensharePreview/index.ts +++ /dev/null @@ -1,42 +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 { getUserSettingLazy } from "@api/UserSettings"; -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -const DisableStreamPreviews = getUserSettingLazy("voiceAndVideo", "disableStreamPreviews")!; - -// @TODO: Delete this plugin in the future -export default definePlugin({ - name: "NoScreensharePreview", - description: "Disables screenshare previews from being sent.", - authors: [Devs.Nuckyz], - - start() { - if (!DisableStreamPreviews.getSetting()) { - DisableStreamPreviews.updateSetting(true); - } - }, - - stop() { - if (DisableStreamPreviews.getSetting()) { - DisableStreamPreviews.updateSetting(false); - } - } -}); From 414539f45ecc24bf78878a76de0569f6d14ab375 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:01:57 -0300 Subject: [PATCH 30/35] Add more FIXME and explain better TODOS for migrations --- src/plugins/_api/chatButtons.ts | 1 + src/plugins/_core/settings.tsx | 1 + src/plugins/ctrlEnterSend/index.ts | 1 + src/plugins/fakeNitro/index.tsx | 1 + src/plugins/messageTags/index.ts | 2 +- src/plugins/openInApp/index.ts | 1 + src/plugins/permissionFreeWill/index.ts | 1 + src/plugins/pinDms/data.ts | 2 +- src/plugins/showHiddenChannels/index.tsx | 4 ++++ src/plugins/textReplace/index.tsx | 2 +- 10 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/_api/chatButtons.ts b/src/plugins/_api/chatButtons.ts index 86ca195e0..184b01584 100644 --- a/src/plugins/_api/chatButtons.ts +++ b/src/plugins/_api/chatButtons.ts @@ -16,6 +16,7 @@ export default definePlugin({ { find: '"sticker")', replacement: { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /return\((!)?\i\.\i(?:\|\||&&)(?=\(\i\.isDM.+?(\i)\.push)/, replace: (m, not, children) => not ? `${m}(Vencord.Api.ChatButtons._injectButtons(${children},arguments[0]),true)&&` diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index 75fa91470..f48f38e03 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -65,6 +65,7 @@ export default definePlugin({ replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}` }, { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /({(?=.+?function (\i).{0,160}(\i)=\i\.useMemo.{0,140}return \i\.useMemo\(\(\)=>\i\(\3).+?(?:function\(\){return |\(\)=>))\2/, replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})` } diff --git a/src/plugins/ctrlEnterSend/index.ts b/src/plugins/ctrlEnterSend/index.ts index 67db12abc..b24f7a909 100644 --- a/src/plugins/ctrlEnterSend/index.ts +++ b/src/plugins/ctrlEnterSend/index.ts @@ -44,6 +44,7 @@ export default definePlugin({ { find: ".selectPreviousCommandOption(", replacement: { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(?<=(\i)\.which(?:!==|===)\i\.\i.ENTER(\|\||&&)).{0,100}(\(0,\i\.\i\)\(\i\)).{0,100}(?=(?:\|\||&&)\(\i\.preventDefault)/, replace: (_, event, condition, codeblock) => `${condition === "||" ? "!" : ""}$self.shouldSubmit(${event},${codeblock})` } diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index 020ff67c2..4bdf194ce 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -256,6 +256,7 @@ export default definePlugin({ }, { // Disallow the emoji for premium locked if the intention doesn't allow it + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(!)?(\i\.\i\.canUseEmojisEverywhere\(\i\))/, replace: (m, not) => not ? `(${m}&&!${IS_BYPASSEABLE_INTENTION})` diff --git a/src/plugins/messageTags/index.ts b/src/plugins/messageTags/index.ts index 5a5d03fdb..49e88c42d 100644 --- a/src/plugins/messageTags/index.ts +++ b/src/plugins/messageTags/index.ts @@ -89,7 +89,7 @@ export default definePlugin({ settings, async start() { - // TODO: Remove DataStore tags migration once enough time has passed + // TODO(OptionType.CUSTOM Related): Remove DataStore tags migration once enough time has passed const oldTags = await DataStore.get(DATA_KEY); if (oldTags != null) { // @ts-ignore diff --git a/src/plugins/openInApp/index.ts b/src/plugins/openInApp/index.ts index e344f1458..1c90b5290 100644 --- a/src/plugins/openInApp/index.ts +++ b/src/plugins/openInApp/index.ts @@ -100,6 +100,7 @@ export default definePlugin({ replace: "true" }, { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(!)?\(0,\i\.isDesktop\)\(\)/, replace: (_, not) => not ? "false" : "true" } diff --git a/src/plugins/permissionFreeWill/index.ts b/src/plugins/permissionFreeWill/index.ts index 510d9cb3b..8a6135145 100644 --- a/src/plugins/permissionFreeWill/index.ts +++ b/src/plugins/permissionFreeWill/index.ts @@ -46,6 +46,7 @@ export default definePlugin({ find: "#{intl::ONBOARDING_CHANNEL_THRESHOLD_WARNING}", replacement: [ { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /{(?:\i:(?:function\(\){return |\(\)=>)\i}?,?){2}}/, replace: m => m.replaceAll(canonicalizeMatch(/(function\(\){return |\(\)=>)\i/g), "$1()=>Promise.resolve(true)") } diff --git a/src/plugins/pinDms/data.ts b/src/plugins/pinDms/data.ts index 2f4a1156e..d689bd2af 100644 --- a/src/plugins/pinDms/data.ts +++ b/src/plugins/pinDms/data.ts @@ -155,7 +155,7 @@ export function moveChannel(channelId: string, direction: -1 | 1) { swapElementsInArray(category.channels, a, b); } -// TODO: Remove DataStore PinnedDms migration once enough time has passed +// TODO(OptionType.CUSTOM Related): Remove DataStore PinnedDms migration once enough time has passed async function migrateData() { if (Settings.plugins.PinDMs.dmSectioncollapsed != null) { settings.store.dmSectionCollapsed = Settings.plugins.PinDMs.dmSectioncollapsed; diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 382990d06..09291b825 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -108,6 +108,7 @@ export default definePlugin({ }, { // Prevent Discord from trying to connect to hidden voice channels + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(?=(\|\||&&)\i\.\i\.selectVoiceChannel\((\i)\.id\))/, replace: (_, condition, channel) => condition === "||" ? `||$self.isHiddenChannel(${channel})` @@ -124,6 +125,7 @@ export default definePlugin({ { find: ".AUDIENCE),{isSubscriptionGated", replacement: { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(!)?(\i)\.isRoleSubscriptionTemplatePreviewChannel\(\)/, replace: (m, not, channel) => not ? `${m}&&!$self.isHiddenChannel(${channel})` @@ -177,6 +179,7 @@ export default definePlugin({ }, // Make voice channels also appear as muted if they are muted { + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(?<=\.wrapper:\i\.notInteractive,)(.+?)(if\()?(\i)(?:\)return |\?)(\i\.MUTED)/, replace: (_, otherClasses, isIf, isMuted, mutedClassExpression) => isIf ? `${isMuted}?${mutedClassExpression}:"",${otherClasses}if(${isMuted})return ""` @@ -190,6 +193,7 @@ export default definePlugin({ { // Make muted channels also appear as unread if hide unreads is false, using the HiddenIconWithMutedStyle and the channel is hidden predicate: () => settings.store.hideUnreads === false && settings.store.showMode === ShowMode.HiddenIconWithMutedStyle, + // FIXME(Bundler change related): Remove old compatiblity once enough time has passed match: /(?<=\.LOCKED(?:;if\(|:))(?<={channel:(\i).+?)/, replace: (_, channel) => `!$self.isHiddenChannel(${channel})&&` }, diff --git a/src/plugins/textReplace/index.tsx b/src/plugins/textReplace/index.tsx index 4bec9b6f9..d5d6f4dc8 100644 --- a/src/plugins/textReplace/index.tsx +++ b/src/plugins/textReplace/index.tsx @@ -244,7 +244,7 @@ export default definePlugin({ }, async start() { - // TODO: Remove DataStore rules migrations once enough time has passed + // TODO(OptionType.CUSTOM Related): Remove DataStore rules migrations once enough time has passed const oldStringRules = await DataStore.get(STRING_RULES_KEY); if (oldStringRules != null) { settings.store.stringRules = oldStringRules; From 1eff1a02bd1d447a412c12744ea742d74794e923 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:02:42 -0300 Subject: [PATCH 31/35] IrcColors: Fix causing react errors sometimes --- src/plugins/ircColors/index.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts index 208b327e9..a518fd93d 100644 --- a/src/plugins/ircColors/index.ts +++ b/src/plugins/ircColors/index.ts @@ -23,11 +23,11 @@ import definePlugin, { OptionType } from "@utils/types"; import { useMemo } from "@webpack/common"; // Calculate a CSS color string based on the user ID -function calculateNameColorForUser(id: string) { +function calculateNameColorForUser(id?: string) { const { lightness } = settings.use(["lightness"]); - const idHash = useMemo(() => h64(id), [id]); + const idHash = useMemo(() => id ? h64(id) : null, [id]); - return `hsl(${idHash % 360n}, 100%, ${lightness}%)`; + return idHash && `hsl(${idHash % 360n}, 100%, ${lightness}%)`; } const settings = definePluginSettings({ @@ -70,16 +70,10 @@ export default definePlugin({ calculateNameColorForMessageContext(context: any) { const id = context?.message?.author?.id; - if (id == null) { - return null; - } return calculateNameColorForUser(id); }, calculateNameColorForListContext(context: any) { const id = context?.user?.id; - if (id == null) { - return null; - } return calculateNameColorForUser(id); } }); From fc4e95806d1c33b160a3a8516debfe54c1344328 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:55:40 -0300 Subject: [PATCH 32/35] Fix ImplicitRelationships and NotificationsVolume (#3184) Also simplifies MessageEventsAPI patch --- src/plugins/_api/messageEvents.ts | 13 ++++--------- src/plugins/implicitRelationships/index.ts | 6 +++--- src/plugins/notificationVolume/index.ts | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index 25a46711d..9dfc55e27 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -37,13 +37,9 @@ export default definePlugin({ { find: ".handleSendMessage,onResize", replacement: { - // FIXME: Simplify this change once all branches share the same code - // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); - // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\((?:async )?)(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/, - // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; - replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + - `${rest1}${rest1.includes("async") ? "" : "async "}${rest2}` + + // https://regex101.com/r/hBlXpl/1 + match: /let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);(?<=\)\(({.+?})\)\.then.+?)/, + replace: (m, parsedMessage, channel, replyOptions, extra) => m + `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + "return{shouldClear:false,shouldRefocus:true};" } @@ -53,8 +49,7 @@ export default definePlugin({ replacement: { match: /let\{id:\i}=(\i),{id:\i}=(\i);return \i\.useCallback\((\i)=>\{/, replace: (m, message, channel, event) => - // the message param is shadowed by the event param, so need to alias them - `const vcMsg=${message},vcChan=${channel};${m}Vencord.Api.MessageEvents._handleClick(vcMsg, vcChan, ${event});` + `const vcMsg=${message},vcChan=${channel};${m}Vencord.Api.MessageEvents._handleClick(vcMsg,vcChan,${event});` } } ] diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index c6b61ef4a..cfc3818dd 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -50,9 +50,9 @@ export default definePlugin({ { find: "#{intl::FRIENDS_SECTION_ONLINE}", replacement: { - match: /(\(0,\i\.jsx\)\(\i\.\i\.Item,\{id:\i\.\i)\.BLOCKED,className:([^\s]+?)\.item,children:\i\.\i\.string\(\i\.\i#{intl::BLOCKED}\)\}\)/, - replace: "$1.IMPLICIT,className:$2.item,children:\"Implicit\"}),$&" - }, + match: /,{id:(\i\.\i)\.BLOCKED,show:.+?className:(\i\.item)/, + replace: (rest, relationShipTypes, className) => `,{id:${relationShipTypes}.IMPLICIT,show:true,className:${className},content:"Implicit"}${rest}` + } }, // Sections content { diff --git a/src/plugins/notificationVolume/index.ts b/src/plugins/notificationVolume/index.ts index bc3c7539d..d320d76f1 100644 --- a/src/plugins/notificationVolume/index.ts +++ b/src/plugins/notificationVolume/index.ts @@ -25,9 +25,9 @@ export default definePlugin({ settings, patches: [ { - find: "_ensureAudio(){", + find: "ensureAudio(){", replacement: { - match: /(?=Math\.min\(\i\.\i\.getOutputVolume\(\)\/100)/, + match: /(?=Math\.min\(\i\.\i\.getOutputVolume\(\)\/100)/g, replace: "$self.settings.store.notificationVolume/100*" }, }, From 7b9f0a36ba3ae7762e852a6a4e91838d4b772ec4 Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Fri, 31 Jan 2025 18:54:51 +0000 Subject: [PATCH 33/35] IrcColors: Allow coloring only users with no color and DMs only (#3186) --- src/plugins/ircColors/index.ts | 36 +++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts index a518fd93d..af926043d 100644 --- a/src/plugins/ircColors/index.ts +++ b/src/plugins/ircColors/index.ts @@ -41,13 +41,25 @@ const settings = definePluginSettings({ restartNeeded: true, type: OptionType.BOOLEAN, default: true + }, + applyColorOnlyToUsersWithoutColor: { + description: "Apply colors only to users who don't have a predefined color", + restartNeeded: false, + type: OptionType.BOOLEAN, + default: false + }, + applyColorOnlyInDms: { + description: "Apply colors only in direct messages; do not apply colors in servers.", + restartNeeded: false, + type: OptionType.BOOLEAN, + default: false } }); export default definePlugin({ name: "IrcColors", description: "Makes username colors in chat unique, like in IRC clients", - authors: [Devs.Grzesiek11], + authors: [Devs.Grzesiek11, Devs.jamesbt365], settings, patches: [ @@ -70,10 +82,28 @@ export default definePlugin({ calculateNameColorForMessageContext(context: any) { const id = context?.message?.author?.id; - return calculateNameColorForUser(id); + const colorString = context?.author?.colorString; + const color = calculateNameColorForUser(id); + + if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) { + return colorString; + } + + return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) + ? color + : colorString; }, calculateNameColorForListContext(context: any) { const id = context?.user?.id; - return calculateNameColorForUser(id); + const colorString = context?.colorString; + const color = calculateNameColorForUser(id); + + if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) { + return colorString; + } + + return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) + ? color + : colorString; } }); From 4f5ebec4bb3ef9abf64668b8927405041642e37e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:24:07 -0300 Subject: [PATCH 34/35] FullUserInChatbox: Fix empty mention when user is unknown Fixes #3190 --- src/plugins/fullUserInChatbox/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx index 5a0c41c01..ceeb56926 100644 --- a/src/plugins/fullUserInChatbox/index.tsx +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -8,6 +8,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; +import { UserStore, useStateFromStores } from "@webpack/common"; import { ReactNode } from "react"; const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)"); @@ -34,14 +35,19 @@ export default definePlugin({ } ], - UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => ( - { + const user = useStateFromStores([UserStore], () => UserStore.getUser(props.id)); + if (user == null) { + return props.originalComponent(); + } + + return - ), { + />; + }, { fallback: ({ wrappedProps: { originalComponent } }) => originalComponent() }) }); From 6cccb54ffcd77c51ccae236420f4df0da8fa616f Mon Sep 17 00:00:00 2001 From: v Date: Sun, 2 Feb 2025 01:37:54 +0100 Subject: [PATCH 35/35] Fix lag caused by poorly written CSS rules (#3198) Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> --- src/components/PluginSettings/index.tsx | 6 +- src/components/PluginSettings/styles.css | 9 +- src/plugins/blurNsfw/index.ts | 14 +-- src/plugins/clientTheme/clientTheme.css | 12 +- src/plugins/clientTheme/index.tsx | 18 +-- src/plugins/dearrow/index.tsx | 1 + src/plugins/dearrow/styles.css | 2 +- src/plugins/hideAttachments/index.tsx | 75 ++++++------ src/plugins/hideAttachments/styles.css | 10 ++ .../imageZoom/components/Magnifier.tsx | 1 + src/plugins/imageZoom/styles.css | 2 +- src/plugins/messageLogger/deleteStyleText.css | 30 ++--- src/plugins/messageLogger/index.tsx | 9 +- src/plugins/messageLogger/messageLogger.css | 24 ++-- .../components/RolesAndUsersPermissions.tsx | 2 +- src/plugins/permissionsViewer/styles.css | 2 +- .../reviewDB/components/BlockedUserModal.tsx | 2 +- .../reviewDB/components/ReviewModal.tsx | 2 +- src/plugins/reviewDB/style.css | 13 +-- src/plugins/sendTimestamps/index.tsx | 41 ++++--- src/plugins/sendTimestamps/styles.css | 23 ++-- src/plugins/serverInfo/GuildInfoModal.tsx | 2 + src/plugins/serverInfo/styles.css | 4 +- .../components/Code.tsx | 6 +- .../components/Highlighter.tsx | 2 +- src/plugins/shikiCodeblocks.desktop/shiki.css | 34 +++--- .../shikiCodeblocks.desktop/utils/misc.ts | 2 +- src/plugins/showConnections/VerifiedIcon.tsx | 1 + src/plugins/showConnections/index.tsx | 2 +- src/plugins/showConnections/styles.css | 2 +- .../components/HiddenChannelLockScreen.tsx | 36 +++--- src/plugins/showHiddenChannels/index.tsx | 10 +- src/plugins/showHiddenChannels/style.css | 110 +++++++----------- .../spotifyControls/PlayerComponent.tsx | 20 ++-- src/plugins/spotifyControls/spotifyStyles.css | 32 ++--- src/plugins/translate/TranslateModal.tsx | 2 +- .../translate/TranslationAccessory.tsx | 2 +- src/plugins/translate/styles.css | 4 +- src/plugins/usrbg/index.css | 12 -- src/plugins/usrbg/index.tsx | 5 - src/plugins/vencordToolbox/index.css | 8 +- src/plugins/vencordToolbox/index.tsx | 2 +- src/plugins/voiceMessages/styles.css | 4 - 43 files changed, 270 insertions(+), 330 deletions(-) create mode 100644 src/plugins/hideAttachments/styles.css delete mode 100644 src/plugins/usrbg/index.css diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 959a4d01e..371c3082c 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 - @@ -158,8 +158,8 @@ export function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, on className={classes(ButtonClasses.button, cl("info-button"))} > {plugin.options && !isObjectEmpty(plugin.options) - ? - : } + ? + : } } /> diff --git a/src/components/PluginSettings/styles.css b/src/components/PluginSettings/styles.css index d3d182e58..a4f9aeee1 100644 --- a/src/components/PluginSettings/styles.css +++ b/src/components/PluginSettings/styles.css @@ -63,10 +63,7 @@ height: 8em; display: flex; flex-direction: column; -} - -.vc-plugins-info-card div { - line-height: 32px; + gap: 0.25em; } .vc-plugins-restart-card { @@ -76,11 +73,11 @@ color: var(--info-warning-text); } -.vc-plugins-restart-card button { +.vc-plugins-restart-button { margin-top: 0.5em; background: var(--info-warning-foreground) !important; } -.vc-plugins-info-button svg:not(:hover, :focus) { +.vc-plugins-info-icon:not(:hover, :focus) { color: var(--text-muted); } diff --git a/src/plugins/blurNsfw/index.ts b/src/plugins/blurNsfw/index.ts index 948de0ac6..c4023f098 100644 --- a/src/plugins/blurNsfw/index.ts +++ b/src/plugins/blurNsfw/index.ts @@ -24,14 +24,14 @@ let style: HTMLStyleElement; function setCss() { style.textContent = ` - .vc-nsfw-img [class^=imageWrapper] img, - .vc-nsfw-img [class^=wrapperPaused] video { + .vc-nsfw-img [class^=imageContainer], + .vc-nsfw-img [class^=wrapperPaused] { filter: blur(${Settings.plugins.BlurNSFW.blurAmount}px); transition: filter 0.2s; - } - .vc-nsfw-img [class^=imageWrapper]:hover img, - .vc-nsfw-img [class^=wrapperPaused]:hover video { - filter: unset; + + &:hover { + filter: blur(0); + } } `; } @@ -54,7 +54,7 @@ export default definePlugin({ options: { blurAmount: { type: OptionType.NUMBER, - description: "Blur Amount", + description: "Blur Amount (in pixels)", default: 10, onChange: setCss } diff --git a/src/plugins/clientTheme/clientTheme.css b/src/plugins/clientTheme/clientTheme.css index 64aefdcf5..795b5457e 100644 --- a/src/plugins/clientTheme/clientTheme.css +++ b/src/plugins/clientTheme/clientTheme.css @@ -1,29 +1,29 @@ -.client-theme-settings { +.vc-clientTheme-settings { display: flex; flex-direction: column; } -.client-theme-container { +.vc-clientTheme-container { display: flex; flex-direction: row; justify-content: space-between; } -.client-theme-settings-labels { +.vc-clientTheme-labels { display: flex; flex-direction: column; justify-content: flex-start; } -.client-theme-container > [class^="colorSwatch"] > [class^="swatch"] { +.vc-clientTheme-container [class^="swatch"] { border: thin solid var(--background-modifier-accent) !important; } -.client-theme-warning * { +.vc-clientTheme-warning-text { color: var(--text-danger); } -.client-theme-contrast-warning { +.vc-clientTheme-contrast-warning { background-color: var(--background-primary); padding: 0.5rem; border-radius: .5rem; diff --git a/src/plugins/clientTheme/index.tsx b/src/plugins/clientTheme/index.tsx index 2dc7ccf6c..c7e0e50de 100644 --- a/src/plugins/clientTheme/index.tsx +++ b/src/plugins/clientTheme/index.tsx @@ -7,6 +7,7 @@ import "./clientTheme.css"; import { definePluginSettings } from "@api/Settings"; +import { classNameFactory } from "@api/Styles"; import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; @@ -14,6 +15,8 @@ import definePlugin, { OptionType, StartAt } from "@utils/types"; import { findByCodeLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; import { Button, Forms, ThemeStore, useStateFromStores } from "@webpack/common"; +const cl = classNameFactory("vc-clientTheme-"); + const ColorPicker = findComponentByCodeLazy("#{intl::USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR}", ".BACKGROUND_PRIMARY)"); const colorPresets = [ @@ -60,9 +63,9 @@ function ThemeSettings() { } return ( -
-
-
+
+
+
Theme Color Add a color to your Discord client theme
@@ -76,10 +79,10 @@ function ThemeSettings() { {(contrastWarning || nitroThemeEnabled) && (<>
-
- Warning, your theme won't look good: - {contrastWarning && Selected color won't contrast well with text} - {nitroThemeEnabled && Nitro themes aren't supported} +
+ Warning, your theme won't look good: + {contrastWarning && Selected color won't contrast well with text} + {nitroThemeEnabled && Nitro themes aren't supported}
{(contrastWarning && fixableContrast) && } {(nitroThemeEnabled) && } @@ -123,6 +126,7 @@ export default definePlugin({ stop() { document.getElementById("clientThemeVars")?.remove(); document.getElementById("clientThemeOffsets")?.remove(); + document.getElementById("clientThemeLightModeFixes")?.remove(); } }); diff --git a/src/plugins/dearrow/index.tsx b/src/plugins/dearrow/index.tsx index b7e90e096..7cb60384e 100644 --- a/src/plugins/dearrow/index.tsx +++ b/src/plugins/dearrow/index.tsx @@ -121,6 +121,7 @@ function DearrowButton({ component }: { component: Component; }) { height="24px" viewBox="0 0 36 36" aria-label="Toggle Dearrow" + className="vc-dearrow-icon" > . */ +import "./styles.css"; + import { get, set } from "@api/DataStore"; +import { updateMessage } from "@api/MessageUpdater"; +import { migratePluginSettings } from "@api/Settings"; import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; +import { classes } from "@utils/misc"; import definePlugin from "@utils/types"; import { ChannelStore } from "@webpack/common"; import { MessageSnapshot } from "@webpack/types"; -let style: HTMLStyleElement; - const KEY = "HideAttachments_HiddenIds"; -let hiddenMessages: Set = new Set(); -const getHiddenMessages = () => get(KEY).then(set => { - hiddenMessages = set ?? new Set(); +let hiddenMessages = new Set(); + +async function getHiddenMessages() { + hiddenMessages = await get(KEY) ?? new Set(); return hiddenMessages; -}); +} + const saveHiddenMessages = (ids: Set) => set(KEY, ids); +migratePluginSettings("HideMedia", "HideAttachments"); + export default definePlugin({ - name: "HideAttachments", - description: "Hide attachments and Embeds for individual messages via hover button", + name: "HideMedia", + description: "Hide attachments and embeds for individual messages via hover button", authors: [Devs.Ven], + dependencies: ["MessageUpdaterAPI"], + + patches: [{ + find: "this.renderAttachments(", + replacement: { + match: /(?<=\i=)this\.render(?:Attachments|Embeds|StickersAccessories)\((\i)\)/g, + replace: "$self.shouldHide($1?.id)?null:$&" + } + }], renderMessagePopoverButton(msg) { // @ts-ignore - discord-types lags behind discord. @@ -50,49 +66,42 @@ export default definePlugin({ const isHidden = hiddenMessages.has(msg.id); return { - label: isHidden ? "Show Attachments" : "Hide Attachments", + label: isHidden ? "Show Media" : "Hide Media", icon: isHidden ? ImageVisible : ImageInvisible, message: msg, channel: ChannelStore.getChannel(msg.channel_id), - onClick: () => this.toggleHide(msg.id) + onClick: () => this.toggleHide(msg.channel_id, msg.id) }; }, - async start() { - style = document.createElement("style"); - style.id = "VencordHideAttachments"; - document.head.appendChild(style); + renderMessageAccessory({ message }) { + if (!this.shouldHide(message.id)) return null; + return ( + + Media Hidden + + ); + }, + + async start() { await getHiddenMessages(); - await this.buildCss(); }, stop() { - style.remove(); hiddenMessages.clear(); }, - async buildCss() { - const elements = [...hiddenMessages].map(id => `#message-accessories-${id}`).join(","); - style.textContent = ` - :is(${elements}) :is([class*="embedWrapper"], [class*="clickableSticker"]) { - /* important is not necessary, but add it to make sure bad themes won't break it */ - display: none !important; - } - :is(${elements})::after { - content: "Attachments hidden"; - color: var(--text-muted); - font-size: 80%; - } - `; + shouldHide(messageId: string) { + return hiddenMessages.has(messageId); }, - async toggleHide(id: string) { + async toggleHide(channelId: string, messageId: string) { const ids = await getHiddenMessages(); - if (!ids.delete(id)) - ids.add(id); + if (!ids.delete(messageId)) + ids.add(messageId); await saveHiddenMessages(ids); - await this.buildCss(); + updateMessage(channelId, messageId); } }); diff --git a/src/plugins/hideAttachments/styles.css b/src/plugins/hideAttachments/styles.css new file mode 100644 index 000000000..4cbd10a6f --- /dev/null +++ b/src/plugins/hideAttachments/styles.css @@ -0,0 +1,10 @@ +.vc-hideAttachments-accessory { + color: var(--text-muted); + margin-top: 0.5em; + font-style: italic; + font-weight: 400; +} + +.vc-hideAttachments-no-content { + margin-top: 0; +} diff --git a/src/plugins/imageZoom/components/Magnifier.tsx b/src/plugins/imageZoom/components/Magnifier.tsx index 31fa7a117..009165ff2 100644 --- a/src/plugins/imageZoom/components/Magnifier.tsx +++ b/src/plugins/imageZoom/components/Magnifier.tsx @@ -195,6 +195,7 @@ export const Magnifier = ErrorBoundary.wrap(({ instance, size: i /> ) : ( img { +.vc-imgzoom-nearest-neighbor > .vc-imgzoom-image { image-rendering: pixelated; /* https://googlechrome.github.io/samples/image-rendering-pixelated/index.html */ diff --git a/src/plugins/messageLogger/deleteStyleText.css b/src/plugins/messageLogger/deleteStyleText.css index a4e9a93c1..a114b7de8 100644 --- a/src/plugins/messageLogger/deleteStyleText.css +++ b/src/plugins/messageLogger/deleteStyleText.css @@ -1,24 +1,8 @@ -/* Message content highlighting */ -.messagelogger-deleted [class*="contents"] > :is(div, h1, h2, h3, p) { - color: var(--status-danger, #f04747) !important; -} - -/* Markdown title highlighting */ -.messagelogger-deleted [class*="contents"] :is(h1, h2, h3) { - color: var(--status-danger, #f04747) !important; -} - -/* Bot "thinking" text highlighting */ -.messagelogger-deleted [class*="colorStandard"] { - color: var(--status-danger, #f04747) !important; -} - -/* Embed highlighting */ -.messagelogger-deleted article :is(div, span, h1, h2, h3, p) { - color: var(--status-danger, #f04747) !important; -} - -.messagelogger-deleted a { - color: var(--red-460, #be3535) !important; - text-decoration: underline; +.messagelogger-deleted { + --text-normal: var(--status-danger, #f04747); + --interactive-normal: var(--status-danger, #f04747); + --text-muted: var(--status-danger, #f04747); + --embed-title: var(--red-460, #be3535); + --text-link: var(--red-460, #be3535); + --header-primary: var(--red-460, #be3535); } diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 90b9c30f2..dee58f2f9 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -442,15 +442,10 @@ export default definePlugin({ { // Attachment renderer find: ".removeMosaicItemHoverButton", - group: true, replacement: [ { - match: /(className:\i,item:\i),/, - replace: "$1,item: deleted," - }, - { - match: /\[\i\.obscured\]:.+?,/, - replace: "$& 'messagelogger-deleted-attachment': deleted," + match: /\[\i\.obscured\]:.+?,(?<=item:(\i).+?)/, + replace: '$&"messagelogger-deleted-attachment":$1.originalItem?.deleted,' } ] }, diff --git a/src/plugins/messageLogger/messageLogger.css b/src/plugins/messageLogger/messageLogger.css index 2759129d9..a76e98888 100644 --- a/src/plugins/messageLogger/messageLogger.css +++ b/src/plugins/messageLogger/messageLogger.css @@ -4,12 +4,12 @@ .messagelogger-deleted :is( - video, + .messagelogger-deleted-attachment, .emoji, [data-type="sticker"], - iframe, - .messagelogger-deleted-attachment, - [class|="inlineMediaEmbed"] + [class*="embedIframe"], + [class*="embedSpotify"], + [class*="imageContainer"] ) { filter: grayscale(1) !important; transition: 150ms filter ease-in-out; @@ -17,18 +17,14 @@ &[class*="hiddenMosaicItem_"] { filter: grayscale(1) blur(var(--custom-message-attachment-spoiler-blur-radius, 44px)) !important; } + + &:hover { + filter: grayscale(0) !important; + } } -.messagelogger-deleted -:is( - video, - .emoji, - [data-type="sticker"], - iframe, - .messagelogger-deleted-attachment, - [class|="inlineMediaEmbed"] -):hover { - filter: grayscale(0) !important; +.messagelogger-deleted [class*="spoilerWarning"] { + color: var(--status-danger); } .theme-dark .messagelogger-edited { diff --git a/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx b/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx index 341971ff8..02662fe97 100644 --- a/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx +++ b/src/plugins/permissionsViewer/components/RolesAndUsersPermissions.tsx @@ -157,7 +157,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea src={user.getAvatarURL(void 0, void 0, false)} /> )} - + { permission.type === PermissionType.Role ? role?.name ?? "Unknown Role" diff --git a/src/plugins/permissionsViewer/styles.css b/src/plugins/permissionsViewer/styles.css index b7e420964..2ca61025d 100644 --- a/src/plugins/permissionsViewer/styles.css +++ b/src/plugins/permissionsViewer/styles.css @@ -73,7 +73,7 @@ background-color: var(--background-modifier-selected); } -.vc-permviewer-modal-list-item > div { +.vc-permviewer-modal-list-item-text { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; diff --git a/src/plugins/reviewDB/components/BlockedUserModal.tsx b/src/plugins/reviewDB/components/BlockedUserModal.tsx index 43c81eb52..8b8271746 100644 --- a/src/plugins/reviewDB/components/BlockedUserModal.tsx +++ b/src/plugins/reviewDB/components/BlockedUserModal.tsx @@ -39,7 +39,7 @@ function BlockedUser({ user, isBusy, setIsBusy }: { user: ReviewDBUser; isBusy: return (
- + {user.username} { diff --git a/src/plugins/reviewDB/components/ReviewModal.tsx b/src/plugins/reviewDB/components/ReviewModal.tsx index 71ac021f0..1485022da 100644 --- a/src/plugins/reviewDB/components/ReviewModal.tsx +++ b/src/plugins/reviewDB/components/ReviewModal.tsx @@ -65,7 +65,7 @@ function Modal({ modalProps, modalKey, discordId, name, type }: { modalProps: an -
+
{ownReview && ( div { +.vc-rdb-modal-footer-wrapper { width: 100%; margin: 6px 16px; } -/* When input becomes disabled(while sending review), input adds unneccesary padding to left, this prevents it */ -.vc-rdb-input > div > div { - padding-left: 0 !important; -} - .vc-rdb-placeholder { margin-bottom: 4px; font-weight: bold; @@ -69,7 +64,7 @@ border-radius: 8px; } -.vc-rdb-review-comment img { +.vc-rdb-review-comment [class*="avatar"] { vertical-align: text-top; } @@ -117,13 +112,13 @@ align-items: center; } -.vc-rdb-block-modal-row img { +.vc-rdb-block-modal-avatar { border-radius: 50%; height: 2em; width: 2em; } -.vc-rdb-block-modal img::before { +.vc-rdb-block-modal-avatar::before { content: ""; display: block; width: 100%; diff --git a/src/plugins/sendTimestamps/index.tsx b/src/plugins/sendTimestamps/index.tsx index 437df1a58..57b9de0df 100644 --- a/src/plugins/sendTimestamps/index.tsx +++ b/src/plugins/sendTimestamps/index.tsx @@ -68,15 +68,16 @@ function PickerModal({ rootProps, close }: { rootProps: ModalProps, close(): voi return ( - + Timestamp Picker - + setValue(e.currentTarget.value)} @@ -86,23 +87,25 @@ function PickerModal({ rootProps, close }: { rootProps: ModalProps, close(): voi /> Timestamp Format - ({ + label: m, + value: m + })) + } + isSelected={v => v === format} + select={v => setFormat(v)} + serialize={v => v} + renderOptionLabel={o => ( +
+ {Parser.parse(formatTimestamp(time, o.value))} +
+ )} + renderOptionValue={() => rendered} + /> +
Preview diff --git a/src/plugins/sendTimestamps/styles.css b/src/plugins/sendTimestamps/styles.css index 033d5c9d5..e7efbe59e 100644 --- a/src/plugins/sendTimestamps/styles.css +++ b/src/plugins/sendTimestamps/styles.css @@ -1,4 +1,4 @@ -.vc-st-modal-content input { +.vc-st-date-picker { background-color: var(--input-background); color: var(--text-normal); width: 95%; @@ -12,35 +12,28 @@ font-size: 100%; } -.vc-st-format-label, -.vc-st-format-label span { - background-color: transparent; -} - -.vc-st-modal-content [class|="select"] { +.vc-st-format-select { margin-bottom: 1em; + + --background-modifier-accent: transparent; } -.vc-st-modal-content [class|="select"] span { - background-color: var(--input-background); +.vc-st-format-label { + --background-modifier-accent: transparent; } .vc-st-modal-header { place-content: center space-between; } -.vc-st-modal-header h1 { +.vc-st-modal-title { margin: 0; } -.vc-st-modal-header button { +.vc-st-modal-close-button { padding: 0; } .vc-st-preview-text { margin-bottom: 1em; } - -.vc-st-button svg { - transform: scale(1.1) translateY(1px); -} diff --git a/src/plugins/serverInfo/GuildInfoModal.tsx b/src/plugins/serverInfo/GuildInfoModal.tsx index 14b7e1dc8..9f2d3008d 100644 --- a/src/plugins/serverInfo/GuildInfoModal.tsx +++ b/src/plugins/serverInfo/GuildInfoModal.tsx @@ -94,6 +94,7 @@ function GuildInfoModal({ guild }: GuildProps) {
{iconUrl ? openImageModal({ @@ -170,6 +171,7 @@ function Owner(guildId: string, owner: User) { return (
openImageModal({ diff --git a/src/plugins/serverInfo/styles.css b/src/plugins/serverInfo/styles.css index 8c88e4f40..274b7d138 100644 --- a/src/plugins/serverInfo/styles.css +++ b/src/plugins/serverInfo/styles.css @@ -21,7 +21,7 @@ margin: 0.5em; } -.vc-gp-header img { +.vc-gp-icon { width: 48px; height: 48px; cursor: pointer; @@ -82,7 +82,7 @@ gap: 0.2em; } -.vc-gp-owner img { +.vc-gp-owner-avatar { height: 20px; border-radius: 50%; cursor: pointer; diff --git a/src/plugins/shikiCodeblocks.desktop/components/Code.tsx b/src/plugins/shikiCodeblocks.desktop/components/Code.tsx index 8deca5882..2794234df 100644 --- a/src/plugins/shikiCodeblocks.desktop/components/Code.tsx +++ b/src/plugins/shikiCodeblocks.desktop/components/Code.tsx @@ -84,9 +84,9 @@ export const Code = ({ } const codeTableRows = lines.map((line, i) => ( - - {i + 1} - {line} + + {i + 1} + {line} )); diff --git a/src/plugins/shikiCodeblocks.desktop/components/Highlighter.tsx b/src/plugins/shikiCodeblocks.desktop/components/Highlighter.tsx index dd1401939..2d62af6e1 100644 --- a/src/plugins/shikiCodeblocks.desktop/components/Highlighter.tsx +++ b/src/plugins/shikiCodeblocks.desktop/components/Highlighter.tsx @@ -102,7 +102,7 @@ export const Highlighter = ({ color: themeBase.plainColor, }} > - +
); } diff --git a/src/plugins/showConnections/index.tsx b/src/plugins/showConnections/index.tsx index 46629c770..f99c0be96 100644 --- a/src/plugins/showConnections/index.tsx +++ b/src/plugins/showConnections/index.tsx @@ -125,7 +125,7 @@ function CompactConnectionComponent({ connection, theme }: { connection: Connect {connection.name} {connection.verified && } - + } key={connection.id} diff --git a/src/plugins/showConnections/styles.css b/src/plugins/showConnections/styles.css index cead5201c..5bb16e0fd 100644 --- a/src/plugins/showConnections/styles.css +++ b/src/plugins/showConnections/styles.css @@ -14,6 +14,6 @@ word-break: break-all; } -.vc-sc-tooltip svg { +.vc-sc-tooltip-icon { min-width: 16px; } diff --git a/src/plugins/showHiddenChannels/components/HiddenChannelLockScreen.tsx b/src/plugins/showHiddenChannels/components/HiddenChannelLockScreen.tsx index 15cd17c46..bbe286af5 100644 --- a/src/plugins/showHiddenChannels/components/HiddenChannelLockScreen.tsx +++ b/src/plugins/showHiddenChannels/components/HiddenChannelLockScreen.tsx @@ -18,6 +18,7 @@ import { Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; +import { classes } from "@utils/misc"; import { formatDuration } from "@utils/text"; import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { EmojiStore, FluxDispatcher, GuildMemberStore, GuildStore, Parser, PermissionsBits, PermissionStore, SnowflakeUtils, Text, Timestamp, Tooltip, useEffect, useState } from "@webpack/common"; @@ -25,7 +26,7 @@ import type { Channel } from "discord-types/general"; import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "../../permissionsViewer/components/RolesAndUsersPermissions"; import { sortPermissionOverwrites } from "../../permissionsViewer/utils"; -import { settings } from ".."; +import { cl, settings } from ".."; const enum SortOrderTypes { LATEST_ACTIVITY = 0, @@ -168,19 +169,19 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) { }, [channelId]); return ( -
-
- +
+
+ -
- This is a {!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) ? "hidden" : "locked"} {ChannelTypesToChannelNames[type]} channel. +
+ This is a {!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) ? "hidden" : "locked"} {ChannelTypesToChannelNames[type]} channel {channel.isNSFW() && {({ onMouseLeave, onMouseEnter }) => ( 0 && ( -
+
{Parser.parseTopic(topic, false, { channelId })}
)} @@ -213,7 +214,6 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) { } - {lastPinTimestamp && Last message pin: } @@ -247,7 +247,7 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) { Default sort order: {SortOrderTypesToNames[defaultSortOrder]} } {defaultReactionEmoji != null && -
+
Default reaction emoji: {Parser.defaultRules[defaultReactionEmoji.emojiName ? "emoji" : "customEmoji"].react({ name: defaultReactionEmoji.emojiName @@ -258,29 +258,29 @@ function HiddenChannelLockScreen({ channel }: { channel: ExtendedChannel; }) { src: defaultReactionEmoji.emojiName ? EmojiUtils.getURL(defaultReactionEmoji.emojiName) : void 0 - }, void 0, { key: "0" })} + }, void 0, { key: 0 })}
} {channel.hasFlag(ChannelFlags.REQUIRE_TAG) && Posts on this forum require a tag to be set. } {availableTags && availableTags.length > 0 && -
+
Available tags: -
+
{availableTags.map(tag => )}
} -
-
- {Settings.plugins.PermissionsViewer.enabled && ( +
+
+ {Vencord.Plugins.isPluginEnabled("PermissionsViewer") && ( {({ onMouseLeave, onMouseEnter }) => (