This commit is contained in:
Ulysia 2025-03-14 15:35:59 +01:00
commit 92406bd718
15 changed files with 160 additions and 26 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "vencord", "name": "vencord",
"private": "true", "private": "true",
"version": "1.11.5", "version": "1.11.6",
"description": "The cutest Discord client mod", "description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme", "homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": { "bugs": {

View file

@ -65,12 +65,12 @@ export default definePlugin({
{ {
find: ".FULL_SIZE]:26", find: ".FULL_SIZE]:26",
replacement: { replacement: {
match: /(?<=(\i)=\(0,\i\.\i\)\(\i\);)return 0===\i.length\?/, match: /(?=;return 0===(\i)\.length\?)(?<=(\i)\.useMemo.+?)/,
replace: "$1.unshift(...$self.getBadges(arguments[0].displayProfile));$&" replace: ";$1=$2.useMemo(()=>[...$self.getBadges(arguments[0].displayProfile),...$1],[$1])"
} }
}, },
{ {
find: ".description,delay:", find: "#{intl::PROFILE_USER_BADGES}",
replacement: [ replacement: [
{ {
match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/, match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/,

View file

@ -17,7 +17,7 @@ export default definePlugin({
find: '"sticker")', find: '"sticker")',
replacement: { replacement: {
// FIXME(Bundler change related): Remove old compatiblity once enough time has passed // FIXME(Bundler change related): Remove old compatiblity once enough time has passed
match: /return\((!)?\i\.\i(?:\|\||&&)(?=\(\i\.isDM.+?(\i)\.push)/, match: /return\((!)?\i\.\i(?:\|\||&&)(?=\(.+?(\i)\.push)/,
replace: (m, not, children) => not replace: (m, not, children) => not
? `${m}(Vencord.Api.ChatButtons._injectButtons(${children},arguments[0]),true)&&` ? `${m}(Vencord.Api.ChatButtons._injectButtons(${children},arguments[0]),true)&&`
: `${m}(Vencord.Api.ChatButtons._injectButtons(${children},arguments[0]),false)||` : `${m}(Vencord.Api.ChatButtons._injectButtons(${children},arguments[0]),false)||`

View file

@ -14,11 +14,18 @@ export default definePlugin({
description: "Allows you to omit either width or height when opening an image modal", description: "Allows you to omit either width or height when opening an image modal",
patches: [ patches: [
{ {
find: "SCALE_DOWN:", find: ".contain,SCALE_DOWN:",
replacement: { replacement: {
match: /(?<="IMAGE"===\i\?)\i(?=\?)/, match: /(?<="IMAGE"===\i\?)\i(?=\?)/,
replace: "true" replace: "true"
} }
},
{
find: ".dimensionlessImage,",
replacement: {
match: /(?<="IMAGE"===\i&&\(\i=)\i(?=\?)/,
replace: "true"
}
} }
] ]
}); });

View file

@ -73,7 +73,7 @@ export default definePlugin({
group: true, group: true,
replacement: [ replacement: [
{ {
match: /(?<=\.AVATAR_SIZE\);)/, match: /(?<=\.AVATAR_SIZE\).{0,100};)(?=return)/,
replace: "$self.useAccountPanelRef();" replace: "$self.useAccountPanelRef();"
}, },
{ {

View file

@ -5,8 +5,11 @@
*/ */
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import { ErrorBoundary, Flex } from "@components/index";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType, StartAt } from "@utils/types"; import { Margins } from "@utils/margins";
import definePlugin, { defineDefault, OptionType, StartAt } from "@utils/types";
import { Checkbox, Forms, Text } from "@webpack/common";
const Noop = () => { }; const Noop = () => { };
const NoopLogger = { const NoopLogger = {
@ -24,6 +27,48 @@ const NoopLogger = {
const logAllow = new Set(); const logAllow = new Set();
interface AllowLevels {
error: boolean;
warn: boolean;
trace: boolean;
log: boolean;
info: boolean;
debug: boolean;
}
interface AllowLevelSettingProps {
settingKey: keyof AllowLevels;
}
function AllowLevelSetting({ settingKey }: AllowLevelSettingProps) {
const { allowLevel } = settings.use(["allowLevel"]);
const value = allowLevel[settingKey];
return (
<Checkbox
value={value}
onChange={(_, newValue) => settings.store.allowLevel[settingKey] = newValue}
size={20}
>
<Text variant="text-sm/normal">{settingKey[0].toUpperCase() + settingKey.slice(1)}</Text>
</Checkbox>
);
}
const AllowLevelSettings = ErrorBoundary.wrap(() => {
return (
<Forms.FormSection>
<Forms.FormTitle tag="h3">Filter List</Forms.FormTitle>
<Forms.FormText className={Margins.bottom8} type={Forms.FormText.Types.DESCRIPTION}>Always allow loggers of these types</Forms.FormText>
<Flex flexDirection="row">
{Object.keys(settings.store.allowLevel).map(key => (
<AllowLevelSetting key={key} settingKey={key as keyof AllowLevels} />
))}
</Flex>
</Forms.FormSection>
);
});
const settings = definePluginSettings({ const settings = definePluginSettings({
disableLoggers: { disableLoggers: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
@ -45,6 +90,18 @@ const settings = definePluginSettings({
logAllow.clear(); logAllow.clear();
newVal.split(";").map(x => x.trim()).forEach(logAllow.add.bind(logAllow)); newVal.split(";").map(x => x.trim()).forEach(logAllow.add.bind(logAllow));
} }
},
allowLevel: {
type: OptionType.COMPONENT,
component: AllowLevelSettings,
default: defineDefault<AllowLevels>({
error: true,
warn: false,
trace: false,
log: false,
info: false,
debug: false
})
} }
}); });
@ -61,8 +118,9 @@ export default definePlugin({
}, },
NoopLogger: () => NoopLogger, NoopLogger: () => NoopLogger,
shouldLog(logger: string) {
return logAllow.has(logger); shouldLog(logger: string, level: keyof AllowLevels) {
return logAllow.has(logger) || settings.store.allowLevel[level] === true;
}, },
patches: [ patches: [
@ -136,13 +194,13 @@ export default definePlugin({
replace: "" replace: ""
} }
}, },
// Patches discords generic logger function // Patches Discord generic logger function
{ {
find: "Σ:", find: "Σ:",
predicate: () => settings.store.disableLoggers, predicate: () => settings.store.disableLoggers,
replacement: { replacement: {
match: /(?<=&&)(?=console)/, match: /(?<=&&)(?=console)/,
replace: "$self.shouldLog(arguments[0])&&" replace: "$self.shouldLog(arguments[0],arguments[1])&&"
} }
}, },
{ {

View file

@ -25,11 +25,14 @@ import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/moda
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findByCodeLazy, findStoreLazy } from "@webpack"; import { findByCodeLazy, findStoreLazy } from "@webpack";
import { Constants, EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common"; import { Constants, EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionsBits, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
import { Guild } from "discord-types/general";
import { Promisable } from "type-fest"; import { Promisable } from "type-fest";
const StickersStore = findStoreLazy("StickersStore"); const StickersStore = findStoreLazy("StickersStore");
const uploadEmoji = findByCodeLazy(".GUILD_EMOJIS(", "EMOJI_UPLOAD_START"); const uploadEmoji = findByCodeLazy(".GUILD_EMOJIS(", "EMOJI_UPLOAD_START");
const getGuildMaxEmojiSlots = findByCodeLazy(".additionalEmojiSlots") as (guild: Guild) => number;
interface Sticker { interface Sticker {
t: "Sticker"; t: "Sticker";
description: string; description: string;
@ -125,7 +128,7 @@ function getGuildCandidates(data: Data) {
const { isAnimated } = data as Emoji; const { isAnimated } = data as Emoji;
const emojiSlots = g.getMaxEmojiSlots(); const emojiSlots = getGuildMaxEmojiSlots(g);
const { emojis } = EmojiStore.getGuilds()[g.id]; const { emojis } = EmojiStore.getGuilds()[g.id];
let count = 0; let count = 0;

View file

@ -95,7 +95,7 @@ export default definePlugin({
{ {
find: "#{intl::ACCOUNT_SPEAKING_WHILE_MUTED}", find: "#{intl::ACCOUNT_SPEAKING_WHILE_MUTED}",
replacement: { replacement: {
match: /this\.renderNameZone\(\).+?children:\[/, match: /className:\i\.buttons,.{0,50}children:\[/,
replace: "$&$self.GameActivityToggleButton()," replace: "$&$self.GameActivityToggleButton(),"
} }
} }

View file

@ -165,8 +165,35 @@ export default definePlugin({
{ {
find: ".contain,SCALE_DOWN:", find: ".contain,SCALE_DOWN:",
replacement: { replacement: {
match: /\.slide,\i\),/g, match: /imageClassName:/,
replace: `$&id:"${ELEMENT_ID}",` replace: `id:"${ELEMENT_ID}",$&`
}
},
{
find: ".dimensionlessImage,",
replacement: [
{
match: /className:\i\.media,/,
replace: `id:"${ELEMENT_ID}",$&`
},
{
// This patch needs to be above the next one as it uses the zoomed class as an anchor
match: /\.zoomed]:.+?,(?=children:)/,
replace: "$&onClick:()=>{},"
},
{
match: /className:\i\(\)\(\i\.wrapper,.+?}\),/,
replace: ""
},
]
},
// Make media viewer options not hide when zoomed in with the default Discord feature
{
find: '="FOCUS_SENSITIVE",',
replacement: {
match: /(?<=\.hidden]:)\i/,
replace: "false"
} }
}, },

View file

@ -96,6 +96,6 @@
.vc-shiki-root .vc-shiki-table-cell:last-child { .vc-shiki-root .vc-shiki-table-cell:last-child {
padding-left: 8px; padding-left: 8px;
overflow-wrap: break-word; overflow-wrap: anywhere;
width: 100%; width: 100%;
} }

View file

@ -50,8 +50,8 @@ export default definePlugin({
{ {
find: '?"@":""', find: '?"@":""',
replacement: { replacement: {
match: /(?<=onContextMenu:\i,children:).*?\)}/, match: /(?<=children:)\(\i\?"@":""\)\+\i(?=,|\})/,
replace: "$self.renderUsername(arguments[0])}" replace: "$self.renderUsername(arguments[0])"
} }
}, },
], ],

View file

@ -26,7 +26,7 @@ import { MessageDecorationFactory } from "@api/MessageDecorations";
import { MessageClickListener, MessageEditListener, MessageSendListener } from "@api/MessageEvents"; import { MessageClickListener, MessageEditListener, MessageSendListener } from "@api/MessageEvents";
import { MessagePopoverButtonFactory } from "@api/MessagePopover"; import { MessagePopoverButtonFactory } from "@api/MessagePopover";
import { FluxEvents } from "@webpack/types"; import { FluxEvents } from "@webpack/types";
import { JSX } from "react"; import { ReactNode } from "react";
import { Promisable } from "type-fest"; import { Promisable } from "type-fest";
// exists to export default definePlugin({...}) // exists to export default definePlugin({...})
@ -202,6 +202,10 @@ export const enum ReporterTestable {
FluxEvents = 1 << 4 FluxEvents = 1 << 4
} }
export function defineDefault<T = any>(value: T) {
return value;
}
export const enum OptionType { export const enum OptionType {
STRING, STRING,
NUMBER, NUMBER,
@ -334,7 +338,8 @@ export interface IPluginOptionComponentProps {
export interface PluginSettingComponentDef { export interface PluginSettingComponentDef {
type: OptionType.COMPONENT; type: OptionType.COMPONENT;
component: (props: IPluginOptionComponentProps) => JSX.Element; component: (props: IPluginOptionComponentProps) => ReactNode | Promise<ReactNode>;
default?: any;
} }
/** Maps a `PluginSettingDef` to its value type */ /** Maps a `PluginSettingDef` to its value type */

View file

@ -38,6 +38,7 @@ export const Forms = {
export const Card = waitForComponent<t.Card>("Card", filters.componentByCode(".editable),", ".outline:")); export const Card = waitForComponent<t.Card>("Card", filters.componentByCode(".editable),", ".outline:"));
export const Button = waitForComponent<t.Button>("Button", filters.componentByCode("#{intl::A11Y_LOADING_STARTED}))),!1")); export const Button = waitForComponent<t.Button>("Button", filters.componentByCode("#{intl::A11Y_LOADING_STARTED}))),!1"));
export const Switch = waitForComponent<t.Switch>("Switch", filters.componentByCode(".labelRow,ref:", ".disabledText")); export const Switch = waitForComponent<t.Switch>("Switch", filters.componentByCode(".labelRow,ref:", ".disabledText"));
export const Checkbox = waitForComponent<t.Checkbox>("Checkbox", filters.componentByCode(".checkboxWrapperDisabled:"));
const Tooltips = mapMangledModuleLazy(".tooltipTop,bottom:", { const Tooltips = mapMangledModuleLazy(".tooltipTop,bottom:", {
Tooltip: filters.componentByCode("this.renderTooltip()]"), Tooltip: filters.componentByCode("this.renderTooltip()]"),
@ -94,7 +95,7 @@ waitFor(m => {
export const MaskedLink = waitForComponent<t.MaskedLink>("MaskedLink", filters.componentByCode("MASKED_LINK)")); export const MaskedLink = waitForComponent<t.MaskedLink>("MaskedLink", filters.componentByCode("MASKED_LINK)"));
export const Timestamp = waitForComponent<t.Timestamp>("Timestamp", filters.componentByCode("#{intl::MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL}")); export const Timestamp = waitForComponent<t.Timestamp>("Timestamp", filters.componentByCode("#{intl::MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL}"));
export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]); export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]);
export const OAuth2AuthorizeModal = waitForComponent("OAuth2AuthorizeModal", filters.componentByCode(".authorize),children:", ".contentBackground")); export const OAuth2AuthorizeModal = waitForComponent("OAuth2AuthorizeModal", filters.componentByCode(".authorize,children:", ".contentBackground"));
export const Animations = mapMangledModuleLazy(".assign({colorNames:", { export const Animations = mapMangledModuleLazy(".assign({colorNames:", {
Transition: filters.componentByCode('["items","children"]', ",null,"), Transition: filters.componentByCode('["items","children"]', ",null,"),

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import type { ComponentPropsWithRef, ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, JSX, KeyboardEvent, MouseEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react"; import type { ComponentPropsWithRef, ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, JSX, KeyboardEvent, MouseEvent, PointerEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react";
export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code"; export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code";
@ -197,6 +197,36 @@ export type Switch = ComponentType<PropsWithChildren<{
tooltipNote?: ReactNode; tooltipNote?: ReactNode;
}>>; }>>;
export type CheckboxAligns = {
CENTER: "center";
TOP: "top";
};
export type CheckboxTypes = {
DEFAULT: "default";
INVERTED: "inverted";
GHOST: "ghost";
ROW: "row";
};
export type Checkbox = ComponentType<PropsWithChildren<{
value: boolean;
onChange(event: PointerEvent, value: boolean): void;
align?: "center" | "top";
disabled?: boolean;
displayOnly?: boolean;
readOnly?: boolean;
reverse?: boolean;
shape?: string;
size?: number;
type?: "default" | "inverted" | "ghost" | "row";
}>> & {
Shapes: Record<"BOX" | "ROUND" | "SMALL_BOX", string>;
Aligns: CheckboxAligns;
Types: CheckboxTypes;
};
export type Timestamp = ComponentType<PropsWithChildren<{ export type Timestamp = ComponentType<PropsWithChildren<{
timestamp: Date; timestamp: Date;
isEdited?: boolean; isEdited?: boolean;

View file

@ -142,9 +142,12 @@ export const UploadHandler = {
promptToUpload: findByCodeLazy("#{intl::ATTACHMENT_TOO_MANY_ERROR_TITLE}") as (files: File[], channel: Channel, draftType: Number) => void promptToUpload: findByCodeLazy("#{intl::ATTACHMENT_TOO_MANY_ERROR_TITLE}") as (files: File[], channel: Channel, draftType: Number) => void
}; };
export const ApplicationAssetUtils = findByPropsLazy("fetchAssetIds", "getAssetImage") as { export const ApplicationAssetUtils = mapMangledModuleLazy("getAssetImage: size must === [", {
fetchAssetIds: (applicationId: string, e: string[]) => Promise<string[]>; fetchAssetIds: filters.byCode('.startsWith("http:")', ".dispatch({"),
}; getAssetFromImageURL: filters.byCode("].serialize(", ',":"'),
getAssetImage: filters.byCode("getAssetImage: size must === ["),
getAssets: filters.byCode(".assets")
});
export const Clipboard: t.Clipboard = mapMangledModuleLazy('queryCommandEnabled("copy")', { export const Clipboard: t.Clipboard = mapMangledModuleLazy('queryCommandEnabled("copy")', {
copy: filters.byCode(".copy("), copy: filters.byCode(".copy("),