From bec4c76d9a521a178853b779c308096e2b116fdc Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:04:16 -0300 Subject: [PATCH 01/16] Fix ShowAllRoles --- src/plugins/showAllRoles/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/showAllRoles/index.ts b/src/plugins/showAllRoles/index.ts index 02d9f964c..97f0181fa 100644 --- a/src/plugins/showAllRoles/index.ts +++ b/src/plugins/showAllRoles/index.ts @@ -15,8 +15,8 @@ export default definePlugin({ { find: ".Messages.VIEW_ALL_ROLES", replacement: { - match: /return null!=\i(?=\?\i\.slice)/, - replace: "return false" + match: /(\i)\.slice\(0,\i\)/, + replace: "$1" } } ] From 78d2713151ff8df725b095ef4dfe3b5f693f0ca0 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 5 Jul 2024 16:56:32 +0200 Subject: [PATCH 02/16] Delete WikiSearch ~ better done via user app https://discord.com/application-directory/search?q=wiki --- src/plugins/wikisearch/index.ts | 110 -------------------------------- 1 file changed, 110 deletions(-) delete mode 100644 src/plugins/wikisearch/index.ts diff --git a/src/plugins/wikisearch/index.ts b/src/plugins/wikisearch/index.ts deleted file mode 100644 index 81dc37af1..000000000 --- a/src/plugins/wikisearch/index.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 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 { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "Wikisearch", - description: "Searches Wikipedia for your requested query. (/wikisearch)", - authors: [Devs.Samu], - dependencies: ["CommandsAPI"], - commands: [ - { - name: "wikisearch", - description: "Searches Wikipedia for your request.", - inputType: ApplicationCommandInputType.BUILT_IN, - options: [ - { - name: "search", - description: "Word to search for", - type: ApplicationCommandOptionType.STRING, - required: true - }, - ], - execute: async (_, ctx) => { - const word = findOption(_, "search", ""); - - if (!word) { - return sendBotMessage(ctx.channel.id, { - content: "No word was defined!" - }); - } - - const dataSearchParams = new URLSearchParams({ - action: "query", - format: "json", - list: "search", - formatversion: "2", - origin: "*", - srsearch: word - }); - - const data = await fetch("https://en.wikipedia.org/w/api.php?" + dataSearchParams).then(response => response.json()) - .catch(err => { - console.log(err); - sendBotMessage(ctx.channel.id, { content: "There was an error. Check the console for more info" }); - return null; - }); - - if (!data) return; - - if (!data.query?.search?.length) { - console.log(data); - return sendBotMessage(ctx.channel.id, { content: "No results given" }); - } - - const altData = await fetch(`https://en.wikipedia.org/w/api.php?action=query&format=json&prop=info%7Cdescription%7Cimages%7Cimageinfo%7Cpageimages&list=&meta=&indexpageids=1&pageids=${data.query.search[0].pageid}&formatversion=2&origin=*`) - .then(res => res.json()) - .then(data => data.query.pages[0]) - .catch(err => { - console.log(err); - sendBotMessage(ctx.channel.id, { content: "There was an error. Check the console for more info" }); - return null; - }); - - if (!altData) return; - - const thumbnailData = altData.thumbnail; - - const thumbnail = thumbnailData && { - url: thumbnailData.source.replace(/(50px-)/ig, "1000px-"), - height: thumbnailData.height * 100, - width: thumbnailData.width * 100 - }; - - sendBotMessage(ctx.channel.id, { - embeds: [ - { - type: "rich", - title: data.query.search[0].title, - url: `https://wikipedia.org/w/index.php?curid=${data.query.search[0].pageid}`, - color: "0x8663BE", - description: data.query.search[0].snippet.replace(/( |<([^>]+)>)/ig, "").replace(/(")/ig, "\"") + "...", - image: thumbnail, - footer: { - text: "Powered by the Wikimedia API", - }, - } - ] as any - }); - } - } - ] -}); From 93dc880bc026ad83ff47bddc588d274909a67bff Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 5 Jul 2024 16:58:11 +0200 Subject: [PATCH 03/16] Delete UrbanDictionary ~ better done via user app https://discord.com/application-directory/search?q=urban --- src/plugins/urbanDictionary/README.md | 13 ---- src/plugins/urbanDictionary/index.ts | 105 -------------------------- 2 files changed, 118 deletions(-) delete mode 100644 src/plugins/urbanDictionary/README.md delete mode 100644 src/plugins/urbanDictionary/index.ts diff --git a/src/plugins/urbanDictionary/README.md b/src/plugins/urbanDictionary/README.md deleted file mode 100644 index e065456a3..000000000 --- a/src/plugins/urbanDictionary/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Urban Dictionary - -Use /urban slash command to search for a definition for a word on [Urban Dictionary](https://www.urbandictionary.com/). - -## Preview - -![preview](https://i.imgur.com/1zwzj38.png) - -## Usage - -- Enable this plugin -- Set plugin settings as desired -- Type /urban and start getting definitions right into your Discord client. diff --git a/src/plugins/urbanDictionary/index.ts b/src/plugins/urbanDictionary/index.ts deleted file mode 100644 index 89dcdcba4..000000000 --- a/src/plugins/urbanDictionary/index.ts +++ /dev/null @@ -1,105 +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 { ApplicationCommandOptionType, sendBotMessage } from "@api/Commands"; -import { ApplicationCommandInputType } from "@api/Commands/types"; -import { definePluginSettings } from "@api/Settings"; -import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; - -const settings = definePluginSettings({ - resultsAmount: { - type: OptionType.NUMBER, - description: "The amount of results you want to get (more gives better results, but is slower)", - default: 10 - } -}); - -export default definePlugin({ - name: "UrbanDictionary", - description: "Search for a word on Urban Dictionary via /urban slash command", - authors: [Devs.jewdev], - dependencies: ["CommandsAPI"], - settings, - commands: [ - { - name: "urban", - description: "Returns the definition of a word from Urban Dictionary", - inputType: ApplicationCommandInputType.BUILT_IN, - options: [ - { - type: ApplicationCommandOptionType.STRING, - name: "word", - description: "The word to search for on Urban Dictionary", - required: true - } - ], - execute: async (args, ctx) => { - try { - const query: string = encodeURIComponent(args[0].value); - const { list } = await fetch(`https://api.urbandictionary.com/v0/define?term=${query}&per_page=${settings.store.resultsAmount}`).then(response => response.json()); - - if (!list.length) - return void sendBotMessage(ctx.channel.id, { content: "No results found." }); - - const definition = list.reduce((prev, curr) => { - return prev.thumbs_up > curr.thumbs_up ? prev : curr; - }); - - const linkify = (text: string) => text - .replaceAll("\r\n", "\n") - .replace(/([*>_`~\\])/gsi, "\\$1") - .replace(/\[(.+?)\]/g, (_, word) => `[${word}](https://www.urbandictionary.com/define.php?term=${encodeURIComponent(word)} "Define '${word}' on Urban Dictionary")`) - .trim(); - - return void sendBotMessage(ctx.channel.id, { - embeds: [ - { - type: "rich", - author: { - name: `Uploaded by "${definition.author}"`, - url: `https://www.urbandictionary.com/author.php?author=${encodeURIComponent(definition.author)}`, - }, - title: definition.word, - url: `https://www.urbandictionary.com/define.php?term=${encodeURIComponent(definition.word)}`, - description: linkify(definition.definition), - fields: [ - { - name: "Example", - value: linkify(definition.example), - }, - { - name: "Want more definitions?", - value: `Check out [more definitions](https://www.urbandictionary.com/define.php?term=${query} "Define "${args[0].value}" on Urban Dictionary") on Urban Dictionary.`, - }, - ], - color: 0xFF9900, - footer: { text: `👍 ${definition.thumbs_up.toString()} | 👎 ${definition.thumbs_down.toString()}`, icon_url: "https://www.urbandictionary.com/favicon.ico" }, - timestamp: new Date(definition.written_on).toISOString(), - }, - ] as any, - }); - } catch (error) { - sendBotMessage(ctx.channel.id, { - content: `Something went wrong: \`${error}\``, - }); - } - } - } - ] -}); From c3f7950f2e6a4305d838d0e83564769871c09ce3 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 5 Jul 2024 17:07:54 +0200 Subject: [PATCH 04/16] MessageLogger: fix not blurring deleted spoilers --- src/plugins/messageLogger/messageLogger.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/messageLogger/messageLogger.css b/src/plugins/messageLogger/messageLogger.css index d5a9c5f17..a112b1961 100644 --- a/src/plugins/messageLogger/messageLogger.css +++ b/src/plugins/messageLogger/messageLogger.css @@ -8,11 +8,15 @@ .emoji, [data-type="sticker"], iframe, - .messagelogger-deleted-attachment:not([class*="hiddenAttachment_"]), + .messagelogger-deleted-attachment, [class|="inlineMediaEmbed"] ) { filter: grayscale(1) !important; transition: 150ms filter ease-in-out; + + &[class*="hiddenMosaicItem_"] { + filter: grayscale(1) blur(var(--custom-message-attachment-spoiler-blur-radius, 44px)) !important; + } } .messagelogger-deleted @@ -23,8 +27,7 @@ iframe, .messagelogger-deleted-attachment, [class|="inlineMediaEmbed"] -):hover, -.messagelogger-deleted { +):hover { filter: grayscale(0) !important; } From 319a99c293004d089cf83685c8e70e53d51c3c91 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 5 Jul 2024 18:43:51 +0200 Subject: [PATCH 05/16] fix(MessageLogger): don't break attachment edits --- src/plugins/messageLogger/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index fdd6dc9b9..6969f0909 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -337,7 +337,7 @@ export default definePlugin({ // Pass through editHistory & deleted & original attachments to the "edited message" transformer match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/, replace: - "Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory, attachments:$1.attachments })" + "Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory })" }, { From 9f79cc05a69dcf709d2612d921c2d9346589a605 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 6 Jul 2024 18:31:43 +0200 Subject: [PATCH 06/16] bump to v1.9.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc90a646c..ac4859593 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.3", + "version": "1.9.4", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From 02092a985c2f95f2f265387a849db8cec95742a8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 3 Jul 2024 21:38:21 +0200 Subject: [PATCH 07/16] BetterNotes: fix crashing --- src/components/VencordSettings/ThemesTab.tsx | 8 ++-- src/plugins/banger/index.ts | 22 ++++++---- src/plugins/betterNotes/index.tsx | 43 +++++++++++--------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx index 016371bed..aa8761d76 100644 --- a/src/components/VencordSettings/ThemesTab.tsx +++ b/src/components/VencordSettings/ThemesTab.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { useSettings } from "@api/Settings"; +import { Settings, useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import { Flex } from "@components/Flex"; import { DeleteIcon, FolderIcon, PaintbrushIcon, PencilIcon, PlusIcon, RestartIcon } from "@components/Icons"; @@ -32,6 +32,8 @@ import { findByPropsLazy, findLazy } from "@webpack"; import { Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common"; import type { ComponentType, Ref, SyntheticEvent } from "react"; +import Plugins from "~plugins"; + import { AddonCard } from "./AddonCard"; import { QuickAction, QuickActionCard } from "./quickActions"; import { SettingsTab, wrapTab } from "./shared"; @@ -250,10 +252,10 @@ function ThemesTab() { Icon={PaintbrushIcon} /> - {Vencord.Settings.plugins.ClientTheme.enabled && ( + {Settings.plugins.ClientTheme.enabled && ( openPluginModal(Vencord.Plugins.plugins.ClientTheme)} + action={() => openPluginModal(Plugins.ClientTheme)} Icon={PencilIcon} /> )} diff --git a/src/plugins/banger/index.ts b/src/plugins/banger/index.ts index 7e0d2df73..eca80f9ee 100644 --- a/src/plugins/banger/index.ts +++ b/src/plugins/banger/index.ts @@ -16,28 +16,34 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +const settings = definePluginSettings({ + source: { + description: "Source to replace ban GIF with (Video or Gif)", + type: OptionType.STRING, + default: "https://i.imgur.com/wp5q52C.mp4", + restartNeeded: true, + } +}); + export default definePlugin({ name: "BANger", description: "Replaces the GIF in the ban dialogue with a custom one.", authors: [Devs.Xinto, Devs.Glitch], + settings, patches: [ { find: "BAN_CONFIRM_TITLE.", replacement: { match: /src:\i\("?\d+"?\)/g, - replace: "src: Vencord.Settings.plugins.BANger.source" + replace: "src:$self.source" } } ], - options: { - source: { - description: "Source to replace ban GIF with (Video or Gif)", - type: OptionType.STRING, - default: "https://i.imgur.com/wp5q52C.mp4", - restartNeeded: true, - } + get source() { + return settings.store.source; } }); diff --git a/src/plugins/betterNotes/index.tsx b/src/plugins/betterNotes/index.tsx index cacdba5fd..b97076bf4 100644 --- a/src/plugins/betterNotes/index.tsx +++ b/src/plugins/betterNotes/index.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Settings } from "@api/Settings"; +import { definePluginSettings, Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { canonicalizeMatch } from "@utils/patches"; @@ -25,10 +25,26 @@ import { findByPropsLazy } from "@webpack"; const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection"); +const settings = definePluginSettings({ + hide: { + type: OptionType.BOOLEAN, + description: "Hide notes", + default: false, + restartNeeded: true + }, + noSpellCheck: { + type: OptionType.BOOLEAN, + description: "Disable spellcheck in notes", + disabled: () => Settings.plugins.BetterNotesBox.hide, + default: false + } +}); + export default definePlugin({ name: "BetterNotesBox", description: "Hide notes or disable spellcheck (Configure in settings!!)", authors: [Devs.Ven], + settings, patches: [ { @@ -36,7 +52,7 @@ export default definePlugin({ all: true, // Some modules match the find but the replacement is returned untouched noWarn: true, - predicate: () => Vencord.Settings.plugins.BetterNotesBox.hide, + predicate: () => settings.store.hide, replacement: { match: /hideNote:.+?(?=([,}].*?\)))/g, replace: (m, rest) => { @@ -54,7 +70,7 @@ export default definePlugin({ find: "Messages.NOTE_PLACEHOLDER", replacement: { match: /\.NOTE_PLACEHOLDER,/, - replace: "$&spellCheck:!Vencord.Settings.plugins.BetterNotesBox.noSpellCheck," + replace: "$&spellCheck:!$self.noSpellCheck," } }, { @@ -66,25 +82,14 @@ export default definePlugin({ } ], - options: { - hide: { - type: OptionType.BOOLEAN, - description: "Hide notes", - default: false, - restartNeeded: true - }, - noSpellCheck: { - type: OptionType.BOOLEAN, - description: "Disable spellcheck in notes", - disabled: () => Settings.plugins.BetterNotesBox.hide, - default: false - } - }, - patchPadding: ErrorBoundary.wrap(({ lastSection }) => { if (!lastSection) return null; return (
); - }) + }), + + get noSpellCheck() { + return settings.store.noSpellCheck; + } }); From 9f8c7494216b3d5aadb8d3fec14fa5ac7d8f448a Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 10 Jul 2024 04:33:03 -0300 Subject: [PATCH 08/16] Fix broken patches --- src/plugins/consoleJanitor/index.ts | 2 +- src/plugins/permissionsViewer/index.tsx | 2 +- src/plugins/reviewDB/index.tsx | 9 ++++----- src/plugins/showHiddenChannels/index.tsx | 6 +++--- src/plugins/viewIcons/index.tsx | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index 30887f5a7..dfb59957d 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -114,7 +114,7 @@ export default definePlugin({ '("MessageActionCreators")', '("ChannelMessages")', '("Routing/Utils")', '("RTCControlSocket")', '("ConnectionEventFramerateReducer")', '("RTCLatencyTestManager")', - '("OverlayBridgeStore")', '("RPCServer:WSS")' + '("OverlayBridgeStore")', '("RPCServer:WSS")', '("RPCServer:IPC")' ].map(logger => ({ find: logger, predicate: () => settings.store.disableNoisyLoggers, diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx index 6401d9450..6a503f2da 100644 --- a/src/plugins/permissionsViewer/index.tsx +++ b/src/plugins/permissionsViewer/index.tsx @@ -34,7 +34,7 @@ import UserPermissions from "./components/UserPermissions"; import { getSortedRoles, sortPermissionOverwrites } from "./utils"; const PopoutClasses = findByPropsLazy("container", "scroller", "list"); -const RoleButtonClasses = findByPropsLazy("button", "buttonInner", "icon", "text"); +const RoleButtonClasses = findByPropsLazy("button", "buttonInner", "icon", "banner"); export const enum PermissionsSortOrder { HighestRole, diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 7fdc1509a..456e15a57 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -37,8 +37,7 @@ import { getCurrentUserInfo, readNotification } from "./reviewDbApi"; import { settings } from "./settings"; import { showToast } from "./utils"; -const PopoutClasses = findByPropsLazy("container", "scroller", "list"); -const RoleButtonClasses = findByPropsLazy("button", "buttonInner", "icon", "text"); +const RoleButtonClasses = findByPropsLazy("button", "buttonInner", "icon", "banner"); const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => { if (!guild) return; @@ -181,9 +180,9 @@ export default definePlugin({ onClick={() => openReviewsModal(user.id, user.username)} look={Button.Looks.FILLED} size={Button.Sizes.NONE} - color={RoleButtonClasses.color} - className={classes(RoleButtonClasses.button, RoleButtonClasses.banner)} - innerClassName={classes(RoleButtonClasses.buttonInner, RoleButtonClasses.banner)} + color={RoleButtonClasses.bannerColor} + className={classes(RoleButtonClasses.button, RoleButtonClasses.icon, RoleButtonClasses.banner)} + innerClassName={classes(RoleButtonClasses.buttonInner, RoleButtonClasses.icon, RoleButtonClasses.banner)} > diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 538200afa..2d8b0c190 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -257,7 +257,7 @@ export default definePlugin({ { find: '"alt+shift+down"', replacement: { - match: /(?<=getChannel\(\i\);return null!=(\i))(?=.{0,150}?>0\)&&\(0,\i\.\i\)\(\i\))/, + match: /(?<=getChannel\(\i\);return null!=(\i))(?=.{0,200}?>0\)&&\(0,\i\.\i\)\(\i\))/, replace: (_, channel) => `&&!$self.isHiddenChannel(${channel})` } }, @@ -265,8 +265,8 @@ export default definePlugin({ { find: ".APPLICATION_STORE&&null!=", replacement: { - match: /(?<=getState\(\)\.channelId.{0,30}?\(0,\i\.\i\)\(\i\))(?=\.map\()/, - replace: ".filter(e=>!$self.isHiddenChannel(e))" + match: /getState\(\)\.channelId.+?(?=\.map\(\i=>\i\.id)/, + replace: "$&.filter(e=>!$self.isHiddenChannel(e))" } }, { diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index b2e7d56df..112f9f755 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -213,8 +213,8 @@ export default definePlugin({ { find: ".canUsePremiumProfileCustomization,{avatarSrc:", replacement: { - match: /children:\(0,\i\.jsx\)\(\i,{src:(\i)/, - replace: "style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)},$&" + match: /\.avatar,\i\.clickable\),onClick:\i,(?<=avatarSrc:(\i).+?)/, + replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," } }, From 04dce64bfd404900930839508b7bd9e4a0d0a7a1 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:56:02 -0300 Subject: [PATCH 09/16] Fix broken patches/finds --- src/plugins/friendsSince/index.tsx | 2 +- src/plugins/moreUserTags/index.tsx | 3 ++- src/plugins/viewIcons/index.tsx | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 629e8e719..717bd754c 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -17,7 +17,7 @@ const container = findByPropsLazy("memberSince"); const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"'); const locale = findByPropsLazy("getLocale"); const lastSection = findByPropsLazy("lastSection"); -const section = findLazy((m: any) => m.section !== void 0 && Object.values(m).length === 1); +const section = findLazy((m: any) => m.section !== void 0 && m.heading !== void 0 && Object.values(m).length === 2); export default definePlugin({ name: "FriendsSince", diff --git a/src/plugins/moreUserTags/index.tsx b/src/plugins/moreUserTags/index.tsx index be81a8a89..45538fb66 100644 --- a/src/plugins/moreUserTags/index.tsx +++ b/src/plugins/moreUserTags/index.tsx @@ -256,6 +256,7 @@ export default definePlugin({ // in profiles { find: ",overrideDiscriminator:", + group: true, replacement: [ { // prevent channel id from getting ghosted @@ -263,7 +264,7 @@ export default definePlugin({ match: /user:\i,nick:\i,/, replace: "$&moreTags_channelId," }, { - match: /,botType:(\i\((\i)\)),/g, + match: /,botType:(\i),(?<=user:(\i).+?)/g, replace: ",botType:$self.getTag({user:$2,channelId:moreTags_channelId,origType:$1,location:'not-chat'})," } ] diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 112f9f755..6ca9bf2d1 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -183,14 +183,24 @@ export default definePlugin({ }, patches: [ - // Profiles Modal pfp - ...[".MODAL,hasProfileEffect", ".FULL_SIZE,hasProfileEffect:"].map(find => ({ - find, + // Avatar component used in User DMs "User Profile" popup in the right and Profiles Modal pfp + { + find: ".overlay:void 0,status:", + replacement: [ + ...[/"PRESS_VIEW_PROFILE".+?(?=children:)(?<=avatarSrc:(\i).+?)/, /avatarSrc:(\i),eventHandlers:(\i).+?"div",{...\2,/].map(match => ({ + match, + replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," + })) + ] + }, + // Old Profiles Modal pfp + { + find: ".MODAL,hasProfileEffect", replacement: { match: /\{src:(\i)(?=,avatarDecoration)/, replace: "{src:$1,onClick:()=>$self.openImage($1)" } - })), + }, // Banners ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ find, @@ -202,7 +212,7 @@ export default definePlugin({ 'onClick:ev=>$1&&ev.target.style.backgroundImage&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,' } })), - // User DMs "User Profile" popup in the right + // Old User DMs "User Profile" popup in the right { find: ".avatarPositionPanel", replacement: { @@ -210,14 +220,6 @@ export default definePlugin({ replace: "$1style:($2)?{cursor:\"pointer\"}:{},onClick:$2?()=>{$self.openImage($3)}" } }, - { - find: ".canUsePremiumProfileCustomization,{avatarSrc:", - replacement: { - match: /\.avatar,\i\.clickable\),onClick:\i,(?<=avatarSrc:(\i).+?)/, - replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," - - } - }, // Group DMs top small & large icon { find: /\.recipients\.length>=2(?! Date: Fri, 12 Jul 2024 12:27:28 -0700 Subject: [PATCH 10/16] CtrlEnterSend: fix for new Discord update (#2689) Co-authored-by: vee --- src/plugins/ctrlEnterSend/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/ctrlEnterSend/index.ts b/src/plugins/ctrlEnterSend/index.ts index 6c9b7ac1d..4a1b73765 100644 --- a/src/plugins/ctrlEnterSend/index.ts +++ b/src/plugins/ctrlEnterSend/index.ts @@ -39,6 +39,15 @@ export default definePlugin({ } }), patches: [ + // Only one of the two patches will be at effect; Discord often updates to switch between them. + // See: https://discord.com/channels/1015060230222131221/1032770730703716362/1261398512017477673 + { + find: ".ENTER&&(!", + replacement: { + match: /(?<=(\i)\.which===\i\.\i.ENTER&&).{0,100}(\(0,\i\.\i\)\(\i\)).{0,100}(?=&&\(\i\.preventDefault)/, + replace: "$self.shouldSubmit($1, $2)" + } + }, { find: "!this.hasOpenCodeBlock()", replacement: { From 0057ab42e8e11f79589c9d17c24dddcafef18272 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:40:26 -0300 Subject: [PATCH 11/16] Fix broken experiments patch --- src/plugins/experiments/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/experiments/index.tsx b/src/plugins/experiments/index.tsx index 4cf8439bc..33c32b1a0 100644 --- a/src/plugins/experiments/index.tsx +++ b/src/plugins/experiments/index.tsx @@ -88,8 +88,8 @@ export default definePlugin({ { find: "useCanFavoriteChannel", replacement: { - match: /!\(\i\.isDM\(\)\|\|\i\.isThread\(\)\)/, - replace: "true", + match: /\i\.isDM\(\)\|\|\i\.isThread\(\)/, + replace: "false", } } ], From 92ae62602b3364f30bb69a7d0155bb2a1c0753d3 Mon Sep 17 00:00:00 2001 From: vee Date: Sat, 13 Jul 2024 19:14:22 +0200 Subject: [PATCH 12/16] new plugin MentionAvatars: Shows user avatars inside mentions (#2691) --- src/plugins/mentionAvatars/README.md | 5 +++ src/plugins/mentionAvatars/index.tsx | 44 +++++++++++++++++++++++ src/plugins/mentionAvatars/styles.css | 8 +++++ src/plugins/roleColorEverywhere/index.tsx | 2 +- src/plugins/showHiddenThings/index.ts | 39 +++++++------------- src/plugins/viewIcons/index.tsx | 10 +++--- 6 files changed, 75 insertions(+), 33 deletions(-) create mode 100644 src/plugins/mentionAvatars/README.md create mode 100644 src/plugins/mentionAvatars/index.tsx create mode 100644 src/plugins/mentionAvatars/styles.css diff --git a/src/plugins/mentionAvatars/README.md b/src/plugins/mentionAvatars/README.md new file mode 100644 index 000000000..912b51916 --- /dev/null +++ b/src/plugins/mentionAvatars/README.md @@ -0,0 +1,5 @@ +# MentionAvatars + +Shows user avatars inside mentions + +![](https://github.com/user-attachments/assets/fc76ea47-5e19-4063-a592-c57785a75cc7) diff --git a/src/plugins/mentionAvatars/index.tsx b/src/plugins/mentionAvatars/index.tsx new file mode 100644 index 000000000..549693142 --- /dev/null +++ b/src/plugins/mentionAvatars/index.tsx @@ -0,0 +1,44 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./styles.css"; + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { SelectedGuildStore, useState } from "@webpack/common"; +import { User } from "discord-types/general"; + +export default definePlugin({ + name: "MentionAvatars", + description: "Shows user avatars inside mentions", + authors: [Devs.Ven], + + patches: [{ + find: ".USER_MENTION)", + replacement: { + match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/, + replace: "children:$self.renderUsername({username:$1,user:$2})" + } + }], + + renderUsername: ErrorBoundary.wrap((props: { user: User, username: string; }) => { + const { user, username } = props; + const [isHovering, setIsHovering] = useState(false); + + if (!user) return <>@{username}; + + return ( + setIsHovering(true)} + onMouseLeave={() => setIsHovering(false)} + > + + @{username} + + ); + }, { noop: true }) +}); diff --git a/src/plugins/mentionAvatars/styles.css b/src/plugins/mentionAvatars/styles.css new file mode 100644 index 000000000..33404d7b5 --- /dev/null +++ b/src/plugins/mentionAvatars/styles.css @@ -0,0 +1,8 @@ +.vc-mentionAvatars-avatar { + vertical-align: middle; + width: 1em; + height: 1em; + margin: 0 4px 0.2rem 2px; + border-radius: 50%; + box-sizing: border-box; +} diff --git a/src/plugins/roleColorEverywhere/index.tsx b/src/plugins/roleColorEverywhere/index.tsx index 37177caad..3e7d216b7 100644 --- a/src/plugins/roleColorEverywhere/index.tsx +++ b/src/plugins/roleColorEverywhere/index.tsx @@ -60,7 +60,7 @@ export default definePlugin({ find: 'location:"UserMention', replacement: [ { - match: /user:(\i),channel:(\i).{0,400}?"@"\.concat\(.+?\)/, + match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/, replace: "$&,color:$self.getUserColor($1?.id,{channelId:$2?.id})" } ], diff --git a/src/plugins/showHiddenThings/index.ts b/src/plugins/showHiddenThings/index.ts index 599bcd36d..90bb345ef 100644 --- a/src/plugins/showHiddenThings/index.ts +++ b/src/plugins/showHiddenThings/index.ts @@ -18,34 +18,21 @@ import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; +import definePlugin, { OptionType, PluginSettingDef } from "@utils/types"; + +const opt = (description: string) => ({ + type: OptionType.BOOLEAN, + description, + default: true, + restartNeeded: true +} satisfies PluginSettingDef); const settings = definePluginSettings({ - showTimeouts: { - type: OptionType.BOOLEAN, - description: "Show member timeout icons in chat.", - default: true, - }, - showInvitesPaused: { - type: OptionType.BOOLEAN, - description: "Show the invites paused tooltip in the server list.", - default: true, - }, - showModView: { - type: OptionType.BOOLEAN, - description: "Show the member mod view context menu item in all servers.", - default: true, - }, - disableDiscoveryFilters: { - type: OptionType.BOOLEAN, - description: "Disable filters in Server Discovery search that hide servers that don't meet discovery criteria.", - default: true, - }, - disableDisallowedDiscoveryFilters: { - type: OptionType.BOOLEAN, - description: "Disable filters in Server Discovery search that hide NSFW & disallowed servers.", - default: true, - }, + showTimeouts: opt("Show member timeout icons in chat."), + showInvitesPaused: opt("Show the invites paused tooltip in the server list."), + showModView: opt("Show the member mod view context menu item in all servers."), + disableDiscoveryFilters: opt("Disable filters in Server Discovery search that hide servers that don't meet discovery criteria."), + disableDisallowedDiscoveryFilters: opt("Disable filters in Server Discovery search that hide NSFW & disallowed servers."), }); migratePluginSettings("ShowHiddenThings", "ShowTimeouts"); diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 6ca9bf2d1..6bde04be0 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -186,12 +186,10 @@ export default definePlugin({ // Avatar component used in User DMs "User Profile" popup in the right and Profiles Modal pfp { find: ".overlay:void 0,status:", - replacement: [ - ...[/"PRESS_VIEW_PROFILE".+?(?=children:)(?<=avatarSrc:(\i).+?)/, /avatarSrc:(\i),eventHandlers:(\i).+?"div",{...\2,/].map(match => ({ - match, - replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," - })) - ] + replacement: { + match: /avatarSrc:(\i),eventHandlers:(\i).+?"div",{...\2,/, + replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openImage($1)}," + } }, // Old Profiles Modal pfp { From 0e7570ad713a91959c6b3095cf426698b7907e5f Mon Sep 17 00:00:00 2001 From: Hen <68553709+henmalib@users.noreply.github.com> Date: Sat, 13 Jul 2024 19:17:00 +0200 Subject: [PATCH 13/16] InvisibleChat: fix embeds missing decrypted content (#2655) --- src/plugins/invisibleChat.desktop/index.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/invisibleChat.desktop/index.tsx b/src/plugins/invisibleChat.desktop/index.tsx index 01199d999..c7eb29e7e 100644 --- a/src/plugins/invisibleChat.desktop/index.tsx +++ b/src/plugins/invisibleChat.desktop/index.tsx @@ -133,10 +133,12 @@ export default definePlugin({ message: message, channel: ChannelStore.getChannel(message.channel_id), onClick: async () => { - await iteratePasswords(message).then((res: string | false) => { - if (res) return void this.buildEmbed(message, res); - return void buildDecModal({ message }); - }); + const res = await iteratePasswords(message); + + if (res) + this.buildEmbed(message, res); + else + buildDecModal({ message }); } } : null; @@ -169,9 +171,9 @@ export default definePlugin({ message.embeds.push({ type: "rich", - title: "Decrypted Message", + rawTitle: "Decrypted Message", color: "0x45f5f5", - description: revealed, + rawDescription: revealed, footer: { text: "Made with ❤️ by c0dine and Sammy!", }, From bbf43c3073a6393d9c6cbc1e815790ecdcf2505d Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 13 Jul 2024 20:34:16 +0200 Subject: [PATCH 14/16] fix(FakeNitro): do not convert applicable twitch sub emotes --- src/plugins/fakeNitro/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index ddcabcbdf..efc194954 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -24,7 +24,7 @@ import { getCurrentGuild } from "@utils/discord"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack"; -import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; +import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common"; import type { Emoji } from "@webpack/types"; import type { Message } from "discord-types/general"; import { applyPalette, GIFEncoder, quantize } from "gifenc"; @@ -818,7 +818,14 @@ export default definePlugin({ if (isUnusableRoleSubscriptionEmoji(e, this.guildId, true)) return false; - if (this.canUseEmotes) + let isUsableTwitchSubEmote = false; + if (e.managed && e.guildId) { + // @ts-ignore outdated type + const myRoles = GuildMemberStore.getSelfMember(e.guildId)?.roles ?? []; + isUsableTwitchSubEmote = e.roles.some(r => myRoles.includes(r)); + } + + if (this.canUseEmotes || isUsableTwitchSubEmote) return e.guildId === this.guildId || hasExternalEmojiPerms(channelId); else return !e.animated && e.guildId === this.guildId; From 71977f070a273634a6eb008db75012fcc2542241 Mon Sep 17 00:00:00 2001 From: Jono99 <42048866+Jono997@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:24:55 +1000 Subject: [PATCH 15/16] fix(ShowMeYourName) - proper case insensitive name comparison (#2633) Co-authored-by: vee --- src/plugins/showMeYourName/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index 8d1504e1a..4f9fcf304 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -67,7 +67,7 @@ export default definePlugin({ const { nick } = author; const prefix = withMentionPrefix ? "@" : ""; - if (isRepliedMessage && !settings.store.inReplies || username === nick.toLowerCase()) + if (isRepliedMessage && !settings.store.inReplies || username.toLowerCase() === nick.toLowerCase()) return <>{prefix}{nick}; if (settings.store.mode === "user-nick") From 2b273d9dbde7e10980f42d89c06c58634fb6c34a Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 15 Jul 2024 03:53:29 +0200 Subject: [PATCH 16/16] fix(MessageLogger edits): render with proper guild context --- src/plugins/messageLogger/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/messageLogger/index.tsx b/src/plugins/messageLogger/index.tsx index 6969f0909..f88af01a0 100644 --- a/src/plugins/messageLogger/index.tsx +++ b/src/plugins/messageLogger/index.tsx @@ -27,7 +27,7 @@ import { Devs } from "@utils/constants"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, FluxDispatcher, i18n, Menu, MessageStore, Parser, Timestamp, UserStore, useStateFromStores } from "@webpack/common"; +import { ChannelStore, FluxDispatcher, i18n, Menu, MessageStore, Parser, SelectedChannelStore, Timestamp, UserStore, useStateFromStores } from "@webpack/common"; import { Message } from "discord-types/general"; import overlayStyle from "./deleteStyleOverlay.css?managed"; @@ -154,7 +154,15 @@ export default definePlugin({ <> {message.editHistory?.map(edit => (
- {Parser.parse(edit.content)} + {Parser.parse(edit.content, true, { + channelId, + messageId, + allowLinks: true, + allowHeading: true, + allowList: true, + allowEmojiLinks: true, + viewingChannelId: SelectedChannelStore.getChannelId(), + })}