Detecting Mastodon Links with BetterTouchTool

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!!

“Did Open URL” - BetterTouchTool Documentation

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.

1 Like

That explains a lot!! Sounds like I may have to re-install Velja for the time being… thank you very much for your help!! :slight_smile:

Just an update, I finally figured out a way to do this using BetterTouchTool as my default browser.

I have two “Did Open URL” automation triggers setup looking for different wildcard URL patterns.

The first one is looks for profile url and the second looks for post urls.

Profile URL Wildcard Pattern:

*://*.*/@*

Post URL Wildcard Pattern:

*://*.*/@*/[0-9]*

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);
})();