AppleScript in Chrome WebApp

I have just learned that you can create a Single Site Browser with Chrome.
This is pretty good since we have some webapps at my work which is easier to have as an app.
But I can not find a way to execute Applescript against the webapp the same way I can with Chrome.
Does anybody have a good idea about how to do this?

I am just guessing here, so if someone else has ideas, please jump in.

How did you make the SSB? I use Epichrome and I am not sure whether or not it supports AppleScript or not, but if it does then I bet you might need to use the Bundle ID for the SSB in any AppleScript you might try.

How do you find the Bundle ID? Well, I do it in Terminal. For example, I have an EpiChrome browser for Google Voice which is at "/Applications/Google" so I use:

defaults read "/Applications/Google" CFBundleIdentifier

(that should be all one long line). Change /Applications/Google to be whatever your app is called, and then be sure to add /Contents/Info at the end to make the defaults read command work properly.

That command gives me this as output for my SSB:

Maybe you can use that to tell AppleScript which browser you want to target?

That being said, I can target the app by name, at least to launch it:

osascript -e 'tell application "Google Voice" to activate'

works fine.

Sorry I don't know much about AppleScript, so I can't be more help. This is just a shot in the dark.

It you made your SSB some other way than EpiChrome… maybe try EpiChrome?

I can target it with the name, but other Chrome specific AppleScript does not work.
Like running javascript.

I make it this way in Chrome. The screenshot is in danish, but it should be possible to see where the option is.

Unfortunately I'm at a loss. You might want to ask the folks at which is the forum for Script Debugger (the premiere AppleScript app, but you don't need to be using their app to ask an AppleScript question).

I've found lots of helpful folks there.

1 Like

Hey Jimmy,

I found a solution for this problem a year or so ago, but I can't guarantee it still works.

How to Click Links in a Coherence (Chrome) Browser


Hi Chris

How do you do it?

I have made a Site-specific browser for our internal timetracking.
In Chrome I can run a JavaScript against it, but not when I target the site-specific app.

See this video:

Hey Jimmy,

If I remember correctly you have to use the bundle-id and not the app-name.

# Get Bundle-ID of Selected App in the Finder.
tell application "Finder"
   set finderSelectionList to selection as alias list
   if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
   set theItem to item 1 of finderSelectionList
   return theItem's id
end tell

# How to Use the Bundle-ID in a Tell-Block.
tell application id "com.barebones.bbedit"
end tell


Hi Chris

I get this weird bundle ID:

But it works when I just want to activate the app.

tell application id ""
end tell

But the code to run JavaScript still fails.

tell application "Keyboard Maestro Engine" to set myOrdrenr to getvariable "Ordrenr"

set myJavascript to "document.getElementById('Ordrer1_TextBoxOrdrenr').value = \"" & myOrdrenr & "\""

tell application id ""
	execute front window's active tab javascript myJavascript
	execute front window's active tab javascript "document.getElementById('Ordrer1_RadButton1').click();"
end tell

Hey Jimmy,

Bah!   Humbug!

Epichrome apps no longer respond to Chrome's AppleScript API (link)

I've queried the dev – and the dev of Coherence Pro – and the dev of Fluid.

We'll see if I get any answers.


1 Like

Chris, when you write posts like this I realize I can't even measure how much smarter you are than I am.