Hello,
Google’s newest release of Chrome now supports AppleScript and I’m rewriting a few of my simple Safari scripts for use with Google’s browser. However, I’ve hit a few roadblocks and was hoping to get some info from the smart people here.
First, how to close a tab. In Safari you can run:
tell application "Safari" to close current tab of window 1
but in Chrome you cannot do the equivalent:
tell application "Google Chrome" to close active tab of window 1
You get the message:
error “Google Chrome got an error: active tab of window 1 doesn’t understand the close message.” number -1708 from active tab of window 1
This seems to me a somewhat basic request, but I can’t figure out how to do it (without employing user scripting).
Secondly, how to run javascript. For instance, in Safari you can run:
tell application "Safari" to do JavaScript "getSelection();" in document 1
The “do JavaScript” command is not in Chrome’s dictionary, but there is the “execute” command:
execute‚v : Execute a piece of javascript.
execute specifier : The tab to execute the command in.
javascript text : The javascript code to execute.
→ any
I’ve tried every combination I can think of to get the getSelection JavaScript to execute, but with no luck.
Much appreciated is any insight provided. Both of these are relatively simple, but they’ve already provided my daily limit of frustration, and Chrome’s scripting abilities are so new that I can’t find any place on the www that has an answer. Cheers.