From 82e444e19635a72d2e1c4d043840bdfd358fa120 Mon Sep 17 00:00:00 2001 From: Ven Date: Mon, 14 Nov 2022 18:05:41 +0100 Subject: [PATCH] Less confusing plugin names (bulk plugin rename) (#214) Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> --- src/api/settings.ts | 20 ++++++++++++++++ src/plugins/apiMenuItemDeobfuscator.ts | 4 +++- src/plugins/apiNotices.ts | 5 +++- src/plugins/clearURLs/index.ts | 6 +++-- .../{emoteYoink.tsx => emoteCloner.tsx} | 24 ++++++++++--------- src/plugins/{nitroBypass.ts => fakeNitro.ts} | 19 ++++++++------- src/plugins/messageActions.ts | 7 ++++-- .../{moarKaomojis.ts => moreKaomoji.ts} | 6 +++-- src/plugins/{STFU.ts => noDevtoolsWarning.ts} | 5 +++- .../{interactionKeybinds.ts => quickReply.ts} | 5 +++- src/plugins/reverseImageSearch.tsx | 4 ++-- src/plugins/spotifyControls/index.tsx | 2 +- src/plugins/{ify.ts => spotifyCrack.ts} | 10 ++++---- .../{sendify.ts => spotifyShareCommands.ts} | 6 +++-- src/plugins/vcDoubleClick.ts | 10 ++++---- src/plugins/viewIcons.tsx | 2 +- src/webpack/common.tsx | 4 ++-- 17 files changed, 94 insertions(+), 45 deletions(-) rename src/plugins/{emoteYoink.tsx => emoteCloner.tsx} (93%) rename src/plugins/{nitroBypass.ts => fakeNitro.ts} (94%) rename src/plugins/{moarKaomojis.ts => moreKaomoji.ts} (89%) rename src/plugins/{STFU.ts => noDevtoolsWarning.ts} (89%) rename src/plugins/{interactionKeybinds.ts => quickReply.ts} (97%) rename src/plugins/{ify.ts => spotifyCrack.ts} (84%) rename src/plugins/{sendify.ts => spotifyShareCommands.ts} (94%) diff --git a/src/api/settings.ts b/src/api/settings.ts index 9e518c67..dd8692a2 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -19,10 +19,12 @@ import plugins from "~plugins"; import IpcEvents from "../utils/IpcEvents"; +import Logger from "../utils/Logger"; import { mergeDefaults } from "../utils/misc"; import { OptionType } from "../utils/types"; import { React } from "../webpack/common"; +const logger = new Logger("Settings"); export interface Settings { notifyAboutUpdates: boolean; useQuickCss: boolean; @@ -169,3 +171,21 @@ export function addSettingsListener(path: string, onUpdate: (newValue: any, path (onUpdate as SubscriptionCallback)._path = path; subscriptions.add(onUpdate); } + +export function migratePluginSettings(name: string, ...oldNames: string[]) { + const { plugins } = settings; + if (name in plugins) return; + + for (const oldName of oldNames) { + if (oldName in plugins) { + logger.info(`Migrating settings from old name ${oldName} to ${name}`); + plugins[name] = plugins[oldName]; + delete plugins[oldName]; + VencordNative.ipc.invoke( + IpcEvents.SET_SETTINGS, + JSON.stringify(settings, null, 4) + ); + break; + } + } +} diff --git a/src/plugins/apiMenuItemDeobfuscator.ts b/src/plugins/apiMenuItemDeobfuscator.ts index 59d40cfb..40d53f19 100644 --- a/src/plugins/apiMenuItemDeobfuscator.ts +++ b/src/plugins/apiMenuItemDeobfuscator.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; @@ -33,8 +34,9 @@ const nameMap = { customitem: "MenuItem", }; +migratePluginSettings("MenuItemDeobfuscatorAPI", "MenuItemDeobfuscatorApi"); export default definePlugin({ - name: "MenuItemDeobfuscatorApi", + name: "MenuItemDeobfuscatorAPI", description: "Deobfuscates Discord's Menu Item module", authors: [Devs.Ven], patches: [ diff --git a/src/plugins/apiNotices.ts b/src/plugins/apiNotices.ts index 1a1df4b2..f53c5351 100644 --- a/src/plugins/apiNotices.ts +++ b/src/plugins/apiNotices.ts @@ -16,11 +16,14 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; +migratePluginSettings("NoticesAPI", "NoticesApi"); + export default definePlugin({ - name: "NoticesApi", + name: "NoticesAPI", description: "Fixes notices being automatically dismissed", authors: [Devs.Ven], required: true, diff --git a/src/plugins/clearURLs/index.ts b/src/plugins/clearURLs/index.ts index b01faedb..f5b89099 100644 --- a/src/plugins/clearURLs/index.ts +++ b/src/plugins/clearURLs/index.ts @@ -21,8 +21,9 @@ import { addPreSendListener, MessageObject, removePreEditListener, - removePreSendListener, + removePreSendListener } from "../../api/MessageEvents"; +import { migratePluginSettings } from "../../api/settings"; import { Devs } from "../../utils/constants"; import definePlugin from "../../utils/types"; import { defaultRules } from "./defaultRules"; @@ -31,8 +32,9 @@ import { defaultRules } from "./defaultRules"; const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; const reHasRegExpChar = RegExp(reRegExpChar.source); +migratePluginSettings("ClearURLs", "clearURLs"); export default definePlugin({ - name: "clearURLs", + name: "ClearURLs", description: "Removes tracking garbage from URLs", authors: [Devs.adryd], dependencies: ["MessageEventsAPI"], diff --git a/src/plugins/emoteYoink.tsx b/src/plugins/emoteCloner.tsx similarity index 93% rename from src/plugins/emoteYoink.tsx rename to src/plugins/emoteCloner.tsx index becc6d1e..0b1190be 100644 --- a/src/plugins/emoteYoink.tsx +++ b/src/plugins/emoteCloner.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -import { Settings } from "../api/settings"; +import { migratePluginSettings, Settings } from "../api/settings"; import { CheckedTextInput } from "../components/CheckedTextInput"; import { Devs } from "../utils/constants"; +import Logger from "../utils/Logger"; import { lazyWebpack, makeLazy } from "../utils/misc"; import { ModalContent, ModalHeader, ModalRoot, openModal } from "../utils/modal"; import definePlugin from "../utils/types"; @@ -60,12 +61,12 @@ async function doClone(guildId: string, id: string, name: string, isAnimated: bo image: reader.result }).then(() => { Toasts.show({ - message: `Successfully yoinked ${name}!`, + message: `Successfully cloned ${name}!`, type: Toasts.Type.SUCCESS, id: Toasts.genId() }); - }).catch(e => { - console.error("[EmoteYoink] Failed to upload emoji", e); + }).catch((e: any) => { + new Logger("EmoteCloner").error("Failed to upload emoji", e); Toasts.show({ message: "Oopsie something went wrong :( Check console!!!", type: Toasts.Type.FAILURE, @@ -174,18 +175,19 @@ function CloneModal({ id, name: emojiName, isAnimated }: { id: string; name: str ); } +migratePluginSettings("EmoteCloner", "EmoteYoink"); export default definePlugin({ - name: "EmoteYoink", - description: "Clone emotes to your own server", + name: "EmoteCloner", + description: "Adds a Clone context menu item to emotes to clone them your own server", authors: [Devs.Ven], - dependencies: ["MenuItemDeobfuscatorApi"], + dependencies: ["MenuItemDeobfuscatorAPI"], patches: [{ // Literally copy pasted from ReverseImageSearch lol find: "open-native-link", replacement: { match: /id:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\},"open-native-link"\)/, - replace: "$&,Vencord.Plugins.plugins.EmoteYoink.makeMenu(arguments[2])" + replace: "$&,Vencord.Plugins.plugins.EmoteCloner.makeMenu(arguments[2])" }, }, @@ -214,9 +216,9 @@ export default definePlugin({ const isAnimated = new URL(htmlElement.src).pathname.endsWith(".gif"); return openModal(modalProps => ( diff --git a/src/plugins/nitroBypass.ts b/src/plugins/fakeNitro.ts similarity index 94% rename from src/plugins/nitroBypass.ts rename to src/plugins/fakeNitro.ts index e455ab6a..e7ef401a 100644 --- a/src/plugins/nitroBypass.ts +++ b/src/plugins/fakeNitro.ts @@ -17,6 +17,7 @@ */ import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "../api/MessageEvents"; +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import { ApngDisposeOp, getGifEncoder, importApngJs } from "../utils/dependencies"; import { lazyWebpack } from "../utils/misc"; @@ -55,8 +56,10 @@ interface StickerPack { stickers: Sticker[]; } +migratePluginSettings("FakeNitro", "NitroBypass"); + export default definePlugin({ - name: "NitroBypass", + name: "FakeNitro", authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven], description: "Allows you to stream in nitro quality and send fake emojis/stickers.", dependencies: ["MessageEventsAPI"], @@ -64,7 +67,7 @@ export default definePlugin({ patches: [ { find: "canUseAnimatedEmojis:function", - predicate: () => Settings.plugins.NitroBypass.enableEmojiBypass === true, + predicate: () => Settings.plugins.FakeNitro.enableEmojiBypass === true, replacement: [ "canUseAnimatedEmojis", "canUseEmojisEverywhere" @@ -77,7 +80,7 @@ export default definePlugin({ }, { find: "canUseAnimatedEmojis:function", - predicate: () => Settings.plugins.NitroBypass.enableStickerBypass === true, + predicate: () => Settings.plugins.FakeNitro.enableStickerBypass === true, replacement: { match: /canUseStickersEverywhere:function\(.+?}/, replace: "canUseStickersEverywhere:function(e){return true;}" @@ -92,7 +95,7 @@ export default definePlugin({ }, { find: "canUseAnimatedEmojis:function", - predicate: () => Settings.plugins.NitroBypass.enableStreamQualityBypass === true, + predicate: () => Settings.plugins.FakeNitro.enableStreamQualityBypass === true, replacement: [ "canUseHighVideoUploadQuality", "canStreamHighQuality", @@ -106,7 +109,7 @@ export default definePlugin({ }, { find: "STREAM_FPS_OPTION.format", - predicate: () => Settings.plugins.NitroBypass.enableStreamQualityBypass === true, + predicate: () => Settings.plugins.FakeNitro.enableStreamQualityBypass === true, replacement: { match: /(userPremiumType|guildPremiumTier):.{0,10}TIER_\d,?/g, replace: "" @@ -154,7 +157,7 @@ export default definePlugin({ }, getStickerLink(stickerId: string) { - return `https://media.discordapp.net/stickers/${stickerId}.png?size=${Settings.plugins.NitroBypass.stickerSize}`; + return `https://media.discordapp.net/stickers/${stickerId}.png?size=${Settings.plugins.FakeNitro.stickerSize}`; }, async sendAnimatedSticker(stickerLink: string, stickerId: string, channelId: string) { @@ -167,7 +170,7 @@ export default definePlugin({ const { frames, width, height } = await parseURL(stickerLink); const gif = new GIFEncoder(); - const resolution = Settings.plugins.NitroBypass.stickerSize; + const resolution = Settings.plugins.FakeNitro.stickerSize; const canvas = document.createElement("canvas"); canvas.width = resolution; @@ -210,7 +213,7 @@ export default definePlugin({ }, start() { - const settings = Settings.plugins.NitroBypass; + const settings = Settings.plugins.FakeNitro; if (!settings.enableEmojiBypass && !settings.enableStickerBypass) { return; } diff --git a/src/plugins/messageActions.ts b/src/plugins/messageActions.ts index bb2ad173..05d792f1 100644 --- a/src/plugins/messageActions.ts +++ b/src/plugins/messageActions.ts @@ -17,6 +17,7 @@ */ import { addClickListener, removeClickListener } from "../api/MessageEvents"; +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import { lazyWebpack } from "../utils/misc"; import definePlugin from "../utils/types"; @@ -27,9 +28,11 @@ let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = false); +migratePluginSettings("MessageClickActions", "MessageQuickActions"); + export default definePlugin({ - name: "MessageQuickActions", - description: "Quick Delete, Quick edit", + name: "MessageClickActions", + description: "Hold Delete and click to delete, double click to edit", authors: [Devs.Ven], dependencies: ["MessageEventsAPI"], diff --git a/src/plugins/moarKaomojis.ts b/src/plugins/moreKaomoji.ts similarity index 89% rename from src/plugins/moarKaomojis.ts rename to src/plugins/moreKaomoji.ts index 8b3c0c58..ef6dc0fd 100644 --- a/src/plugins/moarKaomojis.ts +++ b/src/plugins/moreKaomoji.ts @@ -17,12 +17,14 @@ */ import { findOption, OptionalMessageOption } from "../api/Commands"; +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; +migratePluginSettings("MoreKaomoji", "moarKaomojis"); export default definePlugin({ - name: "moarKaomojis", - description: "Adds more Kaomojis to discord. ヽ(´▽`)/", + name: "MoreKaomoji", + description: "Adds more Kaomoji to discord. ヽ(´▽`)/", authors: [Devs.JacobTm], dependencies: ["CommandsAPI"], commands: [ diff --git a/src/plugins/STFU.ts b/src/plugins/noDevtoolsWarning.ts similarity index 89% rename from src/plugins/STFU.ts rename to src/plugins/noDevtoolsWarning.ts index 66392c85..2ceb0c3f 100644 --- a/src/plugins/STFU.ts +++ b/src/plugins/noDevtoolsWarning.ts @@ -16,11 +16,14 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; +migratePluginSettings("NoDevtoolsWarning", "STFU"); + export default definePlugin({ - name: "STFU", + name: "NoDevtoolsWarning", description: "Disables the 'HOLD UP' banner in the console", authors: [Devs.Ven], patches: [{ diff --git a/src/plugins/interactionKeybinds.ts b/src/plugins/quickReply.ts similarity index 97% rename from src/plugins/interactionKeybinds.ts rename to src/plugins/quickReply.ts index 61af4ace..2903b398 100644 --- a/src/plugins/interactionKeybinds.ts +++ b/src/plugins/quickReply.ts @@ -18,6 +18,7 @@ import { Message } from "discord-types/general"; +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import { lazyWebpack } from "../utils/misc"; import definePlugin from "../utils/types"; @@ -30,8 +31,10 @@ const isMac = navigator.platform.includes("Mac"); // bruh let replyIdx = -1; let editIdx = -1; +migratePluginSettings("QuickReply", "InteractionKeybinds"); + export default definePlugin({ - name: "InteractionKeybinds", + name: "QuickReply", authors: [Devs.obscurity, Devs.Ven], description: "Reply to (ctrl + up/down) and edit (ctrl + shift + up/down) messages via keybinds", diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index 2d666362..804ac048 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -30,9 +30,9 @@ const Engines = { export default definePlugin({ name: "ReverseImageSearch", - description: "yes", + description: "Adds ImageSearch to image context menus", authors: [Devs.Ven], - dependencies: ["MenuItemDeobfuscatorApi"], + dependencies: ["MenuItemDeobfuscatorAPI"], patches: [{ find: "open-native-link", replacement: { diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx index e8b53702..14c7a939 100644 --- a/src/plugins/spotifyControls/index.tsx +++ b/src/plugins/spotifyControls/index.tsx @@ -24,7 +24,7 @@ export default definePlugin({ name: "SpotifyControls", description: "Spotify Controls", authors: [Devs.Ven, Devs.afn, Devs.KraXen72], - dependencies: ["MenuItemDeobfuscatorApi"], + dependencies: ["MenuItemDeobfuscatorAPI"], patches: [ { find: "showTaglessAccountPanel:", diff --git a/src/plugins/ify.ts b/src/plugins/spotifyCrack.ts similarity index 84% rename from src/plugins/ify.ts rename to src/plugins/spotifyCrack.ts index 47d83715..b9f68ed7 100644 --- a/src/plugins/ify.ts +++ b/src/plugins/spotifyCrack.ts @@ -16,13 +16,15 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import definePlugin, { OptionType } from "../utils/types"; import { Settings } from "../Vencord"; +migratePluginSettings("SpotifyCrack", "Ify"); export default definePlugin({ - name: "Ify", - description: "Disables Spotify auto-pausing, allows activity to continue playing when idling and bypasses premium checks, allowing you to listen along with others.", + name: "SpotifyCrack", + description: "Free listen along, no auto-pausing in voice chat, and allows activity to continue playing when idling", authors: [ Devs.Cyn, Devs.Nuckyz @@ -36,14 +38,14 @@ export default definePlugin({ }], }, { find: '.displayName="SpotifyStore"', - predicate: () => Settings.plugins.Ify.noSpotifyAutoPause, + predicate: () => Settings.plugins.SpotifyCrack.noSpotifyAutoPause, replacement: { match: /function (.{1,2})\(\).{0,200}SPOTIFY_AUTO_PAUSED\);.{0,}}}}/, replace: "function $1(){}" } }, { find: '.displayName="SpotifyStore"', - predicate: () => Settings.plugins.Ify.keepSpotifyActivityOnIdle, + predicate: () => Settings.plugins.SpotifyCrack.keepSpotifyActivityOnIdle, replacement: { match: /(shouldShowActivity=function\(\){.{1,50})&&!.{1,6}\.isIdle\(\)(.{0,}?})/, replace: (_, functionDeclarationAndExpression, restOfFunction) => `${functionDeclarationAndExpression}${restOfFunction}` diff --git a/src/plugins/sendify.ts b/src/plugins/spotifyShareCommands.ts similarity index 94% rename from src/plugins/sendify.ts rename to src/plugins/spotifyShareCommands.ts index b0fd52d9..e5b247b3 100644 --- a/src/plugins/sendify.ts +++ b/src/plugins/spotifyShareCommands.ts @@ -17,6 +17,7 @@ */ import { ApplicationCommandInputType, sendBotMessage } from "../api/Commands"; +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import { lazyWebpack } from "../utils/misc"; import definePlugin from "../utils/types"; @@ -74,9 +75,10 @@ function sendMessage(channelId, message) { }); } +migratePluginSettings("SpotifyShareCommands", "Sendify"); export default definePlugin({ - name: "Sendify", - description: "Send your current Spotify music to chat", + name: "SpotifyShareCommands", + description: "Share your current Spotify track, album or artist via slash command (/track, /album, /artist)", authors: [Devs.katlyn], dependencies: ["CommandsAPI"], commands: [ diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index b1a05581..68dc4805 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +import { migratePluginSettings } from "../api/settings"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; import { SelectedChannelStore } from "../webpack/common"; @@ -25,9 +26,10 @@ const timers = {} as Record; +migratePluginSettings("VoiceChatDoubleClick", "vcDoubleClick"); export default definePlugin({ - name: "vcDoubleClick", - description: "Join VCs via DoubleClick instead of single click", + name: "VoiceChatDoubleClick", + description: "Join voice chats via double click instead of single click", authors: [Devs.Ven, Devs.D3SOX], patches: [ { @@ -40,12 +42,12 @@ export default definePlugin({ // voice channels { match: /onClick:(.*)function\(\)\{(e\.handleClick.+?)}/g, - replace: "onClick:$1function(){Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{$2}, e)}", + replace: "onClick:$1function(){Vencord.Plugins.plugins.VoiceChatDoubleClick.schedule(()=>{$2}, e)}", }, // stage channels { match: /onClick:(.{0,15})this\.handleClick,/g, - replace: "onClick:$1(...args)=>Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{this.handleClick(...args);}, args[0]),", + replace: "onClick:$1(...args)=>Vencord.Plugins.plugins.VoiceChatDoubleClick.schedule(()=>{this.handleClick(...args);}, args[0]),", } ], }, diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx index 671b197c..a0d08a96 100644 --- a/src/plugins/viewIcons.tsx +++ b/src/plugins/viewIcons.tsx @@ -36,7 +36,7 @@ export default new class ViewIcons implements PluginDef { authors = [Devs.Ven]; description = "Makes Avatars/Banners in user profiles clickable, and adds Guild Context Menu Entries to View Banner/Icon."; - dependencies = ["MenuItemDeobfuscatorApi"]; + dependencies = ["MenuItemDeobfuscatorAPI"]; openImage(url: string) { const u = new URL(url); diff --git a/src/webpack/common.tsx b/src/webpack/common.tsx index 9a15011d..1dbc8362 100644 --- a/src/webpack/common.tsx +++ b/src/webpack/common.tsx @@ -216,10 +216,10 @@ interface Menu { /** * Discord's Context menu items. * To use anything but Menu.ContextMenu, your plugin HAS TO - * depend on MenuItemDeobfuscatorApi. Otherwise they will throw + * depend on MenuItemDeobfuscatorAPI. Otherwise they will throw */ export const Menu = proxyLazy(() => { - const hasDeobfuscator = Vencord.Settings.plugins.MenuItemDeobfuscatorApi.enabled; + const hasDeobfuscator = Vencord.Settings.plugins.MenuItemDeobfuscatorAPI.enabled; const menuItems = ["MenuSeparator", "MenuGroup", "MenuItem", "MenuCheckboxItem", "MenuRadioItem", "MenuControlItem"]; const map = mapMangledModule("♫ ⊂(。◕‿‿◕。⊂) ♪", {