Display web page preview for any link, not just in Apple Mail?

Hi. Sometimes I’d like to quickly preview a webpage without resort to a web browser, in the same way you can do that in Apple Mail (right click a link to preview web page). Is there a way to reproduce this for any link (including hyperlinks) in any app? What I do now is: I created a simple Automator app which gets the clipboard, extracts URL, puts it up in a website popup. Pretty convenient, but you still have to copy the link first. Then I invoke the web pop-up app using KM hotkey. If possible I’d like to at least be able to use the KM html prompt to display the page, but that may be a really dumb idea. I’m no pro!

You could select the link, and then trigger a KM Macro which would:

  1. Copy the link

If you don’t mind, I’d like to see your Automator workflow.

Yes, I have an automator workflow which acts as a service, which allows you to select a link – a full link, not a hyperlink – and preview it. But that doesn’t help me when I am reading an article with hyperlinks, because I can’t select the hyperlink and activate the service. I have to copy the URL behind the hyperlink. I wanted to do that and preview the link, without having to open a browser tab or save to a read later service. So, here is the service workflow, and here is the app version.

The service version really only works when you have a full link to select. With a hyperlink, you would copy the URL, then, using a KM hotkey, you trigger the app version, which gets the clipboard, extracts the URL and pops up the web preview. (The service workflow goes in the Services directory in Library; the app goes directly into Applications directory).

Here is the KM hotkey and app version in action using Tweetbot hyperlinks. (Selecting a shortened URL does not work with the service version, either.)

Here is the app version in action using a hyperlink.

To make the service version effective for hyperlinks, after selection of the hyperlink text, the workflow would have to copy the link, and I don’t know of an action that takes selected hyperlink text and gets behind it to copy the URL.

Although this has had ONLY LIMITED testing, I think it should work for you to extract the URL from a selected hyperlink. Give it a try and let me know if it works for you.

This macro uses RegEx to extract the URL:
/<a.+href[ \t]*=[ \t]*["'](.+?)["']/i

You can view the RegEx with explanation here:

There is another approach that uses Execute JavaScript in Browser Action (KM Wiki) to extract the URL. It might be more reliable on web pages.

###MACRO:&nbsp;&nbsp;&nbsp;@Web Extract URL from Hyperlink

~~~ VER: 1.0&nbsp;&nbsp;&nbsp;&nbsp;2017-05-23 ~~~

<a class="attachment" href="/uploads/default/original/2X/9/9da0fbd80e61a9dff335c3a179680d3790e48a95.kmmacros">@Web Extract URL from Hyperlink.kmmacros</a> (2.2 KB)



**NOTICE: This macro/script is just an _Example_**

* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete.  It is provided as an example to show you one approach to solving a problem.


<img src="/uploads/default/original/2X/4/4f3ee762ab8e0085219e03ed77bab78762fc75dd.png" width="529" height="740">


var htmlStr = pboardUnpacked('public.html')

var reURL = /<a.+href[ \t]*=[ \t]*["'](.+?)["']/i;
urlStr = reURL.exec(htmlStr)[1];

//~~~~~~~~~~~~ END OF MAIN SCRIPT ~~~~~~~~~~~~~~~

// Types: 'public.rtf', 'public.html' etc
function pboardUnpacked(strType) {
        return ObjC.unwrap(


@BKammer, here is the JIB macro I mentioned. You can choose what works best for you. This is based on the excellent macro by @ComplexPoint. I made a simple mod to the JavaScript to return only the URL.

###MACRO:   @Web Copy webpage link under cursor as Markdown @URL (Author.@ComplexPoint)

~~~ VER: 2.0    2017-05-23 ~~~

@Web Copy webpage link under cursor as Markdown @URL (Author.@ComplexPoint).kmmacros (27 KB)

###Example Results



Topic Title: Copy link under cursor in Safari or Chrome as Markdown
URL: Copy link under cursor in Safari or Chrome as Markdown

Date: 2015-08-16
Author: ComplexPoint

(All Actions with changes are in Magenta color)

Date:  2017-05-23
By:      @JMichaelTX

Purpose:  Change output from MD to just text of URL


<img src="/uploads/default/original/2X/b/b9d7bf8d1167c37cef0ad7ea01cb56b15dd2d32f.png" width="529" height="914">  

(function () {
  var nh = document.querySelectorAll(':hover'),
    iLast = (nh ? nh.length : null),
    nodeHover = (iLast ? nh[iLast - 1] : null),

    oLinkNode = nodeHover ? document.evaluate(
      null, XPathResult.FIRST_ORDERED_NODE_TYPE, 0
    ).singleNodeValue : null;

  // --- RETURN ONLY THE URL ---
  return oLinkNode ? (
  (oLinkNode.getAttribute('data-href') || oLinkNode.href)
  ) : ''