fix(ReverseImageSearch): Don't apply to non image files
This commit is contained in:
parent
963a7332b4
commit
851d07f31a
1 changed files with 18 additions and 3 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue