From 07a9adbce25e42dcd4d1eb25ee011328d0543304 Mon Sep 17 00:00:00 2001 From: V Date: Tue, 13 Jun 2023 02:36:25 +0200 Subject: 🧹🧹 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/_api/badges.tsx | 193 +++++++++++++++++++++ src/plugins/_api/commands.ts | 61 +++++++ src/plugins/_api/contextMenu.ts | 45 +++++ src/plugins/_api/memberListDecorators.ts | 42 +++++ src/plugins/_api/messageAccessories.ts | 36 ++++ src/plugins/_api/messageDecorations.ts | 35 ++++ src/plugins/_api/messageEvents.ts | 59 +++++++ src/plugins/_api/messagePopover.ts | 38 ++++ src/plugins/_api/notices.ts | 42 +++++ src/plugins/_api/serverList.ts | 42 +++++ src/plugins/_api/settingsStore.ts | 38 ++++ src/plugins/_core/noTrack.ts | 56 ++++++ src/plugins/_core/settings.tsx | 191 ++++++++++++++++++++ src/plugins/anonymiseFileNames.ts | 2 +- src/plugins/apiBadges.tsx | 193 --------------------- src/plugins/apiCommands.ts | 61 ------- src/plugins/apiContextMenu.ts | 45 ----- src/plugins/apiMemberListDecorators.ts | 42 ----- src/plugins/apiMessageAccessories.ts | 36 ---- src/plugins/apiMessageDecorations.ts | 35 ---- src/plugins/apiMessageEvents.ts | 59 ------- src/plugins/apiMessagePopover.ts | 38 ---- src/plugins/apiNotices.ts | 42 ----- src/plugins/apiServerList.ts | 42 ----- src/plugins/apiSettingsStore.ts | 38 ---- src/plugins/customRPC.tsx | 2 +- src/plugins/fart.ts | 61 ------- src/plugins/ignoreActivities.tsx | 2 +- src/plugins/lastfm.tsx | 4 +- src/plugins/muteNewGuild.tsx | 41 +---- src/plugins/noTrack.ts | 56 ------ src/plugins/reactErrorDecoder.ts | 59 +++++++ src/plugins/serverListIndicators.tsx | 2 +- src/plugins/settings.tsx | 191 -------------------- src/plugins/shikiCodeblocks/types.ts | 6 +- .../components/HiddenChannelLockScreen.tsx | 10 +- src/plugins/showHiddenChannels/index.tsx | 2 +- src/plugins/supportHelper.tsx | 2 +- src/plugins/unminifyErrors.ts | 59 ------- 39 files changed, 954 insertions(+), 1054 deletions(-) create mode 100644 src/plugins/_api/badges.tsx create mode 100644 src/plugins/_api/commands.ts create mode 100644 src/plugins/_api/contextMenu.ts create mode 100644 src/plugins/_api/memberListDecorators.ts create mode 100644 src/plugins/_api/messageAccessories.ts create mode 100644 src/plugins/_api/messageDecorations.ts create mode 100644 src/plugins/_api/messageEvents.ts create mode 100644 src/plugins/_api/messagePopover.ts create mode 100644 src/plugins/_api/notices.ts create mode 100644 src/plugins/_api/serverList.ts create mode 100644 src/plugins/_api/settingsStore.ts create mode 100644 src/plugins/_core/noTrack.ts create mode 100644 src/plugins/_core/settings.tsx delete mode 100644 src/plugins/apiBadges.tsx delete mode 100644 src/plugins/apiCommands.ts delete mode 100644 src/plugins/apiContextMenu.ts delete mode 100644 src/plugins/apiMemberListDecorators.ts delete mode 100644 src/plugins/apiMessageAccessories.ts delete mode 100644 src/plugins/apiMessageDecorations.ts delete mode 100644 src/plugins/apiMessageEvents.ts delete mode 100644 src/plugins/apiMessagePopover.ts delete mode 100644 src/plugins/apiNotices.ts delete mode 100644 src/plugins/apiServerList.ts delete mode 100644 src/plugins/apiSettingsStore.ts delete mode 100644 src/plugins/fart.ts delete mode 100644 src/plugins/noTrack.ts create mode 100644 src/plugins/reactErrorDecoder.ts delete mode 100644 src/plugins/settings.tsx delete mode 100644 src/plugins/unminifyErrors.ts (limited to 'src/plugins') diff --git a/src/plugins/_api/badges.tsx b/src/plugins/_api/badges.tsx new file mode 100644 index 0000000..5f44d98 --- /dev/null +++ b/src/plugins/_api/badges.tsx @@ -0,0 +1,193 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; +import DonateButton from "@components/DonateButton"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { Flex } from "@components/Flex"; +import { Heart } from "@components/Heart"; +import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; +import { Margins } from "@utils/margins"; +import { isPluginDev } from "@utils/misc"; +import { closeModal, Modals, openModal } from "@utils/modal"; +import definePlugin from "@utils/types"; +import { Forms, Toasts } from "@webpack/common"; + +const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png"; + +const ContributorBadge: ProfileBadge = { + description: "Vencord Contributor", + image: CONTRIBUTOR_BADGE, + position: BadgePosition.START, + props: { + style: { + borderRadius: "50%", + transform: "scale(0.9)" // The image is a bit too big compared to default badges + } + }, + shouldShow: ({ user }) => isPluginDev(user.id), + link: "https://github.com/Vendicated/Vencord" +}; + +let DonorBadges = {} as Record[]>; + +async function loadBadges(noCache = false) { + DonorBadges = {}; + + const init = {} as RequestInit; + if (noCache) + init.cache = "no-cache"; + + const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv", init) + .then(r => r.text()); + + const lines = badges.trim().split("\n"); + if (lines.shift() !== "id,tooltip,image") { + new Logger("BadgeAPI").error("Invalid badges.csv file!"); + return; + } + + for (const line of lines) { + const [id, description, image] = line.split(","); + (DonorBadges[id] ??= []).push({ image, description }); + } +} + +export default definePlugin({ + name: "BadgeAPI", + description: "API to add badges to users.", + authors: [Devs.Megu, Devs.Ven, Devs.TheSun], + required: true, + patches: [ + /* Patch the badge list component on user profiles */ + { + find: "Messages.PROFILE_USER_BADGES,role:", + replacement: [ + { + match: /(?<=(\i)\.isTryItOutFlow,)(.{0,300})null==\i\?void 0:(\i)\.getBadges\(\)/, + replace: (_, props, restCode, badgesMod) => `vencordProps=${props},${restCode}Vencord.Api.Badges._getBadges(vencordProps).concat(${badgesMod}?.getBadges()??[])`, + }, + { + // alt: "", aria-hidden: false, src: originalSrc + match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/g, + // ...badge.props, ..., src: badge.image ?? ... + replace: "...$1.props,$& $1.image??" + }, + { + match: /children:function(?<=(\i)\.(?:tooltip|description),spacing:\d.+?)/g, + replace: "children:$1.component ? () => $self.renderBadgeComponent($1) : function" + }, + { + match: /onClick:function(?=.{0,200}href:(\i)\.link)/, + replace: "onClick:$1.onClick??function" + } + ] + } + ], + + toolboxActions: { + async "Refetch Badges"() { + await loadBadges(true); + Toasts.show({ + id: Toasts.genId(), + message: "Successfully refetched badges!", + type: Toasts.Type.SUCCESS + }); + } + }, + + async start() { + Vencord.Api.Badges.addBadge(ContributorBadge); + await loadBadges(); + }, + + renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => { + const Component = badge.component!; + return ; + }, { noop: true }), + + + getDonorBadges(userId: string) { + return DonorBadges[userId]?.map(badge => ({ + ...badge, + position: BadgePosition.START, + props: { + style: { + borderRadius: "50%", + transform: "scale(0.9)" // The image is a bit too big compared to default badges + } + }, + onClick() { + const modalKey = openModal(props => ( + { + closeModal(modalKey); + VencordNative.native.openExternal("https://github.com/sponsors/Vendicated"); + }}> + + + + + + Vencord Donor + + + + + + + + +
+ + This Badge is a special perk for Vencord Donors + + + Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! + +
+
+ + + + + +
+
+ )); + }, + })); + } +}); diff --git a/src/plugins/_api/commands.ts b/src/plugins/_api/commands.ts new file mode 100644 index 0000000..2197b30 --- /dev/null +++ b/src/plugins/_api/commands.ts @@ -0,0 +1,61 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "CommandsAPI", + authors: [Devs.Arjix], + description: "Api required by anything that uses commands", + patches: [ + // obtain BUILT_IN_COMMANDS instance + { + find: '"giphy","tenor"', + replacement: [ + { + // Matches BUILT_IN_COMMANDS. This is not exported so this is + // the only way. _init() just returns the same object to make the + // patch simpler + + // textCommands = builtInCommands.filter(...) + match: /(?<=\w=)(\w)(\.filter\(.{0,30}giphy)/, + replace: "Vencord.Api.Commands._init($1)$2", + } + ], + }, + // command error handling + { + find: "Unexpected value for option", + replacement: { + // return [2, cmd.execute(args, ctx)] + match: /,(.{1,2})\.execute\((.{1,2}),(.{1,2})\)]/, + replace: (_, cmd, args, ctx) => `,Vencord.Api.Commands._handleCommand(${cmd}, ${args}, ${ctx})]` + } + }, + // Show plugin name instead of "Built-In" + { + find: ".source,children", + replacement: { + // ...children: p?.name + match: /(?<=:(.{1,3})\.displayDescription\}.{0,200}\.source,children:)[^}]+/, + replace: "$1.plugin||($&)" + } + } + ], +}); diff --git a/src/plugins/_api/contextMenu.ts b/src/plugins/_api/contextMenu.ts new file mode 100644 index 0000000..d04e0e6 --- /dev/null +++ b/src/plugins/_api/contextMenu.ts @@ -0,0 +1,45 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "ContextMenuAPI", + description: "API for adding/removing items to/from context menus.", + authors: [Devs.Nuckyz, Devs.Ven], + required: true, + + patches: [ + { + find: "♫ (つ。◕‿‿◕。)つ ♪", + replacement: { + match: /(?<=function \i\((\i)\){)(?=var \i,\i=\i\.navId)/, + replace: (_, props) => `Vencord.Api.ContextMenu._patchContextMenu(${props});` + } + }, + { + find: ".Menu,{", + all: true, + replacement: { + match: /Menu,{(?<=\.jsxs?\)\(\i\.Menu,{)/g, + replace: "$&contextMenuApiArguments:typeof arguments!=='undefined'?arguments:[]," + } + } + ] +}); diff --git a/src/plugins/_api/memberListDecorators.ts b/src/plugins/_api/memberListDecorators.ts new file mode 100644 index 0000000..6b8cffa --- /dev/null +++ b/src/plugins/_api/memberListDecorators.ts @@ -0,0 +1,42 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "MemberListDecoratorsAPI", + description: "API to add decorators to member list (both in servers and DMs)", + authors: [Devs.TheSun], + patches: [ + { + find: "lostPermissionTooltipText,", + replacement: { + match: /Fragment,{children:\[(.{30,80})\]/, + replace: "Fragment,{children:Vencord.Api.MemberListDecorators.__addDecoratorsToList(this.props).concat($1)" + } + }, + { + find: "PrivateChannel.renderAvatar", + replacement: { + match: /(subText:(.{1,2})\.renderSubtitle\(\).{1,50}decorators):(.{30,100}:null)/, + replace: "$1:Vencord.Api.MemberListDecorators.__addDecoratorsToList($2.props).concat($3)" + } + } + ], +}); diff --git a/src/plugins/_api/messageAccessories.ts b/src/plugins/_api/messageAccessories.ts new file mode 100644 index 0000000..5bb13cf --- /dev/null +++ b/src/plugins/_api/messageAccessories.ts @@ -0,0 +1,36 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "MessageAccessoriesAPI", + description: "API to add message accessories.", + authors: [Devs.Cyn], + patches: [ + { + find: ".Messages.REMOVE_ATTACHMENT_BODY", + replacement: { + match: /(.container\)?,children:)(\[[^\]]+\])(}\)\};return)/, + replace: (_, pre, accessories, post) => + `${pre}Vencord.Api.MessageAccessories._modifyAccessories(${accessories},this.props)${post}`, + }, + }, + ], +}); diff --git a/src/plugins/_api/messageDecorations.ts b/src/plugins/_api/messageDecorations.ts new file mode 100644 index 0000000..a3b2518 --- /dev/null +++ b/src/plugins/_api/messageDecorations.ts @@ -0,0 +1,35 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "MessageDecorationsAPI", + description: "API to add decorations to messages", + authors: [Devs.TheSun], + patches: [ + { + find: ".withMentionPrefix", + replacement: { + match: /(.roleDot.{10,50}{children:.{1,2})}\)/, + replace: "$1.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))})" + } + } + ], +}); diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts new file mode 100644 index 0000000..fa46752 --- /dev/null +++ b/src/plugins/_api/messageEvents.ts @@ -0,0 +1,59 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "MessageEventsAPI", + description: "Api required by anything using message events.", + authors: [Devs.Arjix, Devs.hunt, Devs.Ven], + patches: [ + { + find: '"MessageActionCreators"', + replacement: { + // editMessage: function (...) { + match: /\beditMessage:(function\(.+?\))\{/, + // editMessage: async function (...) { await handlePreEdit(...); ... + replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);" + } + }, + { + find: ".handleSendMessage=", + replacement: { + // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); + // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) + match: /(props\.chatInputType.+?\.then\(\()(function.+?var (\i)=\i\.\i\.parse\((\i),.+?var (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, + // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; + replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + + `${rest1}async ${rest2}` + + `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + + "return{shoudClear:true,shouldRefocus:true};" + } + }, + { + find: '("interactionUsernameProfile', + replacement: { + match: /var \i=(\i)\.id,\i=(\i)\.id;return \i\.useCallback\(\(?function\((\i)\){/, + replace: (m, message, channel, event) => + // the message param is shadowed by the event param, so need to alias them + `var _msg=${message},_chan=${channel};${m}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});` + } + } + ] +}); diff --git a/src/plugins/_api/messagePopover.ts b/src/plugins/_api/messagePopover.ts new file mode 100644 index 0000000..be4b639 --- /dev/null +++ b/src/plugins/_api/messagePopover.ts @@ -0,0 +1,38 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "MessagePopoverAPI", + description: "API to add buttons to message popovers.", + authors: [Devs.KingFish, Devs.Ven, Devs.Nuckyz], + patches: [{ + find: "Messages.MESSAGE_UTILITIES_A11Y_LABEL", + replacement: { + // foo && !bar ? createElement(reactionStuffs)... createElement(blah,...makeElement(reply-other)) + match: /\i&&!\i\?\(0,\i\.jsxs?\)\(.{0,200}renderEmojiPicker:.{0,500}\?(\i)\(\{key:"reply-other"/, + replace: (m, makeElement) => { + const msg = m.match(/message:(.{1,3}),/)?.[1]; + if (!msg) throw new Error("Could not find message variable"); + return `...Vencord.Api.MessagePopover._buildPopoverElements(${msg},${makeElement}),${m}`; + } + } + }], +}); diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts new file mode 100644 index 0000000..af7cb15 --- /dev/null +++ b/src/plugins/_api/notices.ts @@ -0,0 +1,42 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "NoticesAPI", + description: "Fixes notices being automatically dismissed", + authors: [Devs.Ven], + required: true, + patches: [ + { + find: 'displayName="NoticeStore"', + replacement: [ + { + match: /(?=;\i=null;.{0,70}getPremiumSubscription)/g, + replace: ";if(Vencord.Api.Notices.currentNotice)return false" + }, + { + match: /(?<=,NOTICE_DISMISS:function\(\i\){)(?=if\(null==(\i)\))/, + replace: (_, notice) => `if(${notice}.id=="VencordNotice")return(${notice}=null,Vencord.Api.Notices.nextNotice(),true);` + } + ] + } + ], +}); diff --git a/src/plugins/_api/serverList.ts b/src/plugins/_api/serverList.ts new file mode 100644 index 0000000..6585d38 --- /dev/null +++ b/src/plugins/_api/serverList.ts @@ -0,0 +1,42 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "ServerListAPI", + authors: [Devs.kemo], + description: "Api required for plugins that modify the server list", + patches: [ + { + find: "Messages.DISCODO_DISABLED", + replacement: { + match: /(Messages\.DISCODO_DISABLED\);return)(.*?homeIcon.*?)(\}function)/, + replace: "$1[$2].concat(Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.Above))$3" + } + }, + { + find: "Messages.SERVERS,children", + replacement: { + match: /(Messages\.SERVERS,children:)(.+?default:return null\}\}\)\))/, + replace: "$1Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($2)" + } + } + ] +}); diff --git a/src/plugins/_api/settingsStore.ts b/src/plugins/_api/settingsStore.ts new file mode 100644 index 0000000..ca1dc65 --- /dev/null +++ b/src/plugins/_api/settingsStore.ts @@ -0,0 +1,38 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "SettingsStoreAPI", + description: "Patches Discord's SettingsStores to expose their group and name", + authors: [Devs.Nuckyz], + + patches: [ + { + find: '"textAndImages","renderSpoilers"', + replacement: [ + { + match: /(?<=INFREQUENT_USER_ACTION.{0,20}),useSetting:function/, + replace: ",settingsStoreApiGroup:arguments[0],settingsStoreApiName:arguments[1]$&" + } + ] + } + ] +}); diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts new file mode 100644 index 0000000..4920ce2 --- /dev/null +++ b/src/plugins/_core/noTrack.ts @@ -0,0 +1,56 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "NoTrack", + description: "Disable Discord's tracking ('science'), metrics and Sentry crash reporting", + authors: [Devs.Cyn, Devs.Ven, Devs.Nuckyz], + required: true, + patches: [ + { + find: "TRACKING_URL:", + replacement: { + match: /^.+$/, + replace: "()=>{}", + }, + }, + { + find: "window.DiscordSentry=", + replacement: { + match: /^.+$/, + replace: "()=>{}", + } + }, + { + find: ".METRICS,", + replacement: [ + { + match: /this\._intervalId.+?12e4\)/, + replace: "" + }, + { + match: /(?<=increment=function\(\i\){)/, + replace: "return;" + } + ] + } + ] +}); diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx new file mode 100644 index 0000000..3ea5a43 --- /dev/null +++ b/src/plugins/_core/settings.tsx @@ -0,0 +1,191 @@ +/* + * 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 { addContextMenuPatch } from "@api/ContextMenu"; +import { Settings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; +import definePlugin, { OptionType } from "@utils/types"; +import { React, SettingsRouter } from "@webpack/common"; + +import gitHash from "~git-hash"; + +export default definePlugin({ + name: "Settings", + description: "Adds Settings UI and debug info", + authors: [Devs.Ven, Devs.Megu], + required: true, + + start() { + // The settings shortcuts in the user settings cog context menu + // read the elements from a hardcoded map which for obvious reason + // doesn't contain our sections. This patches the actions of our + // sections to manually use SettingsRouter (which only works on desktop + // but the context menu is usually not available on mobile anyway) + addContextMenuPatch("user-settings-cog", children => () => { + const section = children.find(c => Array.isArray(c) && c.some(it => it?.props?.id === "VencordSettings")) as any; + section?.forEach(c => { + if (c?.props?.id?.startsWith("Vencord")) { + c.props.action = () => SettingsRouter.open(c.props.id); + } + }); + }); + }, + + 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: { + get match() { + switch (Settings.plugins.Settings.settingsLocation) { + case "top": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.USER_SETTINGS\}/; + case "aboveNitro": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.BILLING_SETTINGS\}/; + case "belowNitro": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.APP_SETTINGS\}/; + case "aboveActivity": return /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/; + case "belowActivity": return /(?<=\{section:(.{1,2})\.ID\.DIVIDER},)\{section:"changelog"/; + case "bottom": return /\{section:(.{1,2})\.ID\.CUSTOM,\s*element:.+?}/; + default: { + new Logger("Settings").error( + new Error("No switch case matched????? Don't mess with the settings, silly") + ); + // matches nothing + return /(?!a)a/; + } + } + }, + replace: "...$self.makeSettingsCategories($1),$&" + } + }], + + customSections: [] as ((ID: Record) => any)[], + + makeSettingsCategories({ ID }: { ID: Record; }) { + return [ + { + section: ID.HEADER, + label: "Vencord" + }, + { + section: "VencordSettings", + label: "Vencord", + element: require("@components/VencordSettings/VencordTab").default + }, + { + section: "VencordPlugins", + label: "Plugins", + element: require("@components/VencordSettings/PluginsTab").default, + }, + { + section: "VencordThemes", + label: "Themes", + element: require("@components/VencordSettings/ThemesTab").default, + }, + !IS_WEB && { + section: "VencordUpdater", + label: "Updater", + element: require("@components/VencordSettings/UpdaterTab").default, + }, + { + section: "VencordCloud", + label: "Cloud", + element: require("@components/VencordSettings/CloudTab").default, + }, + { + section: "VencordSettingsSync", + label: "Backup & Restore", + element: require("@components/VencordSettings/BackupAndRestoreTab").default, + }, + IS_DEV && { + section: "VencordPatchHelper", + label: "Patch Helper", + element: require("@components/VencordSettings/PatchHelperTab").default, + }, + // TODO: make this use customSections + IS_VENCORD_DESKTOP && { + section: "VencordDesktop", + label: "Desktop Settings", + element: VencordDesktop.Components.Settings, + }, + ...this.customSections.map(func => func(ID)), + { + section: ID.DIVIDER + } + ].filter(Boolean); + }, + + options: { + settingsLocation: { + type: OptionType.SELECT, + description: "Where to put the Vencord settings section", + options: [ + { label: "At the very top", value: "top" }, + { label: "Above the Nitro section", value: "aboveNitro" }, + { label: "Below the Nitro section", value: "belowNitro" }, + { label: "Above Activity Settings", value: "aboveActivity", default: true }, + { label: "Below Activity Settings", value: "belowActivity" }, + { label: "At the very bottom", value: "bottom" }, + ], + restartNeeded: true + }, + }, + + get electronVersion() { + return VencordNative.native.getVersions().electron || window.armcord?.electron || null; + }, + + get chromiumVersion() { + try { + return VencordNative.native.getVersions().chrome + // @ts-ignore Typescript will add userAgentData IMMEDIATELY + || navigator.userAgentData?.brands?.find(b => b.brand === "Chromium" || b.brand === "Google Chrome")?.version + || null; + } catch { // inb4 some stupid browser throws unsupported error for navigator.userAgentData, it's only in chromium + return null; + } + }, + + get additionalInfo() { + if (IS_DEV) return " (Dev)"; + if (IS_WEB) return " (Web)"; + if (IS_VENCORD_DESKTOP) return ` (VencordDesktop v${VencordDesktopNative.app.getVersion()})`; + if (IS_STANDALONE) return " (Standalone)"; + return ""; + }, + + makeInfoElements(Component: React.ComponentType, props: React.PropsWithChildren) { + const { electronVersion, chromiumVersion, additionalInfo } = this; + + return ( + <> + Vencord {gitHash}{additionalInfo} + {electronVersion && Electron {electronVersion}} + {chromiumVersion && Chromium {chromiumVersion}} + + ); + } +}); diff --git a/src/plugins/anonymiseFileNames.ts b/src/plugins/anonymiseFileNames.ts index 0baf099..37fd18f 100644 --- a/src/plugins/anonymiseFileNames.ts +++ b/src/plugins/anonymiseFileNames.ts @@ -20,7 +20,7 @@ import { Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -enum Methods { +const enum Methods { Random, Consistent, Timestamp, diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx deleted file mode 100644 index 5f44d98..0000000 --- a/src/plugins/apiBadges.tsx +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges"; -import DonateButton from "@components/DonateButton"; -import ErrorBoundary from "@components/ErrorBoundary"; -import { Flex } from "@components/Flex"; -import { Heart } from "@components/Heart"; -import { Devs } from "@utils/constants"; -import { Logger } from "@utils/Logger"; -import { Margins } from "@utils/margins"; -import { isPluginDev } from "@utils/misc"; -import { closeModal, Modals, openModal } from "@utils/modal"; -import definePlugin from "@utils/types"; -import { Forms, Toasts } from "@webpack/common"; - -const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png"; - -const ContributorBadge: ProfileBadge = { - description: "Vencord Contributor", - image: CONTRIBUTOR_BADGE, - position: BadgePosition.START, - props: { - style: { - borderRadius: "50%", - transform: "scale(0.9)" // The image is a bit too big compared to default badges - } - }, - shouldShow: ({ user }) => isPluginDev(user.id), - link: "https://github.com/Vendicated/Vencord" -}; - -let DonorBadges = {} as Record[]>; - -async function loadBadges(noCache = false) { - DonorBadges = {}; - - const init = {} as RequestInit; - if (noCache) - init.cache = "no-cache"; - - const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv", init) - .then(r => r.text()); - - const lines = badges.trim().split("\n"); - if (lines.shift() !== "id,tooltip,image") { - new Logger("BadgeAPI").error("Invalid badges.csv file!"); - return; - } - - for (const line of lines) { - const [id, description, image] = line.split(","); - (DonorBadges[id] ??= []).push({ image, description }); - } -} - -export default definePlugin({ - name: "BadgeAPI", - description: "API to add badges to users.", - authors: [Devs.Megu, Devs.Ven, Devs.TheSun], - required: true, - patches: [ - /* Patch the badge list component on user profiles */ - { - find: "Messages.PROFILE_USER_BADGES,role:", - replacement: [ - { - match: /(?<=(\i)\.isTryItOutFlow,)(.{0,300})null==\i\?void 0:(\i)\.getBadges\(\)/, - replace: (_, props, restCode, badgesMod) => `vencordProps=${props},${restCode}Vencord.Api.Badges._getBadges(vencordProps).concat(${badgesMod}?.getBadges()??[])`, - }, - { - // alt: "", aria-hidden: false, src: originalSrc - match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/g, - // ...badge.props, ..., src: badge.image ?? ... - replace: "...$1.props,$& $1.image??" - }, - { - match: /children:function(?<=(\i)\.(?:tooltip|description),spacing:\d.+?)/g, - replace: "children:$1.component ? () => $self.renderBadgeComponent($1) : function" - }, - { - match: /onClick:function(?=.{0,200}href:(\i)\.link)/, - replace: "onClick:$1.onClick??function" - } - ] - } - ], - - toolboxActions: { - async "Refetch Badges"() { - await loadBadges(true); - Toasts.show({ - id: Toasts.genId(), - message: "Successfully refetched badges!", - type: Toasts.Type.SUCCESS - }); - } - }, - - async start() { - Vencord.Api.Badges.addBadge(ContributorBadge); - await loadBadges(); - }, - - renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => { - const Component = badge.component!; - return ; - }, { noop: true }), - - - getDonorBadges(userId: string) { - return DonorBadges[userId]?.map(badge => ({ - ...badge, - position: BadgePosition.START, - props: { - style: { - borderRadius: "50%", - transform: "scale(0.9)" // The image is a bit too big compared to default badges - } - }, - onClick() { - const modalKey = openModal(props => ( - { - closeModal(modalKey); - VencordNative.native.openExternal("https://github.com/sponsors/Vendicated"); - }}> - - - - - - Vencord Donor - - - - - - - - -
- - This Badge is a special perk for Vencord Donors - - - Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! - -
-
- - - - - -
-
- )); - }, - })); - } -}); diff --git a/src/plugins/apiCommands.ts b/src/plugins/apiCommands.ts deleted file mode 100644 index 2197b30..0000000 --- a/src/plugins/apiCommands.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "CommandsAPI", - authors: [Devs.Arjix], - description: "Api required by anything that uses commands", - patches: [ - // obtain BUILT_IN_COMMANDS instance - { - find: '"giphy","tenor"', - replacement: [ - { - // Matches BUILT_IN_COMMANDS. This is not exported so this is - // the only way. _init() just returns the same object to make the - // patch simpler - - // textCommands = builtInCommands.filter(...) - match: /(?<=\w=)(\w)(\.filter\(.{0,30}giphy)/, - replace: "Vencord.Api.Commands._init($1)$2", - } - ], - }, - // command error handling - { - find: "Unexpected value for option", - replacement: { - // return [2, cmd.execute(args, ctx)] - match: /,(.{1,2})\.execute\((.{1,2}),(.{1,2})\)]/, - replace: (_, cmd, args, ctx) => `,Vencord.Api.Commands._handleCommand(${cmd}, ${args}, ${ctx})]` - } - }, - // Show plugin name instead of "Built-In" - { - find: ".source,children", - replacement: { - // ...children: p?.name - match: /(?<=:(.{1,3})\.displayDescription\}.{0,200}\.source,children:)[^}]+/, - replace: "$1.plugin||($&)" - } - } - ], -}); diff --git a/src/plugins/apiContextMenu.ts b/src/plugins/apiContextMenu.ts deleted file mode 100644 index d04e0e6..0000000 --- a/src/plugins/apiContextMenu.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "ContextMenuAPI", - description: "API for adding/removing items to/from context menus.", - authors: [Devs.Nuckyz, Devs.Ven], - required: true, - - patches: [ - { - find: "♫ (つ。◕‿‿◕。)つ ♪", - replacement: { - match: /(?<=function \i\((\i)\){)(?=var \i,\i=\i\.navId)/, - replace: (_, props) => `Vencord.Api.ContextMenu._patchContextMenu(${props});` - } - }, - { - find: ".Menu,{", - all: true, - replacement: { - match: /Menu,{(?<=\.jsxs?\)\(\i\.Menu,{)/g, - replace: "$&contextMenuApiArguments:typeof arguments!=='undefined'?arguments:[]," - } - } - ] -}); diff --git a/src/plugins/apiMemberListDecorators.ts b/src/plugins/apiMemberListDecorators.ts deleted file mode 100644 index 6b8cffa..0000000 --- a/src/plugins/apiMemberListDecorators.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "MemberListDecoratorsAPI", - description: "API to add decorators to member list (both in servers and DMs)", - authors: [Devs.TheSun], - patches: [ - { - find: "lostPermissionTooltipText,", - replacement: { - match: /Fragment,{children:\[(.{30,80})\]/, - replace: "Fragment,{children:Vencord.Api.MemberListDecorators.__addDecoratorsToList(this.props).concat($1)" - } - }, - { - find: "PrivateChannel.renderAvatar", - replacement: { - match: /(subText:(.{1,2})\.renderSubtitle\(\).{1,50}decorators):(.{30,100}:null)/, - replace: "$1:Vencord.Api.MemberListDecorators.__addDecoratorsToList($2.props).concat($3)" - } - } - ], -}); diff --git a/src/plugins/apiMessageAccessories.ts b/src/plugins/apiMessageAccessories.ts deleted file mode 100644 index 5bb13cf..0000000 --- a/src/plugins/apiMessageAccessories.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "MessageAccessoriesAPI", - description: "API to add message accessories.", - authors: [Devs.Cyn], - patches: [ - { - find: ".Messages.REMOVE_ATTACHMENT_BODY", - replacement: { - match: /(.container\)?,children:)(\[[^\]]+\])(}\)\};return)/, - replace: (_, pre, accessories, post) => - `${pre}Vencord.Api.MessageAccessories._modifyAccessories(${accessories},this.props)${post}`, - }, - }, - ], -}); diff --git a/src/plugins/apiMessageDecorations.ts b/src/plugins/apiMessageDecorations.ts deleted file mode 100644 index a3b2518..0000000 --- a/src/plugins/apiMessageDecorations.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "MessageDecorationsAPI", - description: "API to add decorations to messages", - authors: [Devs.TheSun], - patches: [ - { - find: ".withMentionPrefix", - replacement: { - match: /(.roleDot.{10,50}{children:.{1,2})}\)/, - replace: "$1.concat(Vencord.Api.MessageDecorations.__addDecorationsToMessage(arguments[0]))})" - } - } - ], -}); diff --git a/src/plugins/apiMessageEvents.ts b/src/plugins/apiMessageEvents.ts deleted file mode 100644 index fa46752..0000000 --- a/src/plugins/apiMessageEvents.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * 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 { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "MessageEventsAPI", - description: "Api required by anything using message events.", - authors: [Devs.Arjix, Devs.hunt, Devs.Ven], - patches: [ - { - find: '"MessageActionCreators"', - replacement: { - // editMessage: function (...) { - match: /\beditMessage:(function\(.+?\))\{/, - // editMessage: async function (...) { await handlePreEdit(...); ... - replace: "editMessage:async $1{await Vencord.Api.MessageEvents._handlePreEdit(...arguments);" - } - }, - { - find: ".handleSendMessage=", - replacement: { - // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); - // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(props\.chatInputType.+?\.then\(\()(function.+?var (\i)=\i\.\i\.parse\((\i),.+?var (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/, - // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; - replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + - `${rest1}async ${rest2}` + - `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + - "return{shoudClear:true,shouldRefocus:true};" - } - }, - { - find: '("interactionUsernameProfile', - replacement: { - match: /var \i=(\i)\.id,\i=(\i)\.id;return \i\.useCallback\(\(?function\((\i)\){/, - replace: (m, message, channel, event) => - // the message param is shadowed by the event param, so need to alias them - `var _msg=${message},_chan=${channel};${m}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});` - } - } - ] -}); diff --git a/src/plugins/apiMessagePopover.ts b/src/plugins/apiMessagePopover.ts deleted file mode