From 8ba9c96f2075f5245a9fec369046559d6a1e107c Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 11 Nov 2022 00:11:44 +0100 Subject: Fix most plugins --- src/plugins/pronoundb/index.ts | 6 +-- src/plugins/reverseImageSearch.tsx | 2 +- src/plugins/settings.ts | 70 -------------------------------- src/plugins/settings.tsx | 75 +++++++++++++++++++++++++++++++++++ src/plugins/spotifyControls/index.tsx | 2 +- 5 files changed, 80 insertions(+), 75 deletions(-) delete mode 100644 src/plugins/settings.ts create mode 100644 src/plugins/settings.tsx (limited to 'src/plugins') diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 68fa265..5dfeda5 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -38,7 +38,7 @@ export default definePlugin({ { find: "showCommunicationDisabledStyles", replacement: { - match: /(?<=return\s+\w{1,3}\.createElement\(.+!\w{1,3}&&)(\w{1,3}.createElement\(.+?\{.+?\}\))/, + match: /(?<=return\s*\(0,\w{1,3}\.jsxs?\)\(.+!\w{1,3}&&)(\(0,\w{1,3}.jsxs?\)\(.+?\{.+?\}\))/, replace: "[$1, Vencord.Plugins.plugins.PronounDB.PronounsChatComponent(e)]" } }, @@ -46,8 +46,8 @@ export default definePlugin({ { find: ".headerTagUsernameNoNickname", replacement: { - match: /""!==(.{1,2})&&(r\.createElement\(r\.Fragment.+?\.Messages\.USER_POPOUT_PRONOUNS.+?pronounsText.+?\},\1\)\))/, - replace: (_, __, fragment) => `Vencord.Plugins.plugins.PronounDB.PronounsProfileWrapper(e, ${fragment})` + match: /(?<=""!==(.{1,2})&&).+?children:\1.+?(?=,)/, + replace: "Vencord.Plugins.plugins.PronounDB.PronounsProfileWrapper(e, $1)" } } ], diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index 3bcefba..cbe72d8 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -36,7 +36,7 @@ export default definePlugin({ patches: [{ find: "open-native-link", replacement: { - match: /key:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\}\)/, + match: /id:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\},"open-native-link"\)/, replace: (m, src) => `${m},Vencord.Plugins.plugins.ReverseImageSearch.makeMenu(${src}, arguments[2])` } diff --git a/src/plugins/settings.ts b/src/plugins/settings.ts deleted file mode 100644 index f8ef7d8..0000000 --- a/src/plugins/settings.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and Megumin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import gitHash from "~git-hash"; - -import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; - -export default definePlugin({ - name: "Settings", - description: "Adds Settings UI and debug info", - authors: [Devs.Ven, Devs.Megu], - required: true, - patches: [{ - find: "().versionHash", - replacement: [ - { - match: /\w\.createElement\(.{1,2}.Fragment,.{0,30}\{[^}]+\},"Host ".+?\):null/, - replace: m => { - const idx = m.indexOf("Host") - 1; - const template = m.slice(0, idx); - const additionalInfo = IS_WEB - ? " (Web)" - : IS_STANDALONE - ? " (Standalone)" - : ""; - - let r = `${m}, ${template}"Vencord ", "${gitHash}${additionalInfo}"), " ")`; - if (!IS_WEB) { - r += `,${template} "Electron ",VencordNative.getVersions().electron)," "),`; - r += `${template} "Chrome ",VencordNative.getVersions().chrome)," ")`; - } - return r; - } - } - ] - }, { - find: "Messages.ACTIVITY_SETTINGS", - replacement: { - match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/, - replace: (m, mod) => { - const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater},' : ""; - const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"PatchHelper",element:Vencord.Components.PatchHelper},' : ""; - return ( - `{section:${mod}.ID.HEADER,label:"Vencord"},` + - '{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},' + - '{section:"VencordPlugins",label:"Plugins",element:Vencord.Components.PluginSettings},' + - updater + - patchHelper + - `{section:${mod}.ID.DIVIDER},${m}` - ); - } - } - }] -}); diff --git a/src/plugins/settings.tsx b/src/plugins/settings.tsx new file mode 100644 index 0000000..d80b0ff --- /dev/null +++ b/src/plugins/settings.tsx @@ -0,0 +1,75 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and Megumin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import React from "react"; + +import gitHash from "~git-hash"; + +import { Devs } from "../utils/constants"; +import definePlugin from "../utils/types"; + +export default definePlugin({ + name: "Settings", + description: "Adds Settings UI and debug info", + authors: [Devs.Ven, Devs.Megu], + required: true, + patches: [{ + find: "().versionHash", + replacement: [ + { + match: /\[\(0,.{1,3}\.jsxs?\)\((.{1,10}),(\{[^{}}]+\{.{0,20}\(\)\.versionHash,.+?\})\)," "/, + replace: (m, component, props) => { + props = props.replace(/children:\[.+\]/, ""); + return `${m},Vencord.Plugins.plugins.Settings.makeInfoElements(${component}, ${props})`; + } + } + ] + }, { + find: "Messages.ACTIVITY_SETTINGS", + replacement: { + match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/, + replace: (m, mod) => { + const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater},' : ""; + const patchHelper = IS_DEV ? '{section:"VencordPatchHelper",label:"PatchHelper",element:Vencord.Components.PatchHelper},' : ""; + return ( + `{section:${mod}.ID.HEADER,label:"Vencord"},` + + '{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},' + + '{section:"VencordPlugins",label:"Plugins",element:Vencord.Components.PluginSettings},' + + updater + + patchHelper + + `{section:${mod}.ID.DIVIDER},${m}` + ); + } + } + }], + + makeInfoElements(Component: React.ComponentType, props: React.PropsWithChildren) { + const additionalInfo = IS_WEB + ? " (Web)" + : IS_STANDALONE + ? " (Standalone)" + : ""; + return ( + <> + Vencord {gitHash}{additionalInfo} + Electron {VencordNative.getVersions().electron} + Chromium {VencordNative.getVersions().chrome} + + ); + } +}); diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx index 18bced9..6bf6625 100644 --- a/src/plugins/spotifyControls/index.tsx +++ b/src/plugins/spotifyControls/index.tsx @@ -40,7 +40,7 @@ export default definePlugin({ find: "showTaglessAccountPanel:", replacement: { // return React.createElement(AccountPanel, { ..., showTaglessAccountPanel: blah }) - match: /return (.{0,30}\(.{1,3},\{[^}]+?,showTaglessAccountPanel:.+?\}\))/, + match: /return ?(.{0,30}\(.{1,3},\{[^}]+?,showTaglessAccountPanel:.+?\}\))/, // return [Player, Panel] replace: "return [Vencord.Plugins.plugins.SpotifyControls.renderPlayer(),$1]" } -- cgit