Using a Non-Safari, Non-Chrome Browser

Hey Peter,

These are the most prominent Chrome-based-browsers other than Google Chrome:

CHROMIUM-BASED-BROWSERS

Brave Browser			com.brave.Browser
Google Chrome Canary	com.google.Chrome.canary
Vivaldi					com.vivaldi.Vivaldi

All support Chrome's execute AppleScript command in the same way.

I request that all be included in Keyboard Maestro's Front-Browser actions.

Also – It would be really nice if there was a mechanism for users to add Bundle-ID's to those actions, so new compatible browsers could be added at need instead of waiting for an update to Keyboard Maestro.

-Chris

3 Likes

Noted.

2 Likes

Excellent, thanks. Worked beautifully.

Would it be possible to have Chromium matched by default as well? (AppleScriptGoogleChromeBundleID org.chromium.Chromium, BrowserGoogleChromeName Chromium.)

Thanks!

1 Like

Hey @Unikitty,

Not presently.

Hey Peter (@peternlewis ) – Let me reiterate my feature-request:

It would be fine if this was an expert preference.

It's inevitable that there will be more Chrome-based browsers, and there are already 7 viable ones – Google Chrome, Google Chrome Canary, Chromium, Brave Browser, Opera, Vivaldi, and Microsoft Edge.

There are also several Webkit-based browsers using the same sdef as Safari.

-Chris

I saw another thread where @peternlewis promised to add support for Brave browser
https://forum.keyboardmaestro.com/t/using-a-non-safari-non-chrome-browser/13712/15

but these days I'm using MS Edge browser on Mac for most business purposes, since it's Chromium-based (v77.0.235.5 specifically).

However, this does not appear to be supported for Tokens at all. Even on latest v9, Front Browser reports Safari because I have that running as well (even though it's nowhere near the front), and %ChromeTitle% and URL resolve to "Not Running". Can this Edge support be added please?

Does Microsoft Edge support the same AppleScript dictionary as Google Chrome?

1 Like

Looks standard to me based on below, what do you think?

I'm using the more frequently updated Dev build, btw, but I don't see why this part would be different from the main channel release (or nightly Canary ones).

Seems so, yes:

1 Like

Then it should work as an alternate browser configured with the Chrome preferences.

Also, it should work in v9 with the FrontBrowser actions.

what script editor (?) is this in the screenshot?

I tested JavaScript on Microsoft Edge, it's not working.
I added this:

defaults write com.stairways.keyboardmaestro.engine AppleScriptMicrosoftEdgeBundleID "com.microsoft.edgemac"

and restarted the engine. It's still not working.

Does Execute a JavaScript in Front Browser action work when Microsoft Edge is frontmost app?

If not, then it really isn't recognized as a Chrome-based browser.

This is the action I tested. So apparently it is not recognized as a Chromium-based browser. But it is a Chromium-based browser. Can we do anything about it?

This simple alert('hello') JavaScript works on MS Edge using JXA. It works on other Chromium-based browsers such as Chrome, Brave, etc. We should expect it to work on MS Edge as well. Any ideas? @peternlewis

Code:

const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0];
const app = Application(frontmost_app_name);
const jScript = "alert('hello');"

if (frontmost_app_name == "Safari"){
	app.doJavaScript(jScript, {in: app.windows[0].currentTab()});
}else{ 
	app.windows[0].activeTab.execute({ javascript: jScript});
}

MACRO:   JXA Test Apple Event on Browser

DOWNLOAD Macro File:

JXA Test Apple Event on Browser.kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


I don't know. You may want to post this question in the MS Edge forum.

I'm not surprised, setting AppleScriptMicrosoftEdgeBundleID does nothing.

If it is compatible with Chrome’s AppleScript support, you can configure it as the Chrome browser of preference as:

defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID -string "com.google.Chrome.canary"
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Chrome Canary"

Replacing com.google.Chrome.canary with the bundle ID of MS Edge, and Chrome Canary with whatever it is called (Microsoft Edge?).

If it uses its own AppleScript dictionary with its own behaviour, then it is not supported.

If that does work, then I can add it to the possibilities for Front Browser.

The current available supported bundle IDs are:

  • com.apple.Safari
  • com.apple.SafariTechnologyPreview
  • com.google.Chrome
  • com.google.Chrome.canary
  • com.brave.Browser
  • com.vivaldi.Vivaldi

plus whatever (if anything) is configured with the AppleScriptGoogleChromeBundleID and AppleScriptSafariBundleID.

Note that there are no other options for the preferences than those two - there is no such preference as AppleScriptMicrosoftEdgeBundleID.

Thank you so much, @peternlewis.
JavaScript works after running these commands in the Terminal:

defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID -string "com.microsoft.edgemac"
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Microsoft Edge"

It looks promising.

@peternlewis, I have updated the KM Wiki with those supported bundle IDs.
If you add more, please update the wiki.
Execute JavaScript in Browser Actions

I confirm @martin's last comment works.

Currently using KM v9.2, MS Edge v90.