Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

donawalt

Contributor
Original poster
Sep 10, 2015
1,207
591
Hi, I am hoping someone can help - for work reasons, periodically I would like to right-click a URL in Safari, and Open Chrome going to that URL page. I have tried to use Automator to do this, it appears that this would be the proper tool. However, despite restarting my Mac, restarting Safari, when I right-click on a URL in Safari and check the Services sub-menu, my automator entry is not there. It is saved to <my logon name>\Library\Services, ie the default folder it put it in when I did a Save As... and entered the name of the automation.

Here is an image of what I created, if I understand it correctly, it will receive the URL I right-clicked on, only in Safari is it active, it will copy it to the Clipboard, and then it will launch Chrome. I haven't figured out how to have it paste/go to that web page once it opens Chrome, as I can't get it to show in the Services sub-menu. Can anyone help me with those two problems? Thanks!


Screen Shot 2022-05-31 at 7.43.46 PM.png
 
  • Like
Reactions: ReneeReader

bogdanw

macrumors 603
Mar 10, 2009
5,964
2,910
Unfortunately, Automator does not receive the URL when you right-click on a link in Safari, it gets the text.
There is a workaround, using JavaScript to get the URL https://stackoverflow.com/questions...ugh-right-click-applescript-and-or-javascript
Here is my version based on that:
OpenInChrome.jpg
AppleScript:
Code:
on run {input, parameters}
    tell application "Safari" to tell ¬
        front document to set TheURL ¬
        to "" & (do JavaScript ¬
        "document.getSelection().anchorNode.parentNode.href")
    if TheURL is "" then return
    tell application "Google Chrome" to open location TheURL
end run
 

donawalt

Contributor
Original poster
Sep 10, 2015
1,207
591
Oh wow @bogdanw that works perfectly!!! Thank you! @kryten2 thanks for your reply, that is the standard documentation for adding a service, yet it does not show up for me. I don't need it now though.
 
  • Like
Reactions: ReneeReader

bogdanw

macrumors 603
Mar 10, 2009
5,964
2,910
In other apps, something simpler might work:
OpenInChrome.jpg
Code:
on run {input, parameters}
    tell application "Google Chrome" to open location (input as text)
end run
 
  • Like
Reactions: ReneeReader
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.