diff options
author | Vendicated <vendicated@riseup.net> | 2022-09-27 18:03:21 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-09-27 18:03:21 +0200 |
commit | 4759ca536c4f36665b2f8905547eb3c63c42ae45 (patch) | |
tree | 57b4b4b5024cfc6db08f9e7e331900f6e4015038 /src/plugins/viewIcons.tsx | |
parent | 0444233dd9640f810ed0c61b97b59d67a606df1a (diff) | |
download | Vencord-4759ca536c4f36665b2f8905547eb3c63c42ae45.tar.gz Vencord-4759ca536c4f36665b2f8905547eb3c63c42ae45.tar.bz2 Vencord-4759ca536c4f36665b2f8905547eb3c63c42ae45.zip |
Fix ViewProfileImages
Diffstat (limited to 'src/plugins/viewIcons.tsx')
-rw-r--r-- | src/plugins/viewIcons.tsx | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx index 433c1e5..f41ae85 100644 --- a/src/plugins/viewIcons.tsx +++ b/src/plugins/viewIcons.tsx @@ -1,57 +1,54 @@ -import { Modal, openModal } from "../utils/modal"; +import IpcEvents from "../utils/IpcEvents"; import definePlugin from '../utils/types'; -import { filters, waitFor } from "../webpack"; - -let ImageModal: any; -let renderMaskedLink: any; - -waitFor(filters.byDisplayName("ImageModal"), m => ImageModal = m.default); -waitFor("renderMaskedLinkComponent", m => renderMaskedLink = m.renderMaskedLinkComponent); const OPEN_URL = "Vencord.Plugins.plugins.ViewIcons.openImage("; export default definePlugin({ name: "ViewIcons", author: "Vendicated", - description: "Makes Avatars/Banners in user profiles clickable, and adds Guild Context Menu Entries to View Banner/Icon. Crashes if you don't have Developer Mode enabled, will fix in the future.", + description: "Makes Avatars/Banners in user profiles clickable, and adds Guild Context Menu Entries to View Banner/Icon.", openImage(url: string) { - openModal(() => ( + VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, url); + // husk + /* openModal(() => ( <ImageModal shouldAnimate={true} original={url} src={url} renderLinkComponent={renderMaskedLink} /> - ), { size: Modal.ModalSize.DYNAMIC }); + ), { size: Modal.ModalSize.DYNAMIC }); */ }, patches: [ { - find: "UserProfileModalHeader", + find: "onAddFriend:", replacement: { match: /\{src:(.{1,2}),avatarDecoration/, replace: (_, src) => `{src:${src},onClick:()=>${OPEN_URL}${src}.replace(/\\?.+$/, "")+"?size=2048"),avatarDecoration` } }, { - find: "default.popoutNoBannerPremium", + find: "().popoutNoBannerPremium", replacement: { - match: /style:.{1,2}\(\{\},(.{1,2}),/, + match: /style:.{0,10}\{\},(.{1,2})\)/, replace: (m, bannerObj) => `onClick:${bannerObj}.backgroundImage&&(()=>${OPEN_URL}${bannerObj}.backgroundImage.replace("url(", "").replace(/(\\?size=.+)?\\)/, "?size=2048"))),${m}` } }, { - find: "GuildContextMenuWrapper", + find: '"GuildContextMenu:', replacement: [ { match: /\w=(\w)\.id/, replace: (m, guild) => `_guild=${guild},${m}` }, { - match: /,(.{1,2})\((.{1,2})\.MenuGroup,\{\},void 0,(.{1,2})\)(?=\)\}.{1,2}\.displayName)/, - replace: (_, createElement, menu, copyIdElement) => `,${createElement}(${menu}.MenuGroup,{},void 0,[` + - `_guild.icon&&${createElement}(${menu}.MenuItem,` + + match: /(?<=createElement\((.{1,5}),\{id:"leave-guild".{0,100}\,)(.{1,2}\.createElement)\((.{1,5}),null,(.{1,2})\)(?=\)\}function)/, + replace: (_, menu, createElement, menuGroup, copyIdElement) => + `${createElement}(${menuGroup},null,[` + + `_guild.icon&&${createElement}(${menu},` + `{id:"viewicons-copy-icon",label:"View Icon",action:()=>${OPEN_URL}_guild.getIconURL(void 0,true)+"size=2048")}),` + - `_guild.banner&&${createElement}(${menu}.MenuItem,` + - `{id:"viewicons-copy-banner",label:"View Banner",action:()=>${OPEN_URL}Vencord.Webpack.findByProps("getGuildBannerURL").getGuildBannerURL(_guild).replace(/\\?size=.+/, "?size=2048"))}),${copyIdElement}])` + `_guild.banner&&${createElement}(${menu},` + + `{id:"viewicons-copy-banner",label:"View Banner",action:()=>${OPEN_URL}Vencord.Webpack.findByProps("getGuildBannerURL").getGuildBannerURL(_guild).replace(/\\?size=.+/, "?size=2048"))})` + + `,${copyIdElement}])` } ] } |