diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 41e38429..bb764063 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -299,6 +299,9 @@ function runTime(token: string) { delete patch.predicate; delete patch.group; + if (!Array.isArray(patch.find)) + patch.find = [patch.find]; + if (!Array.isArray(patch.replacement)) patch.replacement = [patch.replacement]; diff --git a/src/components/VencordSettings/PatchHelperTab.tsx b/src/components/VencordSettings/PatchHelperTab.tsx index 064c872a..c08c366c 100644 --- a/src/components/VencordSettings/PatchHelperTab.tsx +++ b/src/components/VencordSettings/PatchHelperTab.tsx @@ -33,8 +33,8 @@ if (IS_DEV) { var differ = require("diff") as typeof import("diff"); } -const findCandidates = debounce(function ({ find, setModule, setError }) { - const candidates = search(find); +const findCandidates = debounce(function ({ finds, setModule, setError }) { + const candidates = search(...finds); const keys = Object.keys(candidates); const len = keys.length; if (len === 0) @@ -180,7 +180,8 @@ function ReplacementInput({ replacement, setReplacement, replacementError }) { return ( <> - replacement + {/* FormTitle adds a class if className is not set, so we set it to an empty string to prevent that */} + replacement {!isFunc && (
- Cheat Sheet + Cheat Sheet {Object.entries({ "\\i": "Special regex escape sequence that matches identifiers (varnames, classnames, etc.)", "$$": "Insert a $", @@ -220,11 +221,12 @@ function ReplacementInput({ replacement, setReplacement, replacementError }) { interface FullPatchInputProps { setFind(v: string): void; + setFinds(v: string[]): void; setMatch(v: string): void; setReplacement(v: string | ReplaceFn): void; } -function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputProps) { +function FullPatchInput({ setFind, setFinds, setMatch, setReplacement }: FullPatchInputProps) { const [fullPatch, setFullPatch] = React.useState(""); const [fullPatchError, setFullPatchError] = React.useState(""); @@ -256,7 +258,8 @@ function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputPro if (!parsed.replacement.match) throw new Error("No 'replacement.match' field"); if (!parsed.replacement.replace) throw new Error("No 'replacement.replace' field"); - setFind(parsed.find); + setFind(JSON.stringify(parsed.find)); + setFinds(parsed.find instanceof Array ? parsed.find : [parsed.find]); setMatch(parsed.replacement.match instanceof RegExp ? parsed.replacement.match.source : parsed.replacement.match); setReplacement(parsed.replacement.replace); setFullPatchError(""); @@ -266,7 +269,7 @@ function FullPatchInput({ setFind, setMatch, setReplacement }: FullPatchInputPro } return <> - Paste your full JSON patch here to fill out the fields + Paste your full JSON patch here to fill out the fields