Is It Possible for Keyboard Maestro to Support the Brave Browser?

I've just started testing the Brave browser, which is built on Chromium. I'd like to use Keyboard Maestro with it, but I don't know how - is it possible?


If it has the same AppleScript dictionary as Chrome, then you can target the Google Chrome actions at it using the preferences just like you can point them at Chrome Canary.

defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeName "Google Chrome Canary"
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName "Chrome Canary"

The AppleScript name is used in AppleScript’s which control the browser in the form of tell app “[browser name]”. Note that the Chrome browser must behave like Chrome, or the actions will not work. Do not bother trying to set them to Firefox or something like that as it will not work. All this allows you to do is select a specific version of Chrome.

1 Like

It looks like [Brave doesn’t currently have AppleScript support] ( Thanks for the quick answer!

If they implement AppleSupport that is exactly the same as Google Chrome, then the my suggestion above will work.

If they implement AppleScript their own way, then probably the suggestion will not work, though you could then implement your own solution using the Execute AppleScript action.

Otherwise you are stuck controlling the browser via clicks and typing.

One other thing, browsers may allow you to execute JavaScript via some mechanism (eg typing it in to the address bar encoded as a javascript: URL), if so, that might be another vector for controlling the browser.

1 Like

Yep, just posted about this relative to FireFox, but it might also work with any Browser:

1 Like

Brave doesn’t seem to support the javascript: URL scheme, so I’m out of luck there.

My use case is to run a large hunk of JavaScript to extract certain data from a webpage and make it available to a later step of the macro - it works fine in Safari, so I’ll stay there, at least for the time being.

Just a quick update to this thread. Looks like brave now supports applescript

Thanks for sharing, but as the date of the link indicates, BB has supported AppleScript for quite a while now. Been using AppleScript with BB ever since KM9.

I changed the preferences for with Brave (see below), what preference string IDs should I use to return to the Google default?

defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID -string ""
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Brave"

Unless you need to address a Browser that is NOT frontmost, just use the "FrontMostBrowser" actions, tokens, and functions.
Then your macro will work with any Browser that is, well, frontmost. :wink:

Thanks @JMichaelTX for the speedy response. Will there be any impact to my macros if I do not remove the Brave preference IDs and reset the strings back to the Chrome defaults?

Depends on your macros, and your objective.
With the preference as you now have it, ALL of the Chrome-specific Actions etc will actually target Brave Browser.
If it were me, I'd change it back to the default preference of Chrome.

To return to defaults, just delete the preferences:

defaults delete com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID
defaults delete com.stairways.keyboardmaestro.engine BrowserGoogleChromeName

Thanks Peter - I received the following when executing what you provided:

Domain (com.stairways.keyboardmaestro.engine) not found.
Defaults have not been changed.

The command looks ok to me, so I would suggest there is a typo somewhere.

@peternlewis, I could not find a formal reference for these (which I have added to Wiki Preferences). Could you please confirm:

# ~~~ For Brave Browser ~~~
defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID -string "com.brave.Browser"
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Brave Browser"

What do you mean? The preferences AppleScriptGoogleChromeBundleID and BrowserGoogleChromeName are documented in the Preferences. Or do you mean more detail about specifically what they are - the displayed name of the browser and the bundle ID of the browser? Seems fairly self-evident, especially as I don't really want overly detailed documentation on what are intended to be hidden preferences subject to change.

Or do you mean with respect to Brave? If so, I have no idea, I don't use or support Brave - if it works, great, if it doesn't, then it needs to be more like Chrome - Keyboard Maestro only supports Safari and Chrome, and these preferences allow substituting other browsers that behave like Safari or Chrome.

I found that, after setting the appropriate variables in terminal, in order to have keyboard maestro successfully click a link, I also had to check the menu item within Brave: View > Developer > Allow JavaScript from Apple Events. (learned from this discussion)

PS: @JMichaelTX thank you for showing the exact strings necessary! For the Brave Beta I changed to the below (didn't seem to need to change the second one)

# ~~~ For Brave Browser BETA ~~~
defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID -string "com.brave.Browser.beta"
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Brave Browser"
1 Like

Lately my macros that click links in Brave Beta are failing. I used to use "Click Front Browser Link" (after entering above KM defaults) but it stopped working...

I tried one the new Brave-specific command "Click Brave Browser Link" but it didn't work (maybe because I'm running the BETA?) either. Then I re-entered the above settings for my BETA and neither work still...Is this a known issue?

Running Brave Version 1.16.62 Chromium: 86.0.4240.80 (Official Build) beta (x86_64)