0

I'm using Automator to open a link in Chrome based on on some selected text:

on run {input, parameters}
    set kanji to input as string
    set link to "https://jisho.org/search/" & kanji
    tell application "Google Chrome"
        open location link
    end tell
end run

This works fine when the input text is ASCII, and a new Chrome tab opens at the URL, but nothing happens (and no error when put in a "try" block) when the input text is kanji (eg 漢字). Open "Safari" always works correctly, so this looks like a Chrome thing?

Chrome 91.0.4472.164, macOS 11.3.

Thanks for any insights!

Update: Thanks row and gurkensaas.

I ended up with this working version:

on run {input, parameters}
    set kanji to input as string
    set link to "https://jisho.org/search/" & kanji
    try
        tell application "Google Chrome"
            tell its window 1
                set URL of (make new tab) to link
                end tell
        end tell
    on error errMsg number errorNumber
        display dialog "Error occurred:  " & errorNumber as text
    end try
end run
toby
  • 17
  • 2
  • You probably need to uri encode the input, see https://stackoverflow.com/questions/23852182/i-need-to-url-encode-a-string-in-applescript – row Jul 20 '21 at 14:06
  • I don't quite understand what your goal is but I think you should try `make new tab with properties {URL:link}` instead of `open location link`. – gurkensaas Jul 22 '21 at 12:07

0 Answers0