From afc683f9a34b2d1517e8116d51e34c01e2c9c3d4 Mon Sep 17 00:00:00 2001 From: Etorix <92535668+EtorixDev@users.noreply.github.com> Date: Tue, 12 May 2026 19:36:41 -0700 Subject: [PATCH] MiddleClickTweaks: Fix text input patch & remove migration. (#1078) * Fix text input patch & remove migration. * Fix text input patch & remove migration. --- .../middleClickTweaks/index.ts | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/equicordplugins/middleClickTweaks/index.ts b/src/equicordplugins/middleClickTweaks/index.ts index fff576a6f..779f17caa 100644 --- a/src/equicordplugins/middleClickTweaks/index.ts +++ b/src/equicordplugins/middleClickTweaks/index.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { definePluginSettings, SettingsStore } from "@api/Settings"; +import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/index"; import definePlugin, { OptionType } from "@utils/types"; @@ -75,33 +75,13 @@ const settings = definePluginSettings({ } }); -function migrate() { - const { plugins } = SettingsStore.plain; - const oldPlugin = plugins?.LimitMiddleClickPaste; - - if (!oldPlugin) return; - - const newPlugin = plugins.MiddleClickTweaks ??= { enabled: false }; - const { scope, threshold, preventLinkOpen } = oldPlugin; - - if (scope) newPlugin.pasteScope = scope; - if (threshold) newPlugin.pasteThreshold = threshold; - if (preventLinkOpen) newPlugin.openScope = "both"; - if (oldPlugin.enabled) newPlugin.enabled = true; - - delete plugins.LimitMiddleClickPaste; - SettingsStore.markAsChanged(); -} - -migrate(); - export default definePlugin({ name: "MiddleClickTweaks", description: "Various middle click tweaks, such as with pasting and link opening.", - tags: ["Utility"], authors: [EquicordDevs.Etorix, EquicordDevs.korzi], settings, + tags: ["Utility"], searchTerms: ["LimitMiddleClickPaste"], isPastingDisabled(isInput: boolean) { @@ -115,11 +95,7 @@ export default definePlugin({ return false; }, - start() { - migrate(); - updateListeners(); - }, - + start() { updateListeners(); }, stop() { updateListeners(false); }, patches: [ @@ -132,10 +108,10 @@ export default definePlugin({ } }, { - // Detects paste events triggered inside of Discord's text input. + // Detects paste events triggered inside of Discord's text inputs. find: ",origin:\"clipboard\"});", replacement: { - match: /(?<=handlePaste=(\i)=>{)(?=let)/, + match: /(?<=handlePaste=(\i)=>{)(?=let)/g, replace: "if($self.isPastingDisabled(true)){$1.preventDefault?.();$1.stopPropagation?.();return;}" } },