diff --git a/package.json b/package.json index c71e1032..aa8dd622 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "equicord", "private": "true", - "version": "1.12.3", + "version": "1.12.4", "description": "The other cutest Discord client mod", "homepage": "https://github.com/Equicord/Equicord#readme", "bugs": { @@ -119,4 +119,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/src/plugins/callTimer/index.tsx b/src/plugins/callTimer/index.tsx index e27084c3..ea6d7dfb 100644 --- a/src/plugins/callTimer/index.tsx +++ b/src/plugins/callTimer/index.tsx @@ -53,7 +53,8 @@ export default definePlugin({ patches: [{ find: "renderConnectionStatus(){", replacement: { - match: /(renderConnectionStatus\(\){.+\.channel,children:)(.+?}\))(?=}\))/, + // 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 59a7da78..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(".BACKGROUND_ACCENT.css"); 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 150598c0..df99f177 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -24,7 +24,7 @@ import { getCurrentGuild, getEmojiURL } from "@utils/discord"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType, Patch } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack"; -import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, lodash, Parser, PermissionsBits, PermissionStore, StickersStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; +import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, lodash, Parser, PermissionsBits, PermissionStore, StickerStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; import type { Emoji } from "@webpack/types"; import type { Message } from "discord-types/general"; import { applyPalette, GIFEncoder, quantize } from "gifenc"; @@ -552,8 +552,8 @@ export default definePlugin({ const gifMatch = child.props.href.match(fakeNitroGifStickerRegex); if (gifMatch) { - // There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickersStore contains the id of the fake sticker - if (StickersStore.getStickerById(gifMatch[1])) return null; + // There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickerStore contains the id of the fake sticker + if (StickerStore.getStickerById(gifMatch[1])) return null; } } @@ -641,7 +641,7 @@ export default definePlugin({ url = new URL(item); } catch { } - const stickerName = StickersStore.getStickerById(imgMatch[1])?.name ?? url?.searchParams.get("name") ?? "FakeNitroSticker"; + const stickerName = StickerStore.getStickerById(imgMatch[1])?.name ?? url?.searchParams.get("name") ?? "FakeNitroSticker"; stickers.push({ format_type: 1, id: imgMatch[1], @@ -654,9 +654,9 @@ export default definePlugin({ const gifMatch = item.match(fakeNitroGifStickerRegex); if (gifMatch) { - if (!StickersStore.getStickerById(gifMatch[1])) continue; + if (!StickerStore.getStickerById(gifMatch[1])) continue; - const stickerName = StickersStore.getStickerById(gifMatch[1])?.name ?? "FakeNitroSticker"; + const stickerName = StickerStore.getStickerById(gifMatch[1])?.name ?? "FakeNitroSticker"; stickers.push({ format_type: 2, id: gifMatch[1], @@ -670,32 +670,38 @@ export default definePlugin({ }, shouldIgnoreEmbed(embed: Message["embeds"][number], message: Message) { - const contentItems = message.content.split(/\s/); - if (contentItems.length > 1 && !settings.store.transformCompoundSentence) return false; + try { + const contentItems = message.content.split(/\s/); + if (contentItems.length > 1 && !settings.store.transformCompoundSentence) return false; - switch (embed.type) { - case "image": { - if ( - !settings.store.transformCompoundSentence - && !contentItems.some(item => item === embed.url! || item.match(hyperLinkRegex)?.[1] === embed.url!) - ) return false; + switch (embed.type) { + case "image": { + const url = embed.url ?? embed.image?.url; + if (!url) return false; + if ( + !settings.store.transformCompoundSentence + && !contentItems.some(item => item === url || item.match(hyperLinkRegex)?.[1] === url) + ) return false; - if (settings.store.transformEmojis) { - if (fakeNitroEmojiRegex.test(embed.url!)) return true; - } - - if (settings.store.transformStickers) { - if (fakeNitroStickerRegex.test(embed.url!)) return true; - - const gifMatch = embed.url!.match(fakeNitroGifStickerRegex); - if (gifMatch) { - // There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickersStore contains the id of the fake sticker - if (StickersStore.getStickerById(gifMatch[1])) return true; + if (settings.store.transformEmojis) { + if (fakeNitroEmojiRegex.test(url)) return true; } - } - break; + if (settings.store.transformStickers) { + if (fakeNitroStickerRegex.test(url)) return true; + + const gifMatch = url.match(fakeNitroGifStickerRegex); + if (gifMatch) { + // There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickerStore contains the id of the fake sticker + if (StickerStore.getStickerById(gifMatch[1])) return true; + } + } + + break; + } } + } catch (e) { + new Logger("FakeNitro").error("Error in shouldIgnoreEmbed:", e); } return false; @@ -707,8 +713,8 @@ export default definePlugin({ const match = attachment.url.match(fakeNitroGifStickerRegex); if (match) { - // There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickersStore contains the id of the fake sticker - if (StickersStore.getStickerById(match[1])) return false; + // There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickerStore contains the id of the fake sticker + if (StickerStore.getStickerById(match[1])) return false; } return true; @@ -864,7 +870,7 @@ export default definePlugin({ if (!s.enableStickerBypass) break stickerBypass; - const sticker = StickersStore.getStickerById(extra.stickers?.[0]!); + const sticker = StickerStore.getStickerById(extra.stickers?.[0]!); if (!sticker) break stickerBypass; diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx index 0e8b1d21..368131fe 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(".BACKGROUND_ACCENT.css"); 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 187ad938..5192d7e7 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(".BACKGROUND_ACCENT.css"); 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 8e62a1b1..9179e436 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: "spineWithGuildIcon]:", + 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 68cbbe3a..6fd11fbc 100644 --- a/src/webpack/common/types/components.d.ts +++ b/src/webpack/common/types/components.d.ts @@ -544,3 +544,10 @@ export type Icon = ComponentType>; +export type ColorPicker = ComponentType<{ + color: number | null; + showEyeDropper?: boolean; + suggestedColors?: string[]; + label?: ReactNode; + onChange(value: number | null): void; +}>;