6

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.

  • usually is a good practice when the downvoter add an comment to tell what is wrong with the question... – jm666 Mar 19 '16 at 0:44
  • Could you clarify what it is you want to do? Is it just that you're trying to get a service you already wrote in Automator into the Services menu? If so, check out this link. What steps have you taken so far? – jmindel Mar 19 '16 at 9:24
  • @Jenguinie just added more information. – jm666 Mar 19 '16 at 14:10
  • Thanks! I've posted an answer. Let me know if it's useful, or if you have any trouble with any of the steps or downloading the workflow I wrote. – jmindel Mar 19 '16 at 19:15
6

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

  • Thank you for your work and detailled answer. It sure will help to someone in general. Unfortunately, this isn't for what me looking: 1.) this service saves the current Safari windows url and not the right-clicked link. 2.) Also, the "Save URL" is shows only in the Safari->Services menu, and not in the "right-click" contenxtual menu. Please, check my screenshot - what i mean, e.g. i want an entry in the contextual-service menu which appears when you right-click on some link on the page and want get the right-clicked link's URL not the current webpage's URL. ;) – jm666 Mar 19 '16 at 21:35
  • @jm666 I think I've found the answer to your issue. I'll either create a new answer or update this one shortly. – jmindel Mar 21 '16 at 17:36
  • @jm666 Let me know if what I added is helpful when you get the chance. – jmindel Mar 21 '16 at 19:39
  • In my ElCapitan is something broken. Following exactly your workflow the service doesn't shows in the context menu. But because your screenshot shows the service, accepting it - and will try figure out the problem on my system. thanx, +1-accept – jm666 Mar 21 '16 at 19:42
  • @jm666 Sorry I couldn't help you out more. Let me know how things progress. I'm on Yosemite still, so there may be a difference. Best of luck! – jmindel Mar 21 '16 at 19:50

You must log in to answer this question.

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