Mastodon is done by fetching the ActivityPub profile page, so supporting other ActivityPub-compatible format can be done the same way.
Now, each platform has a different format for profile URLs and is not necessarily composed of the username (eg. Misskey, where the ActivityPub endpoint uses user ID), which can be fetched through Webfinger (refer to Mastodon docs). So two requests and it should support all ActivityPub platforms (fields first, and description as fallback), including Pleroma, Misskey, and Friendica.
For secure mode / authorized fetch instances, it is possible to imitate an ActivityPub server.