Switch to patch-only soulution

This commit is contained in:
Cooper 2024-06-29 23:58:29 -05:00 committed by GitHub
parent 36f809f8cf
commit 3e58b70b98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 32 deletions

View file

@ -7,8 +7,6 @@
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
//* platforms that dont open //* platforms that dont open
//* riot and leage (can't view profiles) //* riot and leage (can't view profiles)
//* epic (can't view profiles) //* epic (can't view profiles)
@ -17,43 +15,28 @@ import definePlugin from "@utils/types";
//* xbox //* xbox
//* battle.net (can't view profiles) //* battle.net (can't view profiles)
enum ConnectionType { const uris = { // name = t, and id = l
Roblox = "roblox", roblox: "https://www.roblox.com/users/${l}/profile",
PSN = "playstation", xbox: "https://www.xbox.com/play/user/${t}"
Xbox = "xbox", };
}
interface Connection {
type: ConnectionType | string;
id: string;
name: string;
verified: boolean;
}
export default definePlugin({ export default definePlugin({
name: "OpenMoreConnections", 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", 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",
authors: [Devs.coopeeo], authors: [Devs.coopeeo],
patches: [ patches: [
{ {
find: ".CONNECTED_ACCOUNT_VIEWED,", find: "getPlatformUserUrl:e=>",
replacement: { replacement: {
match: /(?<=(\i)=null==\i\?void 0:null===\(\i=\i.getPlatformUserUrl\)\|\|void 0===\i\?void 0:\i.call\(\i,(\i)\);)/, match: /(?<=Roblox",.*},.+)(?=},)/,
replace: "if ($1 == null) $1 = $self.addConnectionLink($2);" replace: `, getPlatformUserUrl:e=>{let {name:t, id:l} = e; return \`${uris.roblox}\`;}`
}
},
{
find: "getPlatformUserUrl:e=>",
replacement: {
match: /(?<=Xbox",.*},.+)(?=},)/,
replace: `, getPlatformUserUrl:e=>{let {name:t, id:l} = e; return \`${uris.xbox}\`;}`
} }
} }
], ],
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/play/user/${con.name}`;
}
return null;
}
}); });

View file

@ -134,7 +134,7 @@ function ConnectionsComponent({ id, theme, simplified }: { id: string, theme: st
function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) {
const platform = platforms.get(useLegacyPlatformType(connection.type)); const platform = platforms.get(useLegacyPlatformType(connection.type));
var url = platform.getPlatformUserUrl?.(connection); const url = platform.getPlatformUserUrl?.(connection);
const img = ( const img = (
<img <img