aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-09-02 19:05:52 +0200
committerVendicated <vendicated@riseup.net>2022-09-02 19:05:52 +0200
commit3dd294e2adf586930f5650ac59f71ffc087f769b (patch)
treed4a09cd43d53a91d0dff86a40db58270c8b6afa9 /src
parent68057d49e8bb602e0094fc4af785363752f05419 (diff)
downloadVencord-3dd294e2adf586930f5650ac59f71ffc087f769b.tar.gz
Vencord-3dd294e2adf586930f5650ac59f71ffc087f769b.tar.bz2
Vencord-3dd294e2adf586930f5650ac59f71ffc087f769b.zip
Add viewIcons
Diffstat (limited to 'src')
-rw-r--r--src/components/Settings.tsx2
-rw-r--r--src/plugins/viewIcons.ts41
-rw-r--r--src/utils/constants.ts1
3 files changed, 42 insertions, 2 deletions
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 69e923a..c7e73be 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -26,8 +26,6 @@ export default ErrorBoundary.wrap(function Settings(props) {
return o;
}, []);
- console.log(depMap);
-
return (
<Forms.FormSection tag="h1" title="Vencord">
<Forms.FormText>SettingsDir: {settingsDir}</Forms.FormText>
diff --git a/src/plugins/viewIcons.ts b/src/plugins/viewIcons.ts
new file mode 100644
index 0000000..cb56265
--- /dev/null
+++ b/src/plugins/viewIcons.ts
@@ -0,0 +1,41 @@
+import { REACT_GLOBAL } from "../utils/constants";
+import IpcEvents from "../utils/IpcEvents";
+import definePlugin from '../utils/types';
+
+const OPEN_URL = `VencordNative.ipc.invoke("${IpcEvents.OPEN_EXTERNAL}",`;
+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",
+ patches: [
+ {
+ find: "UserProfileModalHeader",
+ replacement: {
+ match: /\{src:(.{1,2}),avatarDecoration/,
+ replace: (_, src) => `{src:${src},onClick:()=>${OPEN_URL}${src}.replace(/\\?.+$/, "")+"?size=2048"),avatarDecoration`
+ }
+ }, {
+ find: "default.popoutNoBannerPremium",
+ replacement: {
+ match: /style:.{1,2}\(\{\},(.{1,2}),/,
+ replace: (m, bannerObj) => `onClick:()=>${OPEN_URL}${bannerObj}.backgroundImage.replace("url(", "").replace(/(\\?size=.+)?\\)/, "?size=2048")),${m}`
+ }
+ }, {
+ find: "GuildContextMenuWrapper",
+ 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: (_, factory, menuGroup, copyIdElement) => `,${factory}(${menuGroup},{},void 0,[` +
+ `_guild.icon&&${REACT_GLOBAL}.cloneElement(${copyIdElement},` +
+ `{key:"viewicons-copy-icon",id:"viewicons-copy-icon",action:()=>${OPEN_URL}_guild.getIconURL(undefined,true)+"size=2048"),label:"View Icon",icon:null}),` +
+ `_guild.banner&&${REACT_GLOBAL}.cloneElement(${copyIdElement},` +
+ `{key:"viewicons-copy-banner",id:"viewicons-copy-banner",action:()=>${OPEN_URL}Vencord.Webpack.findByProps("getGuildBannerURL").getGuildBannerURL(_guild).replace(/\\?size=.+/, "?size=2048")),label:"View Banner",icon:null}),${copyIdElement}])`
+ }
+ ]
+ }
+ ]
+});
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index e948309..92f78f5 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -1 +1,2 @@
export const WEBPACK_CHUNK = "webpackChunkdiscord_app";
+export const REACT_GLOBAL = "Vencord.Webpack.Common.React"; \ No newline at end of file