I use BetterTouchTool as my default browser and have been trying to figure out how to have it automatically open all Mastodon links in the Mastodon client “Mona”.
I know the trigger in BetterTouchTool would be “Did Open URL” and eventually it would need to replace “http” or “https” with “mona” so it opens in Mona but I don’t know how to detect whether or not a link is a Mastodon link or not.
Any help would be greatly appreciated. Thank you!!
There isn’t a quick and reliable option right now, but you should have a read of this Mastodon GitHub request and maybe give it a thumbs up. Some workarounds are listed, but the usability will vary.
If a URL matches either pattern it runs a javascript using the “Run Real Javascript” action that replaces “http” and https" with “mona://” and runs a shell script that opens the modified URL in Mona.
(async () => {
// This gets the URL that was opened
let url = await get_string_variable({ variable_name: 'BTT_OPENED_URL' });
// Replace "https" and "http" with "mona://"
let modifiedUrl = url.replace(/^https?/, 'mona');
// This will open the specified app with the modified URL
let openScript = {
launchPath: '/usr/bin/open',
parameters: `-u;;${modifiedUrl};;-a;;Mona`
};
await runShellScript(openScript);
returnToBTT(modifiedUrl);
})();