Meadow Maker
Meadow Maker

Reputation: 1

Why does Script editor not like this edit?

I got his script:

   set vURL to URL of current tab of window 1
end tell

tell application "Google Chrome"
   if windows ≠ {} then
       make new tab at the end of window 1 with properties {URL:vURL}
   else
       make new window
       set URL of (active tab of window 1) to vURL
   end if

   activate
end tell

I'd really like to be able to just quickly open the tab I'm using in Safari in Firefox beause...

I'm told have to add more text here so, Skip this paragraph. ... a site I use a lot has some great features in Firefox but it can be slow to load so I like to switch backwards and forwards between the two.

Why won't it work if I change "Google Chrome" to "Firefox":

tell application "Safari"
    set vURL to URL of current tab of window 1
end tell

tell application "Firefox"
    if windows ≠ {} then
        make new tab at the end of window 1 with properties {URL:vURL}
    else
        make new window
        set URL of (active tab of window 1) to vURL
    end if

    activate
end tell

Thanks

Upvotes: 0

Views: 56

Answers (1)

red_menace
red_menace

Reputation: 3422

You can't mix and match scripting terms - the scripting terminology (if any) for a given application is entirely up to the developer and is unique to that application. There also isn't a standard or common practice for term names, so any similarity between scripting terms of different applications would be purely coincidental and wouldn't necessarily provide the same functionality.

Looking at the scripting dictionaries for Google Chrome vs Safari and Firefox:

  • Firefox doesn't really have a scripting dictionary, only a default suite is available. Specifically, a window does not have either tab, active tab, or URL elements (URL here would also be assumed to be from StandardAdditions)
  • Safari windows do not have an active tab property.

You will need to target each application with its own tell statement, using the terminology specific to that application. Also note that trying to do something like using a variable to hold the application name will not work, since the scripting terminology for each application is looked up when the script is compiled.

(Edit from comments)

To open the URL of the current Safari tab with Firefox (version 69.0.1 in Mojave), you can do something like:

tell application "Safari" to set theURL to (get URL of current tab of front window)
tell application "Firefox"
    activate
    open location theURL
end tell

Upvotes: 1

Related Questions