diff options
author | Vendicated <vendicated@riseup.net> | 2022-09-27 16:57:46 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-09-27 16:57:46 +0200 |
commit | 572bfcee6ce343c6bf9d69262576de4e57c01500 (patch) | |
tree | a0cdf027c41152a45183e80344d054071684a064 /src/webpack | |
parent | 6398dd25d20e6bc3e02425b709233066baf64e0c (diff) | |
download | Vencord-572bfcee6ce343c6bf9d69262576de4e57c01500.tar.gz Vencord-572bfcee6ce343c6bf9d69262576de4e57c01500.tar.bz2 Vencord-572bfcee6ce343c6bf9d69262576de4e57c01500.zip |
Fix Settings UI
Diffstat (limited to 'src/webpack')
-rw-r--r-- | src/webpack/common.tsx (renamed from src/webpack/common.ts) | 29 | ||||
-rw-r--r-- | src/webpack/webpack.ts | 10 |
2 files changed, 24 insertions, 15 deletions
diff --git a/src/webpack/common.ts b/src/webpack/common.tsx index 525a678..f3cb018 100644 --- a/src/webpack/common.ts +++ b/src/webpack/common.tsx @@ -1,5 +1,5 @@ import { startAll } from "../plugins"; -import { waitFor, filters } from './webpack'; +import { waitFor, filters, findByProps } from './webpack'; import type Components from "discord-types/components"; import type Stores from "discord-types/stores"; import type Other from "discord-types/other"; @@ -7,12 +7,9 @@ import type Other from "discord-types/other"; export let FluxDispatcher: Other.FluxDispatcher; export let React: typeof import("react"); export let UserStore: Stores.UserStore; -export let Forms: any; +export let Forms: any = {}; export let Button: any; -export let ButtonProps: any; export let Switch: any; -export let Flex: Components.Flex; -export let Card: Components.Card; export let Tooltip: Components.Tooltip; waitFor("useState", m => React = m); @@ -25,12 +22,16 @@ waitFor(["dispatch", "subscribe"], m => { m.subscribe("CONNECTION_OPEN", cb); }); waitFor(["getCurrentUser", "initialize"], m => UserStore = m); -waitFor("FormSection", m => Forms = m); -waitFor(["ButtonLooks", "default"], m => { - Button = m.default; - ButtonProps = m; -}); -waitFor(filters.byDisplayName("SwitchItem"), m => Switch = m.default); -waitFor(filters.byDisplayName("Flex"), m => Flex = m.default); -waitFor(filters.byDisplayName("Card"), m => Card = m.default); -waitFor(filters.byDisplayName("Tooltip"), m => Tooltip = m.default); +waitFor(["Hovers", "Looks", "Sizes"], m => Button = m); +waitFor(filters.byCode("helpdeskArticleId"), m => Switch = m); +waitFor(["Positions", "Colors"], m => Tooltip = m); + +waitFor(m => m.Tags && filters.byCode("errorSeparator")(m), m => Forms.FormTitle = m); +waitFor(m => m.Tags && filters.byCode("titleClassName", "sectionTitle")(m), m => Forms.FormSection = m); +waitFor(m => m.Types?.INPUT_PLACEHOLDER, m => Forms.FormText = m); + +waitFor(m => { + if (typeof m !== "function") return false; + const s = m.toString(); + return s.length < 200 && s.includes("divider"); +}, m => Forms.FormDivider = m); diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index a1fd2fb..b8f10e4 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -10,7 +10,15 @@ export const filters = { props.length === 1 ? m => m[props[0]] !== void 0 : m => props.every(p => m[p] !== void 0), - byDisplayName: (deezNuts: string): FilterFn => m => m.default?.displayName === deezNuts + byDisplayName: (deezNuts: string): FilterFn => m => m.default?.displayName === deezNuts, + byCode: (...code: string[]): FilterFn => m => { + if (typeof m !== "function") return false; + const s = Function.prototype.toString.call(m); + for (const c of code) { + if (!s.includes(c)) return false; + } + return true; + } }; export const subscriptions = new Map<FilterFn, CallbackFn>(); |