From d0a47aa602769d3d83d4a9e2b59b1be35ccef072 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:09:21 -0400 Subject: [PATCH] Fixes For Canary --- README.md | 3 +- src/equicordplugins/clientSideBlock/index.tsx | 2 +- src/equicordplugins/demonstration/index.tsx | 1 - .../fixFileExtensions/index.tsx | 10 +- src/equicordplugins/spoilerMessages/index.tsx | 181 ------------------ src/plugins/anonymiseFileNames/index.tsx | 52 +++-- .../index.ts | 10 +- 7 files changed, 45 insertions(+), 214 deletions(-) delete mode 100644 src/equicordplugins/spoilerMessages/index.tsx rename src/plugins/{disableDeepLinks.equibop => noDeepLinks.web}/index.ts (57%) diff --git a/README.md b/README.md index 2531b830..8d061fa3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch ### Extra included plugins
-164 additional plugins +163 additional plugins ### All Platforms @@ -144,7 +144,6 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - StatusPresets by iamme - SteamStatusSync by niko - StickerBlocker by Samwich -- SpoilerMessages by omaw - TalkInReverse by Tolgchu - TeX by Kyuuhachi - TextToSpeech by Samwich diff --git a/src/equicordplugins/clientSideBlock/index.tsx b/src/equicordplugins/clientSideBlock/index.tsx index 3ce827ff..e5993d72 100644 --- a/src/equicordplugins/clientSideBlock/index.tsx +++ b/src/equicordplugins/clientSideBlock/index.tsx @@ -152,7 +152,7 @@ export default definePlugin({ { find: "._areActivitiesExperimentallyHidden=(", replacement: { - match: /new Date\(\i\):null;/, + match: /BOOST_GEM_ICON\}\}\)\)\};/, replace: "$&if($self.shouldHideUser(this.props.user.id, this.props.channel.id)) return null; " } }, diff --git a/src/equicordplugins/demonstration/index.tsx b/src/equicordplugins/demonstration/index.tsx index 8befd47e..54c2b459 100644 --- a/src/equicordplugins/demonstration/index.tsx +++ b/src/equicordplugins/demonstration/index.tsx @@ -126,7 +126,6 @@ async function playSound(url: string) { audio.remove(); } - export default definePlugin({ name: "Demonstration", description: "Plugin for taking theme screenshots - censors identifying images and text.", diff --git a/src/equicordplugins/fixFileExtensions/index.tsx b/src/equicordplugins/fixFileExtensions/index.tsx index 472a473b..adeef42b 100644 --- a/src/equicordplugins/fixFileExtensions/index.tsx +++ b/src/equicordplugins/fixFileExtensions/index.tsx @@ -6,7 +6,6 @@ import { Upload } from "@api/MessageEvents"; import { Settings } from "@api/Settings"; -import { spoiler } from "@equicordplugins/spoilerMessages"; import { tarExtMatcher } from "@plugins/anonymiseFileNames"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { ReporterTestable } from "@utils/types"; @@ -36,33 +35,30 @@ export default definePlugin({ // Taken from AnonymiseFileNames { find: "instantBatchUpload:", - predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.SpoilerMessages, replacement: { match: /uploadFiles:(\i),/, replace: "uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=$self.fixExt(f)),$1(...args)),", }, + predicate: () => !Settings.plugins.AnonymiseFileNames.enabled, }, // Also taken from AnonymiseFileNames { find: 'addFilesTo:"message.attachments"', - predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.SpoilerMessages, replacement: { match: /(\i.uploadFiles\((\i),)/, replace: "$2.forEach(f=>f.filename=$self.fixExt(f)),$1", }, + predicate: () => !Settings.plugins.AnonymiseFileNames.enabled, } ], fixExt(upload: ExtUpload) { const file = upload.filename; const tarMatch = tarExtMatcher.exec(file); const extIdx = tarMatch?.index ?? file.lastIndexOf("."); - let fileName = extIdx !== -1 ? file.substring(0, extIdx) : ""; + const fileName = extIdx !== -1 ? file.substring(0, extIdx) : ""; const ext = extIdx !== -1 ? file.slice(extIdx) : ""; const newExt = reverseExtensionMap[ext] || ext; - if (Settings.plugins.SpoilerMessages.enabled) { - fileName = spoiler(upload); - } return fileName + newExt; }, diff --git a/src/equicordplugins/spoilerMessages/index.tsx b/src/equicordplugins/spoilerMessages/index.tsx deleted file mode 100644 index b7a7a5fa..00000000 --- a/src/equicordplugins/spoilerMessages/index.tsx +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { addChatBarButton, ChatBarButton, ChatBarButtonFactory, removeChatBarButton } from "@api/ChatButtons"; -import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; -import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; -import { addMessagePreSendListener, removeMessagePreSendListener, Upload } from "@api/MessageEvents"; -import { definePluginSettings, Settings } from "@api/Settings"; -import { reverseExtensionMap } from "@equicordplugins/fixFileExtensions"; -import { tarExtMatcher } from "@plugins/anonymiseFileNames"; -import { Devs, EquicordDevs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; -import { Menu, React } from "@webpack/common"; - -// thnx signature / anonymize code -type SpoilUpload = Upload; -const settings = definePluginSettings( - { - spoilerWords: { - type: OptionType.BOOLEAN, - default: true, - description: "This will add a spoiler for every word within the message / attachments.", - restartNeeded: true, - }, - showIcon: { - type: OptionType.BOOLEAN, - default: true, - description: "Show an icon for toggling the plugin in the chat bar", - restartNeeded: true, - }, - contextMenu: { - type: OptionType.BOOLEAN, - description: "Add option to toggle the functionality in the chat input context menu", - default: true - }, - isEnabled: { - type: OptionType.BOOLEAN, - description: "Toggle functionality", - default: true, - }, - }); - -const SpoilerToggle: ChatBarButtonFactory = ({ isMainChat }) => { - const { isEnabled, showIcon } = settings.use(["isEnabled", "showIcon"]); - const toggle = () => settings.store.isEnabled = !settings.store.isEnabled; - - if (!isMainChat || !showIcon) return null; - - return ( - - - - {isEnabled && ( - <> - - - - - - - )} - - - ); -}; - -const handleMessage = (channelId, msg) => { - if (!settings.store.isEnabled || settings.store.isEnabled && msg.content.trim() === "") { - msg.content = msg.content; - } else if (settings.store.isEnabled && settings.store.spoilerWords) { - msg.content = msg.content.split(/(\s+)/).map(word => word.trim() ? `||${word}||` : word).join(""); - } else { - msg.content = textProcessing(msg.content); - } -}; - - -const ChatBarContextCheckbox: NavContextMenuPatchCallback = children => { - const { isEnabled, contextMenu } = settings.use(["isEnabled", "contextMenu"]); - if (!contextMenu) return; - - const group = findGroupChildrenByChildId("submit-button", children); - - if (!group) return; - - const idx = group.findIndex(c => c?.props?.id === "submit-button"); - - group.splice(idx + 1, 0, - settings.store.isEnabled = !settings.store.isEnabled} - /> - ); -}; - -export function spoiler(upload: SpoilUpload) { - const file = upload.filename; - const tarMatch = tarExtMatcher.exec(file); - const extIdx = tarMatch?.index ?? file.lastIndexOf("."); - const fileName = extIdx !== -1 ? file.substring(0, extIdx) : ""; - let ext = extIdx !== -1 ? file.slice(extIdx) : ""; - if (Settings.plugins.FixFileExtensions.enabled) { - ext = reverseExtensionMap[ext] || ext; - } - if (settings.store.isEnabled) return "SPOILER_" + fileName + ext; - return file; -} - -export default definePlugin({ - name: "SpoilerMessages", - description: "Automatically turn all your messages / attachments into a spoiler.", - authors: [Devs.Ven, Devs.Rini, Devs.ImBanana, Devs.fawn, EquicordDevs.KrystalSkull, EquicordDevs.omaw], - dependencies: ["MessageEventsAPI", "ChatInputButtonAPI"], - patches: [ - { - find: "instantBatchUpload:", - replacement: { - match: /uploadFiles:(\i),/, - replace: - "uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=$self.spoiler(f)),$1(...args)),", - }, - predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.FixFileExtensions, - }, - { - find: 'addFilesTo:"message.attachments"', - replacement: { - match: /(\i.uploadFiles\((\i),)/, - replace: "$2.forEach(f=>f.filename=$self.spoiler(f)),$1" - }, - predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.FixFileExtensions, - }, - ], - spoiler, - start: () => { - if (settings.store.isEnabled) true; - addChatBarButton("Spoiler", SpoilerToggle); - addMessagePreSendListener(handleMessage); - }, - stop: () => { - if (settings.store.isEnabled) false; - removeChatBarButton("Spoiler"); - removeMessagePreSendListener(handleMessage); - - }, - settings, - contextMenus: { - "textarea-context": ChatBarContextCheckbox - }, - commands: [{ - name: "Spoiler", - description: "Toggle your spoiler", - inputType: ApplicationCommandInputType.BUILT_IN, - options: [ - { - name: "value", - description: "Toggle your Spoiler (default is toggle)", - required: false, - type: ApplicationCommandOptionType.BOOLEAN, - }, - ], - execute: async (args, ctx) => { - settings.store.isEnabled = !!findOption(args, "value", !settings.store.isEnabled); - sendBotMessage(ctx.channel.id, { - content: settings.store.isEnabled ? "Spoiler enabled!" : "Spoiler disabled!", - }); - }, - }], -}); - -// text processing injection processor -function textProcessing(input: string) { - return `||${input}||`; -} diff --git a/src/plugins/anonymiseFileNames/index.tsx b/src/plugins/anonymiseFileNames/index.tsx index 5ab14e2d..2d0cdd5f 100644 --- a/src/plugins/anonymiseFileNames/index.tsx +++ b/src/plugins/anonymiseFileNames/index.tsx @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +import { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands"; import { Upload } from "@api/MessageEvents"; import { definePluginSettings, Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { reverseExtensionMap } from "@equicordplugins/fixFileExtensions"; -import { spoiler } from "@equicordplugins/spoilerMessages"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy } from "@webpack"; @@ -65,6 +65,11 @@ const settings = definePluginSettings({ default: "image", disabled: () => settings.store.method !== Methods.Consistent, }, + spoilerMessages: { + description: "Spoiler messages", + type: OptionType.BOOLEAN, + default: false, + } }); export default definePlugin({ @@ -119,15 +124,15 @@ export default definePlugin({ const file = upload.filename; const tarMatch = tarExtMatcher.exec(file); const extIdx = tarMatch?.index ?? file.lastIndexOf("."); - let fileName = extIdx !== -1 ? file.substring(0, extIdx) : ""; + const fileName = extIdx !== -1 ? file.substring(0, extIdx) : ""; let ext = extIdx !== -1 ? file.slice(extIdx) : ""; + const addSpoilerPrefix = (str: string) => settings.store.spoilerMessages ? "SPOILER_" + str : str; + if (Settings.plugins.FixFileExtensions.enabled) { ext = reverseExtensionMap[ext] || ext; } - if (Settings.plugins.SpoilerMessages.enabled) { - fileName = spoiler(upload); - } - if ((upload.anonymise ?? settings.store.anonymiseByDefault) === false) return fileName + ext; + + if ((upload.anonymise ?? settings.store.anonymiseByDefault) === false) return addSpoilerPrefix(fileName + ext); switch (settings.store.method) { case Methods.Random: @@ -136,20 +141,31 @@ export default definePlugin({ { length: settings.store.randomisedLength }, () => chars[Math.floor(Math.random() * chars.length)] ).join("") + ext; - if (Settings.plugins.SpoilerMessages.enabled) { - return "SPOILER_" + returnedName; - } - return returnedName; + return addSpoilerPrefix(returnedName); case Methods.Consistent: - if (Settings.plugins.SpoilerMessages.enabled) { - return "SPOILER_" + settings.store.consistent + ext; - } - return settings.store.consistent + ext; + return addSpoilerPrefix(settings.store.consistent + ext); case Methods.Timestamp: - if (Settings.plugins.SpoilerMessages.enabled) { - return "SPOILER_" + Date.now() + ext; - } - return Date.now() + ext; + return addSpoilerPrefix(Date.now().toString() + ext); } }, + + commands: [{ + name: "Spoiler", + description: "Toggle your spoiler", + inputType: ApplicationCommandInputType.BUILT_IN, + options: [ + { + name: "value", + description: "Toggle your Spoiler (default is toggle)", + required: false, + type: ApplicationCommandOptionType.BOOLEAN, + }, + ], + execute: async (args, ctx) => { + settings.store.spoilerMessages = !!findOption(args, "value", !settings.store.spoilerMessages); + sendBotMessage(ctx.channel.id, { + content: settings.store.spoilerMessages ? "Spoiler enabled!" : "Spoiler disabled!", + }); + }, + }], }); diff --git a/src/plugins/disableDeepLinks.equibop/index.ts b/src/plugins/noDeepLinks.web/index.ts similarity index 57% rename from src/plugins/disableDeepLinks.equibop/index.ts rename to src/plugins/noDeepLinks.web/index.ts index c917181b..e217308a 100644 --- a/src/plugins/disableDeepLinks.equibop/index.ts +++ b/src/plugins/noDeepLinks.web/index.ts @@ -9,15 +9,17 @@ import definePlugin from "@utils/types"; export default definePlugin({ name: "DisableDeepLinks", - description: "Disables Discord stupid DeepLinks experiment which makes the app unusable", + description: "Disables Discord's stupid deep linking feature which tries to force you to use their Desktop App", authors: [Devs.Ven], required: true, + noop: () => { }, + patches: [{ - find: "2025-03_desktop_deeplinks", + find: /\.openNativeAppModal\(.{0,50}?\.DEEP_LINK/, replacement: { - match: /config:{enabled:!0/, - replace: "config:{enabled:!1", + match: /\i\.\i\.openNativeAppModal/, + replace: "$self.noop", } }] });