From 066b872219e247bf6624d07386ada0791c336dbb Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 5 May 2024 18:56:49 +0200 Subject: [PATCH 1/6] fix webpack patch on client using discordapp.com --- src/webpack/patchWebpack.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index d2b569e8d..8dd3dba8b 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -63,7 +63,8 @@ Object.defineProperty(Function.prototype, "O", { // When using react devtools or other extensions, or even when discord loads the sentry, we may also catch their webpack here. // This ensures we actually got the right one // this.e (wreq.e) is the method for loading a chunk, and only the main webpack has it - if (new Error().stack?.includes("discord.com") && String(this.e).includes("Promise.all")) { + const { stack } = new Error(); + if ((stack?.includes("discord.com") || stack?.includes("discordapp.com")) && String(this.e).includes("Promise.all")) { logger.info("Found main WebpackRequire.onChunksLoaded"); delete (Function.prototype as any).O; From ce18000c4e403d2408ecf882568ffea90442336d Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 5 May 2024 18:58:23 +0200 Subject: [PATCH 2/6] fix webpack patch on client using discordapp.com part 2 --- src/webpack/patchWebpack.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 8dd3dba8b..d3de20727 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -121,9 +121,9 @@ Object.defineProperty(Function.prototype, "m", { set(v: any) { // When using react devtools or other extensions, we may also catch their webpack here. // This ensures we actually got the right one - const error = new Error(); - if (error.stack?.includes("discord.com")) { - logger.info("Found Webpack module factory", error.stack.match(/\/assets\/(.+?\.js)/)?.[1] ?? ""); + const { stack } = new Error(); + if (stack?.includes("discord.com") || stack?.includes("discordapp.com")) { + logger.info("Found Webpack module factory", stack.match(/\/assets\/(.+?\.js)/)?.[1] ?? ""); patchFactories(v); } From 60e6fdacfa2b07d27b69b9a0ab52a5e5ccfa689b Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 4 May 2024 23:15:33 -0300 Subject: [PATCH 3/6] Resolve PluginSettings circular deps better --- src/components/PluginSettings/index.tsx | 5 +++-- src/plugins/_api/badges/index.tsx | 8 ++------ src/plugins/_core/settings.tsx | 23 +++++++++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 33a472c1a..e6b2cf1fb 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -27,6 +27,7 @@ import PluginModal from "@components/PluginSettings/PluginModal"; import { AddonCard } from "@components/VencordSettings/AddonCard"; import { SettingsTab } from "@components/VencordSettings/shared"; import { ChangeList } from "@utils/ChangeList"; +import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import { classes, isObjectEmpty } from "@utils/misc"; @@ -38,8 +39,8 @@ import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextI import Plugins from "~plugins"; -import { startDependenciesRecursive, startPlugin, stopPlugin } from "../../plugins"; - +// Avoid circular dependency +const { startDependenciesRecursive, startPlugin, stopPlugin } = proxyLazy(() => require("../../plugins")); const cl = classNameFactory("vc-plugins-"); const logger = new Logger("PluginSettings", "#a6d189"); diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 5493d4b6a..bbccf0a11 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -23,6 +23,7 @@ import DonateButton from "@components/DonateButton"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Heart } from "@components/Heart"; +import { openContributorModal } from "@components/PluginSettings/ContributorModal"; import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { isPluginDev } from "@utils/misc"; @@ -37,12 +38,7 @@ const ContributorBadge: ProfileBadge = { image: CONTRIBUTOR_BADGE, position: BadgePosition.START, shouldShow: ({ user }) => isPluginDev(user.id), - onClick(_, { user }) { - // circular import shenanigans - const { openContributorModal } = require("@components/PluginSettings/ContributorModal") as typeof import("@components/PluginSettings/ContributorModal"); - // setImmediate is needed to run on later tick to workaround limitation in proxyLazy - setImmediate(() => openContributorModal(user)); - } + onClick: (_, { user }) => openContributorModal(user) }; let DonorBadges = {} as Record>>; diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index 1aea0d6ee..772ee9b64 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -17,6 +17,13 @@ */ import { Settings } from "@api/Settings"; +import BackupAndRestoreTab from "@components/VencordSettings/BackupAndRestoreTab"; +import CloudTab from "@components/VencordSettings/CloudTab"; +import PatchHelperTab from "@components/VencordSettings/PatchHelperTab"; +import PluginsTab from "@components/VencordSettings/PluginsTab"; +import ThemesTab from "@components/VencordSettings/ThemesTab"; +import UpdaterTab from "@components/VencordSettings/UpdaterTab"; +import VencordTab from "@components/VencordSettings/VencordTab"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { React } from "@webpack/common"; @@ -36,7 +43,7 @@ export default definePlugin({ match: /\[\(0,.{1,3}\.jsxs?\)\((.{1,10}),(\{[^{}}]+\{.{0,20}.versionHash,.+?\})\)," "/, replace: (m, component, props) => { props = props.replace(/children:\[.+\]/, ""); - return `${m},Vencord.Plugins.plugins.Settings.makeInfoElements(${component}, ${props})`; + return `${m},$self.makeInfoElements(${component}, ${props})`; } } ] @@ -77,43 +84,43 @@ export default definePlugin({ { section: "VencordSettings", label: "Vencord", - element: require("@components/VencordSettings/VencordTab").default, + element: VencordTab, className: "vc-settings" }, { section: "VencordPlugins", label: "Plugins", - element: require("@components/VencordSettings/PluginsTab").default, + element: PluginsTab, className: "vc-plugins" }, { section: "VencordThemes", label: "Themes", - element: require("@components/VencordSettings/ThemesTab").default, + element: ThemesTab, className: "vc-themes" }, !IS_UPDATER_DISABLED && { section: "VencordUpdater", label: "Updater", - element: require("@components/VencordSettings/UpdaterTab").default, + element: UpdaterTab, className: "vc-updater" }, { section: "VencordCloud", label: "Cloud", - element: require("@components/VencordSettings/CloudTab").default, + element: CloudTab, className: "vc-cloud" }, { section: "VencordSettingsSync", label: "Backup & Restore", - element: require("@components/VencordSettings/BackupAndRestoreTab").default, + element: BackupAndRestoreTab, className: "vc-backup-restore" }, IS_DEV && { section: "VencordPatchHelper", label: "Patch Helper", - element: require("@components/VencordSettings/PatchHelperTab").default, + element: PatchHelperTab, className: "vc-patch-helper" }, ...this.customSections.map(func => func(SectionTypes)), From a090872d8f8b1ccb201b716bc657a90f745f132d Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 4 May 2024 23:15:46 -0300 Subject: [PATCH 4/6] ImplicitRelationships: Properly test find --- src/plugins/implicitRelationships/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index 15165d64a..4faad2a9d 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -19,11 +19,12 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByProps, findStoreLazy } from "@webpack"; +import { findByPropsLazy, findStoreLazy } from "@webpack"; import { ChannelStore, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common"; import { Settings } from "Vencord"; const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore"); +const { FriendsSections } = findByPropsLazy("FriendsSections"); interface UserAffinity { user_id: string; @@ -181,7 +182,6 @@ export default definePlugin({ }, start() { - const { FriendsSections } = findByProps("FriendsSections"); FriendsSections.IMPLICIT = "IMPLICIT"; } }); From 45c1e42ce412bdf732b5f21073f6d4d8a00f3528 Mon Sep 17 00:00:00 2001 From: Fafa <87046111+Faf4a@users.noreply.github.com> Date: Sun, 5 May 2024 06:42:15 +0200 Subject: [PATCH 5/6] ReviewDB: Fix context menus being added to folders (#2416) --- src/plugins/reviewDB/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index bcd0f163f..e73bce82c 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -36,6 +36,7 @@ import { settings } from "./settings"; import { showToast } from "./utils"; const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => { + if (!guild) return; children.push( Date: Sun, 5 May 2024 20:15:01 +1200 Subject: [PATCH 6/6] ImageLink: Fix embed showing in gifs (#2417) --- src/plugins/imageLink/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/imageLink/index.ts b/src/plugins/imageLink/index.ts index 73a977fa9..5e8dd23e9 100644 --- a/src/plugins/imageLink/index.ts +++ b/src/plugins/imageLink/index.ts @@ -10,15 +10,15 @@ import definePlugin from "@utils/types"; export default definePlugin({ name: "ImageLink", description: "Never hide image links in messages, even if it's the only content", - authors: [Devs.Kyuuhachi], + authors: [Devs.Kyuuhachi, Devs.Sqaaakoi], patches: [ { - find: "isEmbedInline:function()", + find: "unknownUserMentionPlaceholder:", replacement: { - match: /(?<=isEmbedInline:function\(\)\{return )\i(?=\})/, - replace: "()=>false", - }, - }, - ], + match: /\(0,\i\.isEmbedInline\)\(\i\)/, + replace: "false", + } + } + ] });