mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Compare commits
38 commits
0e2f3ce4f1
...
debe0052d6
Author | SHA1 | Date | |
---|---|---|---|
|
debe0052d6 | ||
|
a015cf96f6 | ||
|
f62795da6d | ||
|
0d7ab0bcbf | ||
|
70ea0c92a8 | ||
|
d6390658b7 | ||
|
29de13fe4e | ||
|
d24afdaa20 | ||
|
cb4071a3ce | ||
|
70d49a97c9 | ||
|
255571653e | ||
|
a081ec8afd | ||
|
be5e2527aa | ||
|
52c3a55449 | ||
|
52d3c0afac | ||
|
162be49239 | ||
|
7d4f0e4c3e | ||
|
3f4e993329 | ||
|
5d64c6a081 | ||
|
e2c3c0655a | ||
|
d435e0a28e | ||
|
7c27cec573 | ||
|
120004874f | ||
|
d3e9230117 | ||
|
7134cdd4d1 | ||
|
6a617016a7 | ||
|
7bc3e03b52 | ||
|
a0262029e3 | ||
|
1fbfed635d | ||
|
610332e93d | ||
|
402cb1cad9 | ||
|
e648bf92e2 | ||
|
8b4fe6e95f | ||
|
b333deb731 | ||
|
3e58b70b98 | ||
|
36f809f8cf | ||
|
9afcb75358 | ||
|
bfea1edf63 |
6 changed files with 112 additions and 29 deletions
21
src/plugins/extraConnectionLinks/README.md
Normal file
21
src/plugins/extraConnectionLinks/README.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# ExtraConnectionLinks
|
||||||
|
Allows you to open more connections in browser!
|
||||||
|
|
||||||
|
### Before
|
||||||
|
![Shows the Roblox connection in the Discord client without the open profile button (the default).](https://github.com/Vendicated/Vencord/assets/73203995/734efd94-c61a-4f90-987d-3a4bbcc9311f)
|
||||||
|
### After
|
||||||
|
![Shows the Roblox connection in the Discord client with the open profile button.](https://github.com/Vendicated/Vencord/assets/73203995/eef59d09-78d9-4859-b722-242fc6aa7c8e)
|
||||||
|
|
||||||
|
## Platform Status
|
||||||
|
### Supported Platforms
|
||||||
|
* Xbox
|
||||||
|
* Epic Games
|
||||||
|
### Platforms that will never be supported
|
||||||
|
* Riot Games (Nothing made by Riot Games to view profiles online)
|
||||||
|
* League of Legends (Same as above since it's the same company)
|
||||||
|
* Battle.net (Nothing made by Blizzard to view profiles online)
|
||||||
|
* Bungie.net (Nothing made by Bungie.net to view profiles online)
|
||||||
|
* PlayStation Network (Sony built a service called My PlayStation, but removed it for unknown reasons in 2021)
|
||||||
|
* Facebook
|
||||||
|
* Crunchyroll (can't view other peoples profiles nor your own profile)
|
||||||
|
* Amazon Music (nothing references to the actual amazon music user id in discord.)
|
59
src/plugins/extraConnectionLinks/index.ts
Normal file
59
src/plugins/extraConnectionLinks/index.ts
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Cooper/coopeeo, Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All the connection types implemented into this plugin
|
||||||
|
*/
|
||||||
|
enum connectionTypes {
|
||||||
|
Roblox,
|
||||||
|
Xbox,
|
||||||
|
Epic,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The uri to use.
|
||||||
|
* There are also two variables that you can use, name and id.
|
||||||
|
* The "name" is what shows up when viewing a connection on a discord profile.
|
||||||
|
* The "id" is the identifier of the account connected, the type depends on the service connected.
|
||||||
|
* @example [connectionTypes.Xbox]: "https://www.xbox.com/play/user/${name}",
|
||||||
|
* @example [connectionTypes.Roblox]: "https://www.roblox.com/users/${id}/profile",
|
||||||
|
*/
|
||||||
|
const uris = { // name (what shows up on connection on ui), id (an identifier thing)
|
||||||
|
//[connectionTypes.Roblox]: "https://www.roblox.com/users/${id}/profile",
|
||||||
|
[connectionTypes.Xbox]: "https://www.xbox.com/play/user/${name}",
|
||||||
|
[connectionTypes.Epic]: "https://store.epicgames.com/u/${id}",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What discord has the service named as.
|
||||||
|
* @example [connectionTypes.Epic]: "Epic Games",
|
||||||
|
*/
|
||||||
|
const serviceNames = {
|
||||||
|
//[connectionTypes.Roblox]: "Roblox",
|
||||||
|
[connectionTypes.Xbox]: "Xbox",
|
||||||
|
[connectionTypes.Epic]: "Epic Games",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "ExtraConnectionLinks",
|
||||||
|
description: "Allows you to open more connections in browser!",
|
||||||
|
authors: [Devs.coopeeo],
|
||||||
|
patches: Object.keys(connectionTypes)
|
||||||
|
.filter(v => isNaN(Number(v)))
|
||||||
|
.map(key => {
|
||||||
|
const connectionTypeSelected = connectionTypes[key as keyof typeof connectionTypes];
|
||||||
|
return {
|
||||||
|
find: "getPlatformUserUrl:",
|
||||||
|
replacement: {
|
||||||
|
match: new RegExp("(r"),
|
||||||
|
replace: `, getPlatformUserUrl:e=>{let {name, id} = e; return \`${uris[connectionTypeSelected]}\`;}`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
});
|
|
@ -8,7 +8,7 @@ import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildStore, IconUtils, NavigationRouter, PermissionsBits, PermissionStore, showToast, Text, Toasts, Tooltip, useCallback, useMemo, UserStore, useStateFromStores } from "@webpack/common";
|
import { ChannelStore, GuildStore, IconUtils, NavigationRouter, PermissionsBits, PermissionStore, React, showToast, Text, Toasts, Tooltip, useMemo, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
const cl = classNameFactory("vc-uvs-");
|
const cl = classNameFactory("vc-uvs-");
|
||||||
|
@ -17,7 +17,7 @@ const { selectVoiceChannel } = findByPropsLazy("selectChannel", "selectVoiceChan
|
||||||
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
const VoiceStateStore = findStoreLazy("VoiceStateStore");
|
||||||
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
|
||||||
|
|
||||||
interface IconProps extends React.HTMLAttributes<HTMLDivElement> {
|
interface IconProps extends React.ComponentPropsWithoutRef<"div"> {
|
||||||
size?: number;
|
size?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,23 +71,18 @@ interface VoiceChannelTooltipProps {
|
||||||
|
|
||||||
function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
||||||
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
|
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
|
||||||
|
|
||||||
const users = useMemo(
|
const users = useMemo(
|
||||||
() => Object.values<any>(voiceStates).map(voiceState => UserStore.getUser(voiceState.userId)).filter(user => user != null),
|
() => Object.values<any>(voiceStates).map(voiceState => UserStore.getUser(voiceState.userId)).filter(user => user != null),
|
||||||
[voiceStates]
|
[voiceStates]
|
||||||
);
|
);
|
||||||
|
|
||||||
const guild = useMemo(
|
const guild = channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId());
|
||||||
() => channel.getGuildId() == null ? undefined : GuildStore.getGuild(channel.getGuildId()),
|
const guildIcon = guild?.icon == null ? undefined : IconUtils.getGuildIconURL({
|
||||||
[channel]
|
|
||||||
);
|
|
||||||
|
|
||||||
const guildIcon = useMemo(() => {
|
|
||||||
return guild?.icon == null ? undefined : IconUtils.getGuildIconURL({
|
|
||||||
id: guild.id,
|
id: guild.id,
|
||||||
icon: guild.icon,
|
icon: guild.icon,
|
||||||
size: 30
|
size: 30
|
||||||
});
|
});
|
||||||
}, [guild]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -103,7 +98,7 @@ function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
||||||
<UserSummaryItem
|
<UserSummaryItem
|
||||||
users={users}
|
users={users}
|
||||||
renderIcon={false}
|
renderIcon={false}
|
||||||
max={7}
|
max={13}
|
||||||
size={18}
|
size={18}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -119,11 +114,14 @@ const clickTimers = {} as Record<string, any>;
|
||||||
|
|
||||||
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChannelIndicatorProps) => {
|
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChannelIndicatorProps) => {
|
||||||
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
|
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
|
||||||
const channel = useMemo(() => channelId == null ? undefined : ChannelStore.getChannel(channelId), [channelId]);
|
|
||||||
|
|
||||||
const onClick = useCallback((e: React.MouseEvent) => {
|
const channel = channelId == null ? undefined : ChannelStore.getChannel(channelId);
|
||||||
|
if (channel == null) return null;
|
||||||
|
|
||||||
|
function onClick(e: React.MouseEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
if (channel == null || channelId == null) return;
|
if (channel == null || channelId == null) return;
|
||||||
|
|
||||||
if (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) {
|
if (!PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel)) {
|
||||||
|
@ -147,18 +145,15 @@ export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId }: VoiceChanne
|
||||||
delete clickTimers[channelId];
|
delete clickTimers[channelId];
|
||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
}, [channelId]);
|
}
|
||||||
|
|
||||||
const isLocked = useMemo(() => {
|
const isLocked = !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel);
|
||||||
return !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, channel) || !PermissionStore.can(PermissionsBits.CONNECT, channel);
|
|
||||||
}, [channelId]);
|
|
||||||
|
|
||||||
if (channel == null) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
text={<VoiceChannelTooltip channel={channel} />}
|
text={<VoiceChannelTooltip channel={channel} />}
|
||||||
tooltipClassName={cl("tooltip-container")}
|
tooltipClassName={cl("tooltip-container")}
|
||||||
|
tooltipContentClassName={cl("tooltip-content")}
|
||||||
>
|
>
|
||||||
{props =>
|
{props =>
|
||||||
isLocked ?
|
isLocked ?
|
||||||
|
|
|
@ -32,7 +32,7 @@ const settings = definePluginSettings({
|
||||||
default: true,
|
default: true,
|
||||||
restartNeeded: true
|
restartNeeded: true
|
||||||
},
|
},
|
||||||
showInVoiceMemberList: {
|
showInMemberList: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Show a user's Voice Channel indicator in the member and DMs list",
|
description: "Show a user's Voice Channel indicator in the member and DMs list",
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -82,12 +82,12 @@ export default definePlugin({
|
||||||
match: /\.subtext,children:.+?}\)\]}\)(?=])/,
|
match: /\.subtext,children:.+?}\)\]}\)(?=])/,
|
||||||
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
replace: "$&,$self.VoiceChannelIndicator({userId:arguments[0]?.user?.id})"
|
||||||
},
|
},
|
||||||
predicate: () => settings.store.showInVoiceMemberList
|
predicate: () => settings.store.showInMemberList
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (settings.store.showInVoiceMemberList) {
|
if (settings.store.showInMemberList) {
|
||||||
addDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
|
addDecorator("UserVoiceShow", ({ user }) => user == null ? null : <VoiceChannelIndicator userId={user.id} />);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-uvs-tooltip-container {
|
.vc-uvs-tooltip-container {
|
||||||
max-width: 200px;
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-uvs-tooltip-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-uvs-guild-name {
|
.vc-uvs-guild-name {
|
||||||
|
@ -31,7 +37,5 @@
|
||||||
|
|
||||||
.vc-uvs-vc-members {
|
.vc-uvs-vc-members {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 8px 0;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -531,6 +531,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "Antti",
|
name: "Antti",
|
||||||
id: 312974985876471810n
|
id: 312974985876471810n
|
||||||
},
|
},
|
||||||
|
coopeeo: {
|
||||||
|
name: "Cooper",
|
||||||
|
id: 594864203102158859n
|
||||||
|
},
|
||||||
Joona: {
|
Joona: {
|
||||||
name: "Joona",
|
name: "Joona",
|
||||||
id: 297410829589020673n
|
id: 297410829589020673n
|
||||||
|
|
Loading…
Reference in a new issue