diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/reverseImageSearch.tsx | 21 |
1 files changed, 18 insertions, 3 deletions
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: /(?<props>.).onHeightUpdate.{0,200}(.)=(.)=.\.url;.+?\(null!=\3\?\3:\2[^)]+/, + replace: "$&,$<props>.target" } }], - makeMenu(src: string) { + makeMenu(src: string, target: HTMLElement) { + if (target && target.attributes["data-role"]?.value !== "img") + return null; + return ( <Menu.MenuItem label="Search Image" |