Chrome: Open All Links and Print

How exactly do you want to print each of the target links?

  • Actually print to physical printer, or to PDF?
  • Print using default Chrome print settings?
  • Confirm each print, or just auto-print?

Also, I will need the HTML code for one of the link pages so I can pause until the page is fully loaded.

First of all, thank you very much for the help.

to your questions
The physical printer is to be used
the standard settings of the Chrome print dialog can be used
As far as possible, it should be automated so that no one has to click on print on every page.

and here is the HTML of one of the pages to be printed ...
There are too many characters for this thread, hence a link to an HTML on my server.

Thanks, but I really need the HTML code. Can you please zip the HTML file and upload it here?
If for some reason you can't upload here, a link to the zip file on your server will be fine. (18.5 KB)

ok, sorry
here ist the HTML in a Zip File

OK, I believe I have a solution for you.
This macro first extracts all links from the main web page with the table.

It then displays an Alert for you to confirm you want to print all of then Links:


A new Tab is opened, then each link is opened in it and prints it.
A standard Notification is sent as each link is printed.
The tab is closed when the macro is finished.

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Please test with an main web page the contains only a few links in the table, something like 3-5 links.
If that works well, then you can use with larger tables.

Please let me know if you have any issues, or need to tweak the macro in any way.

Please let us know if it meets your needs.


MACRO:   Print All Links on Web Page Table [Example]

-~~~ VER: 1.0    2021-05-03 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Print All Links on Web Page Table [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

Please Note these changes




  • Print All Links on Web Page Table
    • Extract the URL from each Link in Designated Table (using querySelector)
    • Then Open and Print each URL


  1. First, make sure you have followed instructions in the Macro Setup below.
  2. See the below "How to Use" Comment Action
  3. This macro is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.


  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      Make These Changes to this Macro
  1. Assign a Trigger to this Macro .
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
  3. ENABLE this Macro, and the Macro Group it is in.
    • For more info, see KM Wiki article on Macro Activation


  1. KM 9.0+ (may work in KM 8.2+ in some cases)
  2. macOS 10.12.6 (Sierra)+

TAGS: @Example


  • While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Macro Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

First of all, thank you very much.
I activated the macro and set a trigger.

When I run it, the macro only finds one link - although there are several - and when I continue only an empty tab opens.
Am I doing something wrong?

Could be.
Your video will not play.

Here's a quick video demo of the macro on my system:
Keyboard Maestro 9.2 on macOS 10.14.6 (Mojave)

OK. here is the direct link to the video from me. Remove the dial tone, of course.


OK, this would seem to indicate that the HTML code is different for your actual page than for the example you sent me.

So please do this:

Open the Chrome DevTools window using the "inspect" tool:

You should see this:

I updated my demo video to provide a complete demo of the entire macro.

CleanShot 2021-05-03 at 22.22.53

Well, that looks right.

So please try this:
In the JavaScript Console window of the Chrome DevTools, enter this:
linkCollect = document.querySelectorAll('#tourListTable td a');

and press return.

You should see:
NodeList(9) [a, a, a, a, a, a, a, a, a]

If not, please post what you see.

I think it works - for me there are 13 links that are counted.

CleanShot 2021-05-03 at 22.32.05

OK, great!

Now enter this command:
linkList = Array.from(linkCollect).map(function(x) {return x.href;});

BTW, be sure you have "Allow JavaScript from Apple Events checked:

Also, please insert this Action immediately after the Script Action near the top of the macro:

Display Text Action (v9.2)

Display Text.kmactions (1.1 KB)

and rerun the macro.
Post a screenshot of this window.

"Allow JavaScript from Apple Events" - was not enabled.
I made up for it.

I am now ready to count the 13 links correctly. But when I click on Continue, only 1 tab opens and unfortunately there is no printing yet.

OK, it would be much easier and faster if we could do a macOS screen share.
Would that be OK with you?

yes, no problem

Problem resolved.

Three changes:

  1. Enable (check) the Chrome > View > Developer > Allow JavaScript from Apple Events
  2. Convert all KM Select Menu Actions to use local language.
  3. Convert all Pause Until Button Actions to use local language.

Macro now runs on @kevindax's Mac.

again, many, many thanks for the great help! The macro will help me save a lot of time in the future with monotonous work.

1 Like