From 68662c96255f617189411d97a9f11cabe2f5584d Mon Sep 17 00:00:00 2001 From: jamesbt365 Date: Thu, 30 Jan 2025 01:36:56 +0000 Subject: [PATCH 1/7] 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 4a7060c5980..f6ca5b45915 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 2/7] 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 642dcc29f38..e6903bcdee2 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 803cc71560e..aea57fef2a1 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 3/7] 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 0fddf472f18..1122d55bba6 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 4/7] 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 97ed1746d4e..25a46711d3d 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 5/7] 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 d4bb9c1eb98..00000000000 --- 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 6/7] 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 86ca195e01a..184b01584b6 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 75fa91470c7..f48f38e0306 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 67db12abc8b..b24f7a909bc 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 020ff67c2b7..4bdf194ce96 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 5a5d03fdb7f..49e88c42d6e 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 e344f14586e..1c90b529089 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 510d9cb3b1f..8a61351454b 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 2f4a1156e74..d689bd2af29 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 382990d06e4..09291b825cb 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 4bec9b6f90b..d5d6f4dc824 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 7/7] 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 208b327e953..a518fd93d6c 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); } });