Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): ExtraConnectionLinks #2642

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
12 changes: 12 additions & 0 deletions src/plugins/openMoreConnections/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# OpenMoreConnections

Adds the Open Profile button to connections that don't natively have it in the regular Discord client.
## Supported Platforms
* Xbox
* Roblox
## Planned Platforms
coopeeo marked this conversation as resolved.
Show resolved Hide resolved
* PSN
## Platforms that will never be supported
* Riot Games/League of Legends
* Battle.net
* Epic Games
59 changes: 59 additions & 0 deletions src/plugins/openMoreConnections/index.ts
Original file line number Diff line number Diff line change
@@ -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";



//* platforms that dont open
//* riot and leage (can't view profiles)
//* epic (can't view profiles)
//* psn (can't view profiles but I have a workaround for 3rd party stuff)
//* roblox
//* xbox
//* battle.net (can't view profiles)

enum ConnectionType {
Roblox = "roblox",
PSN = "playstation",
Xbox = "xbox",
}


interface Connection {
type: ConnectionType | string;
id: string;
name: string;
verified: boolean;
}


export default definePlugin({
name: "OpenMoreConnections",
description: "Adds the Open Profile button to connections that don't natively have it in the regular Discord client. Supported Platforms: Xbox, and Roblox. Planned Platforms: PSN. Platforms that will never be supported: Riot Games/League of Legends, Battle.net, and Epic Games",
coopeeo marked this conversation as resolved.
Show resolved Hide resolved
authors: [Devs.coopeeo],
patches: [
{
find: ".CONNECTED_ACCOUNT_VIEWED,",
replacement: {
match: /(?<=(\i)=null==\i\?void 0:null===\(\i=\i.getPlatformUserUrl\)\|\|void 0===\i\?void 0:\i.call\(\i,(\i)\);)/,
replace: "if ($1 == null) $1 = $self.addConnectionLink($2);"
}
}
],
addConnectionLink(con: Connection) {
switch (con.type) {
case ConnectionType.Roblox:
return `https://www.roblox.com/users/${con.id}/profile`;
case ConnectionType.Xbox:
return `https://www.xbox.com/en-US/play/user/${con.name}`;
coopeeo marked this conversation as resolved.
Show resolved Hide resolved
}


return null;
}
});
7 changes: 6 additions & 1 deletion src/plugins/showConnections/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: st

function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) {
const platform = platforms.get(useLegacyPlatformType(connection.type));
const url = platform.getPlatformUserUrl?.(connection);
var url = platform.getPlatformUserUrl?.(connection);
coopeeo marked this conversation as resolved.
Show resolved Hide resolved

const img = (
<img
Expand All @@ -147,6 +147,11 @@ function CompactConnectionComponent({ connection, theme }: { connection: Connect
/>
);

if (Vencord.Plugins.isPluginEnabled("OpenMoreConnections") && url == null) {
const OpenMoreConnections = Vencord.Plugins.plugins.OpenMoreConnections as any as typeof import("../openMoreConnections").default;
url = OpenMoreConnections.addConnectionLink(connection) as string;
}

const TooltipIcon = url ? LinkIcon : CopyIcon;

return (
Expand Down
4 changes: 4 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
Antti: {
name: "Antti",
id: 312974985876471810n
},
coopeeo: {
name: "Cooper",
id: 594864203102158859n
}
} satisfies Record<string, Dev>);

Expand Down