/* * Vencord, a Discord client mod * Copyright (c) 2025 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import "./styles.css"; import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import { t } from "@utils/translation"; import definePlugin, { OptionType } from "@utils/types"; import { User } from "@vencord/discord-types"; import { findByCodeLazy } from "@webpack"; import { React, UserProfileStore } from "@webpack/common"; import { ProfilePopoutComponent } from "./components/ProfilePopoutComponent"; import { ProfileTabComponent } from "./components/ProfileTabComponent"; const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryColor:"); export const cl = classNameFactory("vc-github-repos-"); export const settings = definePluginSettings({ showStars: { type: OptionType.BOOLEAN, description: t("equicord.githubRepos.settings.showStars"), default: true }, showLanguage: { type: OptionType.BOOLEAN, description: t("equicord.githubRepos.settings.showLanguage"), default: true }, }); export default definePlugin({ name: "GitHubRepos", description: t("equicord.githubRepos.description"), dependencies: ["ProfileCollectionsAPI"], tags: ["Appearance"], authors: [EquicordDevs.talhakf, EquicordDevs.Panniku, EquicordDevs.benjii], settings, patches: [ // User Profile Modal v2 tab bar { find: "#{intl::USER_PROFILE_ACTIVITY}", replacement: { match: /(\i)\.id!==\i\?\.id&&\i&&\(.{0,300}\.MUTUAL_GUILDS\}\)\)(?=,(\i))/, replace: '$&,$self.shouldShowGitHub($1.id)&&$2.push({text:"GitHub",section:"GITHUB"})', } }, // User Profile Modal v2 tab content { find: ".WIDGETS?", replacement: { match: /(\i)===\i\.\i\.WISHLIST/, replace: '$1==="GITHUB"?$self.renderProfileRepositoriesTab(arguments[0]):$&', } } ], shouldShowGitHub(userId: string) { return UserProfileStore.getUserProfile(userId)?.connectedAccounts?.some((c: any) => c.type === "github") ?? false; }, renderProfileCollection: (props: { user: User; displayProfile?: any; }) => { return ( ); }, renderProfileRepositoriesTab: ErrorBoundary.wrap((props: { user: User; displayProfile?: any; }) => { return ( ); }, { noop: true }), });