AppleScript “Copy Link” function for Safari


I need to right click a link on a website…
and open the Services menu…
to run an Automator Action on the text/url of that link.

I need to "get" the url from the link into the script so I can run some shell script actions on it and then output the result to the clipboard.

I am having a hard time finding a way to copy that url into the Action using automator. I need a way to replicate the "Copy Link" function that already exists in Safari drop down menu when right clicking inside of the Quick Action.

I would prefer to not "allow javascript from Apple Events" as it's a security risk.

Best Answer

There is a right click command on AppleScript.

Might also be worth looking into a combination of CliClick and cURL using Brew / Bash for this purpose.