diff --git a/README.md b/README.md index 6d7dfa34..6960e168 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,6 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - NewPluginsManager by Sqaaakoi - NoAppsAllowed by kvba - NoBulletPoints by Samwich -- NoDefaultEmojis by Samwich - NoDeleteSafety by Samwich - NoMirroredCamera by Nyx - NoModalAnimation by AutumnVN @@ -148,6 +147,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - VoiceChannelLog by Sqaaakoi & maintained by thororen - VoiceChatUtilities by D3SOX - WebpackTarball by Kyuuhachi +- WhitelistedEmojis by Creations - WhosWatching by fres - WigglyText by nexpid - Woof by Samwich diff --git a/src/equicordplugins/noDefaultEmojis/index.tsx b/src/equicordplugins/noDefaultEmojis/index.tsx deleted file mode 100644 index fdefa5db..00000000 --- a/src/equicordplugins/noDefaultEmojis/index.tsx +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; -import { definePluginSettings } from "@api/Settings"; -import { disableStyle, enableStyle } from "@api/Styles"; -import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; -import { Menu } from "@webpack/common"; - -import style from "./style.css?managed"; - -const settings = definePluginSettings({ - except: { - type: OptionType.STRING, - description: "", - default: "" - } -}); - -const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { target: HTMLElement; }) => () => { - // eslint-disable-next-line no-unsafe-optional-chaining - const { id, type, name } = props?.target?.dataset; - if (id) return; - - if (type === "emoji") { - children.push(buttonThingy(name)); - } - -}; - -const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => { - - const { favoriteableName } = props ?? {}; - if (!favoriteableName) { return; } - // WHY DID I DO IT THIS WAY - const name = favoriteableName.split(":").join(""); - if (name == null) { return; } - const group = findGroupChildrenByChildId("favorite", children) || findGroupChildrenByChildId("unfavorite", children); - if (!group) return; - - group.splice(group.findIndex(c => c?.props?.id === "favorite" || c?.props?.id === "unfavorite") + 1, 0, buttonThingy(name)); - -}; - - -function buttonThingy(name) { - return ( - addEmojiToAutofill(name)} - /> - ); -} - -function addEmojiToAutofill(name) { - const excepted = isEmojiExcepted(name); - if (excepted) { - // remove the emoji if its already in there - // split up the exceptions by the seperator, filter out the emoji, then re join it. - settings.store.except = settings.store.except.split(", ").filter(item => item !== name).join(", "); - } - else { - // add the emoji to the exceptions - settings.store.except = settings.store.except += (", " + name); - } - -} - -function isEmojiExcepted(name) { - return settings.store.except.split(", ").includes(name); -} - - -export default definePlugin({ - name: "NoDefaultEmojis", - description: "Stops default emojis showing in the autocomplete. (You can add exceptions)", - authors: [Devs.Samwich], - settings, - patches: [ - { - find: ".Messages.EMOJI_MATCHING", - replacement: { - match: /renderResults\((\i)\){/, - replace: "renderResults($1){ $1.results.emojis = $1.results.emojis.filter(emoji => !emoji.uniqueName || Vencord.Settings.plugins.NoDefaultEmojis.except.split(',\\ ').includes(emoji.uniqueName));" - } - } - ], - contextMenus: - { - "expression-picker": expressionPickerPatch, - "message": messageContextMenuPatch - }, - start() { - enableStyle(style); - }, - stop() { - disableStyle(style); - } -}); - - - - diff --git a/src/equicordplugins/noDefaultEmojis/style.css b/src/equicordplugins/noDefaultEmojis/style.css deleted file mode 100644 index efc20424..00000000 --- a/src/equicordplugins/noDefaultEmojis/style.css +++ /dev/null @@ -1,4 +0,0 @@ -/* stylelint-disable selector-class-pattern */ -.scroller_cc9b9a.thin_b1c063.scrollerBase_dc3aa9:not(:has(.base__76a71)) { - display: none; -} diff --git a/src/equicordplugins/whitelistedEmojis/index.tsx b/src/equicordplugins/whitelistedEmojis/index.tsx index b7e70b62..79e003a9 100644 --- a/src/equicordplugins/whitelistedEmojis/index.tsx +++ b/src/equicordplugins/whitelistedEmojis/index.tsx @@ -8,7 +8,7 @@ import "./style.css"; import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; import { DataStore } from "@api/index"; -import { definePluginSettings } from "@api/Settings"; +import { definePluginSettings, migratePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Alerts, Button, EmojiStore, GuildStore, Menu, Toasts, useEffect, useState } from "@webpack/common"; @@ -594,19 +594,20 @@ const settings = definePluginSettings({ } }); +migratePluginSettings("WhitelistedEmojis", "NoDefaultEmojis"); export default definePlugin({ name: "WhitelistedEmojis", description: "Adds the ability to disable all message emojis except for a whitelisted set.", + authors: [EquicordDevs.creations], patches: [ { find: ".Messages.EMOJI_MATCHING", replacement: { - match: /renderResults\(e\){/, - replace: "renderResults(e){ e.results.emojis = $self.filterEmojis(e);" + match: /renderResults\((\i)\){/, + replace: "renderResults($1){ $1.results.emojis = $self.filterEmojis($1);" } } ], - authors: [EquicordDevs.creations], settings: settings, async start() { cache_allowedList = await getAllowedList(); @@ -617,9 +618,8 @@ export default definePlugin({ removeContextMenuPatch("expression-picker", expressionPickerPatch); removeContextMenuPatch("guild-context", guildContextPatch); }, - - filterEmojis: (e: { results: { emojis: (CustomEmoji | UnicodeEmoji)[]; }; }) => { - const { emojis } = e.results; + filterEmojis: (data: { results: { emojis: (CustomEmoji | UnicodeEmoji)[]; }; }) => { + const { emojis } = data.results; let modifiedEmojis = emojis; if (settings.store.defaultEmojis) {