From b6ffb33adca2e26e728ee89becae3202d4caf65f Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Tue, 24 Jun 2025 21:25:36 -0400 Subject: [PATCH] Fix plugins for latest discord update (#3509) Co-authored-by: Etorix <92535668+EtorixDev@users.noreply.github.com> Co-authored-by: V --- src/plugins/callTimer/index.tsx | 3 +- .../clientTheme/components/Settings.tsx | 5 +- src/plugins/fakeNitro/index.tsx | 2 +- src/plugins/fakeProfileThemes/index.tsx | 95 +++++++++---------- .../pinDms/components/CreateCategoryModal.tsx | 10 +- src/plugins/typingIndicator/index.tsx | 2 +- src/webpack/common/components.ts | 3 + src/webpack/common/types/components.d.ts | 7 ++ 8 files changed, 61 insertions(+), 66 deletions(-) diff --git a/src/plugins/callTimer/index.tsx b/src/plugins/callTimer/index.tsx index bdcca777..dcab0551 100644 --- a/src/plugins/callTimer/index.tsx +++ b/src/plugins/callTimer/index.tsx @@ -75,7 +75,8 @@ export default definePlugin({ patches: [{ find: "renderConnectionStatus(){", replacement: { - match: /(renderConnectionStatus\(\){.+\.channel,children:)(.+?}\):\i)(?=}\))/, + // in renderConnectionStatus() + match: /(lineClamp:1,children:)(\i)(?=,|}\))/, replace: "$1[$2,$self.renderTimer(this.props.channel.id)]" } }], diff --git a/src/plugins/clientTheme/components/Settings.tsx b/src/plugins/clientTheme/components/Settings.tsx index f38380fa..9e7f867e 100644 --- a/src/plugins/clientTheme/components/Settings.tsx +++ b/src/plugins/clientTheme/components/Settings.tsx @@ -7,14 +7,13 @@ import { classNameFactory } from "@api/Styles"; import { ErrorCard } from "@components/ErrorCard"; import { Margins } from "@utils/margins"; -import { findByCodeLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Button, Forms, ThemeStore, useStateFromStores } from "@webpack/common"; +import { findByCodeLazy, findStoreLazy } from "@webpack"; +import { Button, ColorPicker, Forms, ThemeStore, useStateFromStores } from "@webpack/common"; import { settings } from ".."; import { relativeLuminance } from "../utils/colorUtils"; import { createOrUpdateThemeColorVars } from "../utils/styleUtils"; -const ColorPicker = findComponentByCodeLazy("#{intl::USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR}", ".BACKGROUND_PRIMARY)"); const saveClientTheme = findByCodeLazy('type:"UNSYNCED_USER_SETTINGS_UPDATE', '"system"==='); const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore"); diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index a4da103e..f362a355 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -394,7 +394,7 @@ export default definePlugin({ }, // Separate patch for allowing using custom app icons { - find: "?24:30,", + find: "getCurrentDesktopIcon(),", replacement: { match: /\i\.\i\.isPremium\(\i\.\i\.getCurrentUser\(\)\)/, replace: "true" diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx index 4c789b76..61ab1731 100644 --- a/src/plugins/fakeProfileThemes/index.tsx +++ b/src/plugins/fakeProfileThemes/index.tsx @@ -24,10 +24,9 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { classes, copyWithToast } from "@utils/misc"; -import { useAwaiter } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; -import { extractAndLoadChunksLazy, findComponentByCodeLazy } from "@webpack"; -import { Button, Flex, Forms, React, Text, UserProfileStore, UserStore, useState } from "@webpack/common"; +import { findComponentByCodeLazy } from "@webpack"; +import { Button, ColorPicker, Flex, Forms, React, Text, UserProfileStore, UserStore, useState } from "@webpack/common"; import { User } from "discord-types/general"; import { ReactElement } from "react"; import virtualMerge from "virtual-merge"; @@ -109,10 +108,8 @@ interface ProfileModalProps { isTryItOutFlow: boolean; } -const ColorPicker = findComponentByCodeLazy("#{intl::USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR}", ".BACKGROUND_PRIMARY)"); const ProfileModal = findComponentByCodeLazy("isTryItOutFlow:", "pendingThemeColors:", "pendingAvatarDecoration:", "EDIT_PROFILE_BANNER"); -const requireColorPicker = extractAndLoadChunksLazy(["#{intl::USER_SETTINGS_PROFILE_COLOR_DEFAULT_BUTTON}"], /createPromise:\(\)=>\i\.\i(\("?.+?"?\)).then\(\i\.bind\(\i,"?(.+?)"?\)\)/); export default definePlugin({ name: "FakeProfileThemes", @@ -141,8 +138,6 @@ export default definePlugin({ const [color1, setColor1] = useState(existingColors[0]); const [color2, setColor2] = useState(existingColors[1]); - const [, , loadingColorPickerChunk] = useAwaiter(requireColorPicker); - return ( Usage @@ -162,51 +157,49 @@ export default definePlugin({ className={classes(Margins.top8, Margins.bottom8)} /> Color pickers - {!loadingColorPickerChunk && ( - + + Primary + + } + onChange={(color: number) => { + setColor1(color); + }} + /> + + Accent + + } + onChange={(color: number) => { + setColor2(color); + }} + /> + - - )} + Copy 3y3 + + diff --git a/src/plugins/pinDms/components/CreateCategoryModal.tsx b/src/plugins/pinDms/components/CreateCategoryModal.tsx index 8c0fc659..e769f4b6 100644 --- a/src/plugins/pinDms/components/CreateCategoryModal.tsx +++ b/src/plugins/pinDms/components/CreateCategoryModal.tsx @@ -7,18 +7,11 @@ import { classNameFactory } from "@api/Styles"; import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModalLazy } from "@utils/modal"; import { extractAndLoadChunksLazy, findComponentByCodeLazy } from "@webpack"; -import { Button, Forms, Text, TextInput, Toasts, useMemo, useState } from "@webpack/common"; +import { Button, ColorPicker, Forms, Text, TextInput, Toasts, useMemo, useState } from "@webpack/common"; import { DEFAULT_COLOR, SWATCHES } from "../constants"; import { categoryLen, createCategory, getCategory } from "../data"; -interface ColorPickerProps { - color: number | null; - showEyeDropper?: boolean; - suggestedColors?: string[]; - onChange(value: number | null): void; -} - interface ColorPickerWithSwatchesProps { defaultColor: number; colors: number[]; @@ -29,7 +22,6 @@ interface ColorPickerWithSwatchesProps { renderCustomButton?: () => React.ReactNode; } -const ColorPicker = findComponentByCodeLazy("#{intl::USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR}", ".BACKGROUND_PRIMARY)"); const ColorPickerWithSwatches = findComponentByCodeLazy('id:"color-picker"'); export const requireSettingsMenu = extractAndLoadChunksLazy(['name:"UserSettings"'], /createPromise:.{0,20}(\i\.\i\("?.+?"?\).*?).then\(\i\.bind\(\i,"?(.+?)"?\)\).{0,50}"UserSettings"/); diff --git a/src/plugins/typingIndicator/index.tsx b/src/plugins/typingIndicator/index.tsx index e6903bcd..a5c9f49c 100644 --- a/src/plugins/typingIndicator/index.tsx +++ b/src/plugins/typingIndicator/index.tsx @@ -178,7 +178,7 @@ export default definePlugin({ // Theads { // This is the thread "spine" that shows in the left - find: "M11 9H4C2.89543 9 2 8.10457 2 7V1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1V7C0 9.20914 1.79086 11 4 11H11C11.5523 11 12 10.5523 12 10C12 9.44771 11.5523 9 11 9Z", + find: "M0 15H2c0 1.6569", replacement: { match: /mentionsCount:\i.+?null(?<=channel:(\i).+?)/, replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())" diff --git a/src/webpack/common/components.ts b/src/webpack/common/components.ts index a772c98d..bcce3cbb 100644 --- a/src/webpack/common/components.ts +++ b/src/webpack/common/components.ts @@ -65,6 +65,9 @@ export const Paginator = waitForComponent("Paginator", filters.comp export const Clickable = waitForComponent("Clickable", filters.componentByCode("this.context?this.renderNonInteractive():")); export const Avatar = waitForComponent("Avatar", filters.componentByCode(".size-1.375*")); +export const ColorPicker = waitForComponent("ColorPicker", filters.componentByCode("#{intl::USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR}", "showEyeDropper")); + + export let createScroller: (scrollbarClassName: string, fadeClassName: string, customThemeClassName: string) => t.ScrollerThin; export let scrollerClasses: Record; waitFor(filters.byCode('="ltr",orientation:', "customTheme:", "forwardRef"), m => createScroller = m); diff --git a/src/webpack/common/types/components.d.ts b/src/webpack/common/types/components.d.ts index 7a9e848b..783663cb 100644 --- a/src/webpack/common/types/components.d.ts +++ b/src/webpack/common/types/components.d.ts @@ -536,3 +536,10 @@ export type Icon = ComponentType>; +export type ColorPicker = ComponentType<{ + color: number | null; + showEyeDropper?: boolean; + suggestedColors?: string[]; + label?: ReactNode; + onChange(value: number | null): void; +}>;