1

There is an answer already to a similar question that does work when the link is on a Chrome webpage, Shift + Left Click.

Unfortunately, Left Click does not work for me opening a .webloc file on MacOS Mojave 10.14.6 with Chrome 84. It opens as a new tab in the most recently used Chrome window.

I'm interested in the answers offered at How to make Chrome open a new window for external Links. Unfortunately Comment 1 on the question says "this solution works" but other users report there that one or another of the multiple solutions on that page do not work for them.

In addition, the most recent version of Chrome mentioned in those answers is Chrome 45 and we're nearly 40 versions past that to date. So I'm asking if anyone knows of something that works, rather than experimenting with complicated, programming solutions that are already identified as not working.

Any suggestions?

2

Here is an option to consider...

Use an Automator Service/Quick Action1, via Finder, to open the URL contained in the .webloc file in a new window of Google Chrome.

1 In macOS Mojave, and later, an Automator Service is called a Quick Action. The use of terms separated with a / is to denote the differences between Automator prior to macOS Mojave and from it onwards.

The Automator Service/Quick Action can be triggered from the Services context menu via right-click (option-click) on the selected .webloc file(s) in Finder, or after selecting the .webloc file(s) in Finder press the keyboard shortcut assigned to the Automator Service/Quick Action.

  • In Automator create a new Service/Quick Action, setting: Service/Workflow receives/receives current [files or folders] in [Finder]

  • Add a Run AppleScript action, replacing the default code with the following example AppleScript code:

on run {input, parameters}
    repeat with i from 1 to the length of input
        set thisItem to the POSIX path of item i of input
        if thisItem ends with ".webloc" then
            set dssCommand to ¬
                "/usr/libexec/PlistBuddy -c \"Print :URL\" " & ¬
                quoted form of thisItem
            set thisURL to do shell script dssCommand
            if thisURL starts with "http" then
                tell application "Google Chrome"
                    set the URL of the active tab of ¬
                        (make new window) to thisURL
                end tell
            end if
        end if
    end repeat
end run
  • Save the Automator Service/Quick Action, e.g.: Open webloc in Google Chrome

  • Add a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services, e.g.: ⌘G


Notes:

Depending on how the .webloc file was created, it can be either a binary PLIST file or an XML plist text file. The examples below shows https://www.google.com/ as the URL:

 binary .webloc file in hex editor

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>URL</key>
    <string>https://www.google.com/</string>
</dict>
</plist>

Regardless, the example AppleScript code uses a do shell script command to assign the value of the URL to a variable by using PlistBuddy to print the value of URL in the .webloc file. It then opens the URL in a new window in Google Chrome.

The PlistBuddy full output for the example .webloc file, in both forms, above is:

Dict {
    URL = https://www.google.com/
}

However, when configuring it to print the URL directly, its output for the example .webloc file, in both forms, above is just:

https://www.google.com/

As coded, it can handle multiple selected .webloc files opening each in its own window, regardless of how the preferences are set in Google Chrome. It validates that the file(s) passed to the service have a .webloc file extension, and the value of the thisURL variable starts with http, otherwise the service fails silently.


This Automator Service/Quick Action was tested and worked for me, under macOS High Sierra and macOS Catalina, using both the Services context menu and ⌘G assigned keyboard shortcut of the service on the selected .webloc file(s) in Finder.

2
  • Thank 894. (May I call you "894"? That seems so much more personal than "@user".) On first reading, this looks complete and thorough. I can't wait to try it out, but unfortunately I may have to for a few days. Thank you so much! Aug 26 '20 at 22:52
  • I finally got time to implement and test it. As the Brits say, "It works a champ!" Thanks! As a Technical Writer, I appreciate all the tutorial detail too. Aug 29 '20 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .