Support for Orion browser in "Front Browser" actions and variables

The new Orion browser is a native Mac app that uses Webkit. Does that make it possible for it to be added to the list of browsers that the "Front Browser" actions and variables can make use of? If so, is that something that might be implented?

Only, I think, if the authors of the browser have implemented an osascript interface – preferably emulating Safari’s.

If the Onion browser supports AppleScript control matching either Chrome or Safari, then it is easily done.

If the Onion browser supports AppleScript control with its own interface, then that will take some work.

If the Onion browser does not have AppleScript control, then it will be impossible.

I'm not sure if it's the information you're looking for, but an image of the Orion Suite in the Script Editor library is below. If that doesn't provide the needed information, could you suggest how I might investigate further? Thank you!

If that is all, then that is insufficient.

At the least it needs some way to run JavaScript via AppleScript.

I don't think it can but looks like it is planned: Allow JavaScript from Apple Events - Orion Public Issue Tracker

2 Likes

Orion Version 0.99.124-beta (WebKit 616.1.10) has just been released, and one of the improvements is the closing of issue #4361 Allow JavaScript from Apple Events. However, I find that Orion can now be asked for URL and site title using Applescript, with no need for Javascript. @peternlewis

1 Like

I'm revisiting an old topic... @peternlewis, do you think that at any point Keyboard Maestro might be able to recognise Orion as the "front browser"? (I ask because I would now like to be able to use the Click front browser link action).

As mentioned in my reply from May 2023, Javascript via Applescript is supported.

From Orion's Applescript dictionary:

The same answer remains - if it implements a compatible dictionary with either Safari or Chrome, then you can do it now, and if not, then probably not. do JavaScript is just one component of the dictionary, there is also the AppleScript related to tabs and windows and titles and such.

Thanks, I understand you as saying here that KM should not need to be tweaked if everything has been implemented in Orion. I think that is a little different from the previous answers, but maybe I misunderstand.

From May 2022 (above):

As linked to in my update, above, from May 2023 above, here is my post showing that Applescript control is possible: Orion Web Browser: Getting URL or Title via Applescript

KM's %FrontBrowser...% tokens do not see Orion, nor do the Press a button... actions. I have not been able to spot any relevant differences between Orion and Safari's dictionaries,

Safari Technology Preview continues to also be invisible to KM's tokens, so I am not sure to what extent Webkit browsers have to be individually catered for by KM.

If it is compatible with Chrome, you can just add it as a Chrome browser, you can add it as an additional browser with the AdditionalWebBrowserBundleIDs setting.

If it is compatible with Safari, then it would need an additional change to the engine as currently any compatible browser is assumed to be Chrome-compatible unless it has “safari” in the bundle id somewhere.

1 Like

That brings clarity, thanks. As mentioned, Orion uses Webkit, so (although it supports Chromium and Firefox plugins) it will fall under "Safari-compatible". For the record, the bundle ID is com.kagi.kagimacOS.

It's not really about using WebKit so much as it is about the details of it's AppleScript dictionary.

For example, to get the url of the front tab, the AppleScript for Chrome is:

tell application id "com.google.Chrome" 
  if it is running then 
    tell window 1 
      URL of active tab 
    end tell 
  else 
    "Not Running" 
  end if 
end tell

and for Safari is:

tell application id "com.apple.Safari" 
  if it is running then 
    tell document 1 
      URL 
    end tell 
  else 
    "Not Running" 
  end if 
end tell

It is the handling of document/window/etc that makes the difference in the AppleScript being compatible or not compatible.

Ah yes, of course.

I can confirm that, in your second example, replacing "com.apple.Safari" with "com.kagi.kagimacOS" works.This is not the case when applied to the first script. Modifying my original examples to use application id in place of application also works, so it all seems consistent.

As an additional experiment, I have just tried the following, and then restarted KM (editor and engine):
defaults write com.stairways.keyboardmaestro.engine AppleScriptSafariBundleID -string "com.kagi.kagimacOS"
and
defaults write com.stairways.keyboardmaestro.engine BrowserSafariName -string "com.kagi.kagimacOS"

%SafariURL% then gave the URL from Orion, but %SafariTitle% was empty.

The SafariTitle token should be the result of the JavaScript document.title.

The AppleScript for Safari (with error checking removed) looks like:

tell application id "com.apple.Safari" 
  if it is running then 
    tell document 1 
      set r to do JavaScript "document.title"
    end tell
  end if 
  r 
end tell 

The SafariTitle token should be the result of the JavaScript document.title.

A first guess was that in the menu system of @kevinb 's installation of Orion:

Develop > Allow JavaScript from Apple Events

might not yet be checked.

But having enabled that here, I'm still finding that the following evaluates to AppleScript missing value (with Safari it evaluates to "4.0") so I wonder if Orion has yet implemented do javascript ?

tell application id "com.kagi.kagimacOS"
    if it is running then
        tell document 1 to do JavaScript "2+2"
    end if
end tell

worth a note to them ?

1 Like

It does seem that you are right. Although, as I mentioned above (7th July), do javascript appears in Orion's Applescript dictionary, it appears that it hasn't yet been implemented.

The results of further searches of orionfeedback.org suggest that, following user feedback, implementing do javascript was set to "planned" in June 2022. So I hope it is still planned, but I appreciate that, until then, there is no more that can be done by @peternlewis. And KM does of course allow for the creation of nifty workarounds in the meantime!

Thank you both for your input.

2 Likes

According to the Orion developer, though this is planned, how soon it happens depends on the number of upvotes—any Orion user who wants to upvote it can do so at the issue page.

1 Like