0

When running the following script:

on run
  tell application "Safari"
    set allWins to every window
    set allTabs to {}
    repeat with currWin in allWins
      set allTabs to allTabs & every tab of currWin
    end repeat
    repeat with currTab in allTabs
      try
        if ((characters -10 thru -1 of (title of currTab as string)) as string) = "Google Music" then set musicTab to currTab
      end try
    end repeat
    tell musicTab
        execute javascript "SJBpost(\"playPause\");"
    end tell
  end tell
end run

received is the syntax Error Expected end of line but found identifier. and javascript becomes highlighted.

I'm using automator and trying to create hot keys for google music following this article.

1 Answer 1

2

You may want to read the linked article a little more closely:

If you're using Safari, change the 'Google Chrome' in the first line to 'Safari,' change the word title (near the middle) to name, and change the word execute on the third-to-last line to do.

Hence try replacing:

tell musicTab
    execute javascript "SJBpost(\"playPause\");"

with:

tell musicTab to do javascript "SJBpost('playPause');"

You also haven't followed the second instruction of that paragraph change the word title (near the middle) to name. With all those changes, it becomes:

on run
  tell application "Safari"
                    ^^^^^^
    set allWins to every window
    set allTabs to {}
    repeat with currWin in allWins
      set allTabs to allTabs & every tab of currWin
    end repeat
    repeat with currTab in allTabs
      try
        if ((characters -12 thru -1 of (name of currTab as string)) as string) = "Google Music" then set musicTab to currTab
                        ^^^             ^^^^                                      ^^^^^^^^^^^^
      end try
    end repeat
    tell musicTab to do javascript "SJBpost('playPause');"
                     ^^
  end tell
end run

Remove the three lines containing ^^^ character markers, they're just there to make it as obvious as possible.

And, according to Kurt Rudolph, it's now called Google Music (no longer in Beta) so we've changed the tab title detection as well, to match.

You'll have to test this yourself unfortunately since all I see is:

We're sorry. Google Music is currently only available in the United States

Presumably where the RIAA would have less trouble dragging me into court :-)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.