From 851d07f31a117cf342d09c0886ae0b38ae0c9050 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Mon, 7 Nov 2022 18:52:34 +0100 Subject: fix(ReverseImageSearch): Don't apply to non image files --- src/plugins/reverseImageSearch.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index da7d844..79c2488 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -31,7 +31,6 @@ const Engines = { const Menu = lazyWebpack(filters.byProps("MenuItem")); - export default definePlugin({ name: "ReverseImageSearch", description: "yes", @@ -42,11 +41,27 @@ export default definePlugin({ replacement: { match: /key:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\}\)/, replace: (m, src) => - `${m},Vencord.Plugins.plugins.ReverseImageSearch.makeMenu(${src})` + `${m},Vencord.Plugins.plugins.ReverseImageSearch.makeMenu(${src}, arguments[2])` + } + }, { + // pass the target to the open link menu so we can check if it's an image + find: "REMOVE_ALL_REACTIONS_CONFIRM_BODY,", + replacement: { + // url1 = url2 = props.attachment.url + // ... + // OpenLinks(url2 != null ? url2 : url1, someStuffs) + // + // the back references are needed because the code is like Z(a!=null?b:c,d), no way to match that + // otherwise + match: /(?.).onHeightUpdate.{0,200}(.)=(.)=.\.url;.+?\(null!=\3\?\3:\2[^)]+/, + replace: "$&,$.target" } }], - makeMenu(src: string) { + makeMenu(src: string, target: HTMLElement) { + if (target && target.attributes["data-role"]?.value !== "img") + return null; + return (