Run JavaScript in the Arc Browser with AppleScript

Hi :wave:

Arc is a new Browser based on Chromium. It looks like an action "Run JavaScript in Front Browser" does not work at all. Because of this, I've created a simple AppleScript Snippet to run JavaScript:

set JSSnippet to ""
set JSSnippetResult to ""

tell application "Keyboard Maestro Engine"
	set JSSnippet to getvariable "JSSnippet"
end tell

tell application "Arc"
	set JSSnippetResult to execute front window's active tab javascript JSSnippet
end tell

It works but there is Missing Value instead of a result. I'm fairly sure that this script is correct, because it works in Brave/Chrome.

Is it possible to extract JS result in this situation?

Hey Adam,

Run this in Apple's Script Editor:

set jsCmdStr to "

document.title

"

tell application "Arc"
   tell front window's active tab to execute javascript jsCmdStr
end tell

If you don't get a result go looking for:

image

This is from Google Chrome, and most Chrome-based browsers are similar.

-Chris

As you can see, still missing value.

What's more "Allow JS from Apple Events" are not available in this menu but still it's seem to be active because in Dev Tools I can see that JavaScript snippet is running. I just can't get results.

I came up with an idea to do this:

As you can see I have an IFEE here so I can "return" a result and then "copy" it to the Clipboard, which may be accessed in Keyboard Maestro.

1 Like