Possibility to make BTT as a default browser

Generally idea is about to make possible to set BTT as a default browser, and later on implement different logic based on link. Few examples:

  • User click link in messenger, BTT catch this request as it set as a default browser. In BTT user implemented logic which will checking domain and open link in required browser.
  • User click link in any app, dropdown menu appear with available browser. Together with WebView it will be possible to implement menu which will allow you to select browser to proceed with link.
  • User click youtube links and it open not in browser but in media player.

One of example of app here: https://github.com/johnste/finicky, but with power of BTT there will be much more possibilities.

Yes please. This would help in my quest to replace various utilities with just BTT!

Nice idea! I already have most of the required code in BTT anyways, I’ll definitely add this.

2 Likes

Is it possible to make this configurable? I'd rather not have something that I will never use in the 'open with' menus.

This is now functional in versions >= alpha 3.521

The setup works like this (documentation will be added soon):

1.) Go to the named & other triggers section and add a "Did Open URL" trigger.
2.) If you just want to choose which browser to use, assign the "Open URL / Open URL With Selection" action and enter {BTT_OPENED_URL} as url, also select the Browser to use:

If you want to do some more complex things you can assign the "Run Real Java Script" action and run a script based on the url and/or the application that opened the URL:

(async ()=> {

// this gets the url that shall be opened
let url = await callBTT('get_string_variable', {variable_name:'BTT_OPENED_URL'});

// in case you want to decide based on the app you can also get the app path from where it was opened
let appPath = await callBTT('get_string_variable', {variable_name:'BTT_OPENED_URL_FROM_APP_AT_PATH'});

let openScript = {
    launchPath: '/usr/bin/open',     
	parameters: '-b com.apple.Safari ' + url, 
};


await runShellScript(openScript);

returnToBTT(url+'-'+appPath);
})();
2 Likes

Hi @Andreas_Hegenberg, I tried the feature today on the production release (3.540) and tried to use the BTT_OPENED_URL_FROM_APP_AT_PATH do decide which Browser to open based on the app requesting to open a link.
I tested with Unite $ Spark, in both cases, I get "Undefined" in BTT_OPENED_URL_FROM_APP_AT_PATH (I used the script you shared in the documentation)
Is there something missing ?
(I just send the appPath to the url to debug and all I get is safari opened at https://undefined)

(async ()=> {

// this gets the url that was opened
let url = await callBTT('get_string_variable', {variable_name:'BTT_OPENED_URL'});

// in case you want to decide based on the app you can also get the app path from where it was opened
let appPath = await callBTT('get_string_variable', {variable_name:'BTT_OPENED_URL_FROM_APP_AT_PATH'});

// this will open safari with the given URL
let openScript = {
    launchPath: '/usr/bin/open',
    parameters: '-b com.apple.Safari https://' + appPath,
};


await runShellScript(openScript);

returnToBTT(url+'-'+appPath);
})();

Ahh I'm sorry, apparently I didn't upload the updated documentation. I have renamed that variable to BTT_OPENED_URL_FROM_APP

Works much better with the right variable :slight_smile:
Thanks a lot for your very quick answer.
Release after release, BTT is solving more problems for my usage, and every release it reminds me how much it was a good "investment" to buy a license !!
Most useful Mac app

1 Like

I'm trying this in BTT 3.553, but the links always open in the browser in which I clicked on them (as usual), even though I have set BTT to be the default browser (I'm trying to redirect certain links clicked in Safari to either Firefox or a Unite App).

How can I debug this?

EDIT: Looks like I misunderstood and this is "only" for links outside of a browser?

Correct, this just behaves like setting a different default browser. Link clicks inside the browser are handled by the browser - this would probably require browser extensions to change.

(When setting Chrome as default Safari will also not open Chrome when clicking a link :-))

1 Like

Why can't I set BTT as default browser in System Preferences | General?

(For me it only offers Safari, Firefox, and Finicky, but not BTT)

Reason: I want to prevent Safari's constant nagging about not being the default browser

Imprint | Privacy Policy