From 38c490533b72a3da113b0cd0b802b8310aef2d95 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 10 Feb 2026 01:30:30 +0100 Subject: [PATCH] remove some legacy code --- src/plugins/_core/settings.tsx | 119 --------------------------------- src/plugins/decor/index.tsx | 14 ++-- src/webpack/patchWebpack.ts | 10 ++- 3 files changed, 11 insertions(+), 132 deletions(-) diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index 0c61e54c3..55d6d7d18 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -20,7 +20,6 @@ import { definePluginSettings } from "@api/Settings"; import { BackupRestoreIcon, CloudIcon, MainSettingsIcon, PaintbrushIcon, PatchHelperIcon, PlaceholderIcon, PluginsIcon, UpdaterIcon, VesktopSettingsIcon } from "@components/Icons"; import { BackupAndRestoreTab, CloudTab, PatchHelperTab, PluginsTab, ThemesTab, UpdaterTab, VencordTab } from "@components/settings/tabs"; import { Devs } from "@utils/constants"; -import { getIntlMessage } from "@utils/discord"; import { isTruthy } from "@utils/guards"; import definePlugin, { IconProps, OptionType } from "@utils/types"; import { waitFor } from "@webpack"; @@ -135,19 +134,6 @@ export default definePlugin({ } ] }, - { - find: ".SEARCH_NO_RESULTS&&0===", - replacement: [ - { - match: /(?<=section:(.{0,50})\.DIVIDER\}\))([,;])(?=.{0,200}(\i)\.push.{0,100}label:(\i)\.header)/, - replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}` - }, - { - match: /({(?=.+?function (\i).{0,160}(\i)=\i\.useMemo.{0,140}return \i\.useMemo\(\(\)=>\i\(\3).+?\(\)=>)\2/, - replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})` - } - ] - }, { find: "#{intl::USER_SETTINGS_ACTIONS_MENU_LABEL}", replacement: { @@ -325,111 +311,6 @@ export default definePlugin({ customSections: [] as ((SectionTypes: SectionTypes) => any)[], customEntries: [] as EntryOptions[], - makeSettingsCategories(SectionTypes: SectionTypes) { - return [ - { - section: SectionTypes.HEADER, - label: "Vencord", - className: "vc-settings-header" - }, - { - section: "VencordSettings", - label: "Vencord", - element: VencordTab, - className: "vc-settings" - }, - { - section: "VencordPlugins", - label: "Plugins", - element: PluginsTab, - className: "vc-plugins" - }, - { - section: "VencordThemes", - label: "Themes", - element: ThemesTab, - className: "vc-themes" - }, - !IS_UPDATER_DISABLED && { - section: "VencordUpdater", - label: "Updater", - element: UpdaterTab, - className: "vc-updater" - }, - { - section: "VencordCloud", - label: "Cloud", - element: CloudTab, - className: "vc-cloud" - }, - { - section: "VencordBackupAndRestore", - label: "Backup & Restore", - element: BackupAndRestoreTab, - className: "vc-backup-restore" - }, - IS_DEV && { - section: "VencordPatchHelper", - label: "Patch Helper", - element: PatchHelperTab, - className: "vc-patch-helper" - }, - ...this.customSections.map(func => func(SectionTypes)), - { - section: SectionTypes.DIVIDER - } - ].filter(Boolean); - }, - - isRightSpot({ header, settings: s }: { header?: string; settings?: string[]; }) { - const firstChild = s?.[0]; - // lowest two elements... sanity backup - if (firstChild === "LOGOUT" || firstChild === "SOCIAL_LINKS") return true; - - const { settingsLocation } = settings.store; - - if (settingsLocation === "bottom") return firstChild === "LOGOUT"; - if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG"; - - if (!header) return; - - try { - const names: Record, string> = { - top: getIntlMessage("USER_SETTINGS"), - aboveNitro: getIntlMessage("BILLING_SETTINGS"), - belowNitro: getIntlMessage("APP_SETTINGS"), - aboveActivity: getIntlMessage("ACTIVITY_SETTINGS") - }; - - if (!names[settingsLocation] || names[settingsLocation].endsWith("_SETTINGS")) - return firstChild === "PREMIUM"; - - return header === names[settingsLocation]; - } catch { - return firstChild === "PREMIUM"; - } - }, - - patchedSettings: new WeakSet(), - - addSettings(elements: any[], element: { header?: string; settings: string[]; }, sectionTypes: SectionTypes) { - if (this.patchedSettings.has(elements) || !this.isRightSpot(element)) return; - - this.patchedSettings.add(elements); - - elements.push(...this.makeSettingsCategories(sectionTypes)); - }, - - wrapSettingsHook(originalHook: (...args: any[]) => Record[]) { - return (...args: any[]) => { - const elements = originalHook(...args); - if (!this.patchedSettings.has(elements)) - elements.unshift(...this.makeSettingsCategories(FallbackSectionTypes)); - - return elements; - }; - }, - get electronVersion() { return VencordNative.native.getVersions().electron || window.legcord?.electron || null; }, diff --git a/src/plugins/decor/index.tsx b/src/plugins/decor/index.tsx index 854f9062c..abf5ea460 100644 --- a/src/plugins/decor/index.tsx +++ b/src/plugins/decor/index.tsx @@ -102,16 +102,10 @@ export default definePlugin({ "#{intl::ayozFl::raw}", // Avatar preview ].map(find => ({ find, - replacement: [ - { - match: /(?<=userValue.{0,25}void 0:)((\i)\.avatarDecoration)/, - replace: "$self.useUserDecorAvatarDecoration($2)??$1" - }, - { - match: /(?<=userValue:)((\i(?:\.author)?)\?\.avatarDecoration)/, - replace: "$self.useUserDecorAvatarDecoration($2)??$1" - } - ] + replacement: { + match: /(?<=userValue:)((\i(?:\.author)?)\?\.avatarDecoration)/, + replace: "$self.useUserDecorAvatarDecoration($2)??$1" + } })), // Patch avatar decoration preview to display Decor avatar decorations as if they are purchased { diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 1eeb10ed3..c6eece366 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -599,10 +599,14 @@ function patchFactory(moduleId: PropertyKey, originalFactory: AnyModuleFactory): markedAsPatched = true; } } catch (err) { - logger.error(`Patch by ${patch.plugin} errored (Module id is ${String(moduleId)}): ${replacement.match}\n`, err); + // FIXME: Maybe fix this properly + const shouldSuppressError = patch.plugin === "ContextMenuAPI" && err instanceof SyntaxError && err.message.includes("arguments"); + if (!shouldSuppressError) { + logger.error(`Patch by ${patch.plugin} errored (Module id is ${String(moduleId)}): ${replacement.match}\n`, err); - if (IS_DEV) { - diffErroredPatch(code, lastCode, lastCode.match(replacement.match)!); + if (IS_DEV) { + diffErroredPatch(code, lastCode, lastCode.match(replacement.match)!); + } } if (markedAsPatched) {