How to create a service (shown in the context menu on the URL) in Safari

automatorcontextual menusafariservicesshortcut-menu

I want to create a service which will be shown in the context menu when I right-click on any link in the Safari (need get the URL into the service).

This is my current contextual services menu on the right-click to any Safari link, eg. want add the my service to this menu.

enter image description here

Any suggestion?

EDIT

For the simplicity, I want:

  • create a service (by the Automator or by any other way)
  • let say the service name should be: "Save URL"
  • the "Save URL" service should appear in the Services context menu when I right-click on any link in Safari
  • The real workflow of the service isn't the matter. Just want to know how to create a service which will appear in the context menu.
  • but, if you want – for the simplicity let's say – the service should do only one simple thing: open a new TextEdit document and add the URL of the given (right-clicked) link into it.

I tried to create an Automator Service, but the saved service doesn't show up in the menu.

Best Answer

UPDATE: I initially misunderstood the question. To learn how to create a service for the context menu in Safari, see part A of this answer. To learn how to create a service that takes no input and appears in the menubar > Safari > Services menu in Safari, see part B.

Part A: Creating a Contextual Text Service

Step 1

Follow part B's step 1 (I'll refer to it as B.1 from here on out).

Step 2

Follow B.2, but instead of selecting "no input," select "rich text."

Selecting "rich text" to allow right-click input

In this case, you won't want to use anything else, because this is the step that makes it possible to see it from the contextual right-click menu when selecting text. This is because Automator requires some sort of input usually, and the type of input determines how it will get that input. If it's manual input, then it'll simply ask for the input when it runs, but if it's some sort of text that's already on the screen, it needs selected text to function. Note that you can't choose "URLs" because that does not mean that you can right click on URLs on the webpage, but that you can save the URL of the current page using the menubar. I chose "rich text" for this because it saves the text with its URL properties (i.e. you can click on it and it'll take you to the webpage once it's in the TextEdit document).

Step 3

As with B.3, write your workflow. In this case, it's really simple (there will be no download link because you can make it so easily):

Writing the workflow

In this case, all I'm doing is taking the input of the selected rich text as specified, and then copying it into a new TextEdit document, which should open up with the link once you've used the service.

Step 4

Finish things off by saving, as in B.4, and optionally do B.5 if you want to see where your services are located.

Using the finished service

If you're looking to do something more advanced, like copying the URL from selected text, that would be more complicated, but feel free to experiment with it. You can always try URL shortening to create links, or perhaps have Automator open that webpage in a new tab and copy its URL as with the script in B.3.

Part B: Creating a Menubar URL Service

Step 1

First, you'll want to make sure that the workflow you created is a "Service" workflow. To do so, when you create a workflow, select the "Service" option like so:

Creating a service

Click on "Choose" and you're ready to create your service. You should see the typical Automator workflow builder window, as usual.

Step 2

Once you're there, make sure that you say your application is for Safari, using the menu at the top of the window. The other dropdown menu determines whether or not the Automator workflow takes any input. Depends on what you're doing, but in this case, I think you don't need any input, so select "no input."

Making the service usable by Safari

Step 3

At that point, go ahead and build your workflow. It sounds like you already have a workflow you want to use, but here's one I built to do what you'd like:

Create the workflow

At this point, you'll see that the service does not yet show up in the dropdown in Safari.

No services in the menu yet

Step 4

In order to make it show up, make sure you've saved your Automator workflow.

Saving the workflow

The header on Automator should look like this: The saved workflow

If you check Safari now, your "Save URL" service should come up.

The "Save URL" service is now shown

Step 5 (optional)

If you really want to check that your service was saved because it still isn't showing up in the menu, you can go to ~/Library/Services/ in Finder, where all workflows are stored. Keep in mind that the Library folder is hidden if you've never accessed it before. You can go here to find out how to view it and its contents.

The /Library/Services folder with your workflows

Related Question