Chrome: Open All Links and Print

Hello,

Can someone possibly help me find a workaround for this problem:

I have this website open in Chrome. There is always a table there with several rows (there can be several hundred rows).
The text under "Tour No." (for example 20210430-0950) is a hyperlink to the detail view of each row.

I want an automation to open each row/link, print it and close it again and then continue with the next one until there are no more links.
(or: first open all links in new tabs and then print all tabs).

Can someone help me here?

Thanks a lot!

Hey Kevin,

Welcome to the forum!   :smile:

This is likely a pretty complex task, but it should be doable.

Download and install BBEdit if you don't have it already. It has a 30 day demo period after which it will revert to its freeware (Lite) mode, but it will still be muy powerful.

Open the following macro (it will be installed in a Google Chrome macro group.

Google Chrome ⇢ Get Source 1.00.kmmacros (5.7 KB)

Run the macro – it will produce the source of your front page in Google Chrome.

Paste the source into BBEdit.

Start looking at the code and see if your table is well represented.

If so then it should not be too hard to parse.

Are you at all familiar with JavaScript?

-Chris

This will likely require Execute a JavaScript in Browser action.
I prefer using the JavaScript querySelector function.

If you are not familiar with JavaScript, or need help, please post the URL to this page if you can. If you can't, then post the HTML code using the forum Code Block that covers the target table plus a couple of <div>s above and below, and I'll try to help get you started.

You can view and copy the HTML code using the Chrome Inspect tool. Right-click on the table header, and select "inspect".

Hello,

thank you very much - I would like to accept your offer for further help. I can't post a link because the area is protected.

Attached is a screenshot and the HTML code of the page.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<!--[if lt IE 7]>      <html class="no-js ie lt-ie10 lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js ie lt-ie10 lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js ie lt-ie10 lt-ie9"> <![endif]-->
<!--[if IE 9]>         <html class="no-js ie lt-ie10"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js"> <!--<![endif]-->

    <head>
    	
    	
    	<!--nocache START-->
		<meta http-equiv="expires" content="-1"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="pragma" content="no-cache"/>
		<!--nocache END-->
    	
    
        <!-- Meta, title, CSS, favicons, etc. -->
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="" />
        <meta name="author" content="Micromata GmbH" />
        <title>eDataGate 1 Neu - Alle Touren</title>

        <!--
            CSS of bower libs.
            Non minified/merged versions for debugging purposes are
            replaced in the production ready build.
        -->
        <link rel="stylesheet" href="/edg/gw/edg1web/libs/libs.css" type="text/css" />

        <!-- Our compiled and merged LESS files -->
        <link rel="stylesheet" href="/edg/gw/edg1web/assets/css/index.min.css" type="text/css" />

        <!--
        Replace "no-js" class with "js" in case JavaScript is available.
        You can delete this when you feel the need to make use of modernizr.
        -->
        <script>(function(h){h.className = h.className.replace('no-js', 'js')})(document.documentElement)</script>

        <!-- HTML5 shim and Respond.js IE8 support for HTML5 elements and media queries. -->
        <!--[if lt IE 9]>
        <script src="/edg/gw/edg1web/libs/html5shiv/dist/html5shiv-printshiv.min.js"></script>
        <script src="/edg/gw/edg1web/libs/respondJs/dest/respond.min.js"></script>
        <![endif]-->

        <!-- Place favicon.ico and apple-touch-icon.png in the root directory. -->
        <link rel="shortcut icon" type="image/x-icon"
              href="/edg/gw/edg1web/assets/img/dhl_iconset_august2014/Favicon/140120_DHL_Favicon_64x64_01.gif" />

        <!-- Place anything custom after this. But put JS to the end of body. -->
    </head>

    <body>

        <!-- begin: wrapper -->
        <div id="main_wrapper">

            <div id="mm_header" class="mm_wrapper">
            <!-- begin: header -->
                <header class="hero-unit">
            <div class="lang-chooser">
                <ul>
                    
                    
                    <li class="lang-field"><a class="lang-active" href="?__lang=en&__gwfs=2799746007417212581">Englisch</a></li>
                    <li class="lang-field"><span class="language-current">Deutsch</span></li>
                    <!-- <li class="link-field"><a href="#" th:href="@{/Agb.action}" th:text="#{AGBAction.shortTitle}">AGB</a></li> -->
                    <li class="link-field"><a href="/edg/gw/edg1web/Impressum.action?__gwfs=2799746007417212581">Impressum/Datenschutzhinweise</a></li>
                </ul>
            </div>

            <a href="https://www.dhl.de/" class="mm_logo">
                <img src="/edg/gw/edg1web/assets/img/dhl-logo.gif" alt="DHL Logo">
            </a>

            <h1>eDataGate 1 Neu</h1>

            <ul class="nav nav-tabs" id="mm_mainNav-tabs" role="tablist"
            style="width: 950px;">
            <li>
                <a id="menu_sl_home" href="/edg/gw/edg1web/Index.action?__gwfs=2799746007417212581" role="tab">Startseite</a>
            </li>
            <li class="active">
                <a id="menu_sl_touren" href="/edg/gw/edg1web/TourListNew.action?__gwfs=2799746007417212581" data-target="#touren" role="tab">Touren</a>
            </li>
            <li>
                <a id="menu_sl_fahrplan" href="/edg/gw/edg1web/FahrplanFilter.action?__gwfs=2799746007417212581" role="tab">Fahrplan exportieren</a>
            </li>
            <li>
                <a id="menu_sl_unterbrechungen" href="/edg/gw/edg1web/TourUnterbrechungList.action?__gwfs=2799746007417212581" role="tab">Tourunterbrechung</a>
            </li>
            <li>
                <a id="menu_sl_istdaten" href="/edg/gw/edg1web/ActualDataFormSL.action?__gwfs=2799746007417212581" data-target="#actualdata" role="tab">Ist Daten</a>
            </li>
            <li>
                <a id="menu_sl_fapp_istdaten" href="/edg/gw/edg1web/ActualDataAllSL.action?__gwfs=2799746007417212581" data-target="#fappactualdata" role="tab">DHL Connect</a>
            </li>
            
            <li>
                <a id="menu_sl_dateiliste" href="/edg/gw/edg1web/FileList.action?__gwfs=2799746007417212581" data-target="#dateien" role="tab">Dateiliste</a>
            </li>
            <li style="float: right;">
                <a id="menu_sl_benutzer" href="#" data-target="#benutzer" role="tab">Benutzer</a>
            </li>
           
        </ul>
            <div class="tab-content" id="mm_mainNav-tabContent">
            <div class="tab-pane" id="touren">
                <div class="mm_wrapper">
                    <ul class="mm_navigation mm_flyout">
                        <li>
                            <ul>
                                <li><a id="flyout_sl_neuetouren" href="/edg/gw/edg1web/TourListNew.action?__gwfs=2799746007417212581">Neue Touren</a></li>
                                <li><a id="flyout_sl_geaendertetouren" href="/edg/gw/edg1web/TourListModified.action?__gwfs=2799746007417212581">Geänderte Touren</a></li>
                                <li><a id="flyout_sl_unvollstaendigetouren" href="/edg/gw/edg1web/TourListIncomplete.action?__gwfs=2799746007417212581">Unvollständige Touren</a></li>
                                <li><a id="flyout_sl_vollstaendigetouren" href="/edg/gw/edg1web/TourListComplete.action?__gwfs=2799746007417212581">Vollständige Touren</a></li>
                                <li><a id="flyout_sl_storniertetouren" href="/edg/gw/edg1web/TourListCancelled.action?__gwfs=2799746007417212581">Stornierte Touren</a></li>
                                <li><a id="flyout_sl_alletouren" href="/edg/gw/edg1web/TourListAll.action?__gwfs=2799746007417212581">Alle Touren</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
            <!-- EDATAG1MIG-695 -->
            <div class="tab-pane" id="fappactualdata">
               <div class="mm_wrapper">
                    <ul class="mm_navigation mm_flyout">
                        <li>
                            <ul>
                                <li><a id="flyout_sl_alleactualdata" href="/edg/gw/edg1web/ActualDataAllSL.action?__gwfs=2799746007417212581">Alle Ist-Daten</a></li><!-- EDATAG1MIG-682  -->
                                <li><a id="flyout_sl_tourInterruptionFapp" href="/edg/gw/edg1web/TourUnterbrechungListFapp.action?__gwfs=2799746007417212581">Tourunterbrechung</a></li><!-- EDATAG1MIG-680  -->
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>                 
            <div class="tab-pane" id="benutzer">
                <div class="mm_wrapper">
                    <ul class="mm_navigation mm_flyout">
                        <li class="pull-right">
                            <a id="flyout_sl_abmelden" href="/edg/gw/edg1web/Login.action?onLogout&__gwfs=2799746007417212581">Abmelden</a>
                            <ul>
                                <li>
                                    <a id="flyout_sl_benutzerverwaltung" href="/edg/gw/edg1web/UserManagement.action?__gwfs=2799746007417212581">Benutzerverwaltung</a>
                                </li>
                                <li>
                                    <a id="flyout_sl_passwortaendern" href="/edg/gw/edg1web/ChangePassword.action?__gwfs=2799746007417212581">Passwort ändern</a>
                                </li>
                                
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        </header>
            <!-- end: header -->
            </div>

            <div id="wrapper" class="mm_bootstrapElement">
            <!-- begin: mm_container -->
                <section class="container" id="mm_container">
                <!-- begin: main -->
                <div id="mm_main" class="mm_tourList">

                    <div class="row mm_bootstrapElement">
            <!-- begin: grid column -->
            <div class="col-xs-12">

                <p style="text-align: right;">Firma: RTS Benutzer: reymann</p>

                <h1>Alle Touren</h1>

                <!-- begin: feedback panel -->
                
                <!-- end: feedback panel -->

            </div>
            <!-- end: grid column -->
        </div>

                    <!-- begin: content -->

                    <div class="row">
                        <div class="col-xs-12">
                            <form role="form" method="GET" action="/edg/gw/edg1web/TourListAll.action" ><input type="hidden" name="__gwfs" value="2799746007417212581"/>

                                <div class="row formMargin">
                                    <div class="col-xs-3">
                                        <label for="tournummer">Tournummer</label>
                                    </div>
                                    <div class="col-xs-9">
                                        <input type="text" class="form-control" id="tourNummer"
                                               placeholder="Tournummer tippen (yyyymmdd-####)" name="tourFilter.tourNummer" value>
                                    </div>
                                </div>

                                <div class="row formMargin">
                                    <div class="col-xs-3">
                                        <label for="zeitraum_von.datum">Zeitraum von</label>
                                    </div>
                                    <div class="col-xs-5">
                                        <input type="text" class="form-control mm_hasDatepicker" id="fromDateString"
                                               placeholder="Datum auswählen oder tippen (dd.mm.yyyy)" value="02.05.2021" name="tourFilter.fromDateString">
                                    </div>
                                    <div class="col-xs-4">
                                        <input type="text" class="form-control" id="fromTimeString"
                                               placeholder="Uhrzeit tippen (hh:mm)" value="00:00" name="tourFilter.fromTimeString" >
                                    </div>
                                </div>

                                <div class="row formMargin">
                                    <div class="col-xs-3">
                                        <label for="zeitraum_bis.datum">Zeitraum bis</label>
                                    </div>
                                    <div class="col-xs-5">
                                        <input type="text" class="form-control mm_hasDatepicker" id="toDateString"
                                               placeholder="Datum auswählen oder tippen (dd.mm.yyyy)" value="03.05.2021" name="tourFilter.toDateString" >
                                    </div>
                                    <div class="col-xs-4">
                                        <input type="text" class="form-control" id="toTimeString"
                                               placeholder="Uhrzeit tippen (hh:mm)" value="10:00" name="tourFilter.toTimeString" >
                                    </div>
                                </div>

                                <div class="row formMargin">
                                    <div class="col-xs-3"></div>
                                    <div class="col-xs-9">
                                        <input type="hidden" name="tourFilter.orderBy" value="tourNummer" />
                                        <input type="hidden" name="tourFilter.sortOrder" value="ASC" />
                                        <button type="submit" class="btn btn-primary mm_btn_arrow mm_preventMultiplePosts" name="onFilter">Aktualisieren</button>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>

                    

                    <div class="row">
                        <div class="col col-xs-12">
                            <!-- Table -->
                            <table id="tourListTable" class="table table-hover table-striped mm_datatable mm_dynTable">
                                <thead>

                                    <tr>

            <th class="wicket_orderDown">
                <a href="?onSort=true&amp;orderBy=tourNummer&amp;sortOrder=DESC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Tour Nr.</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=tourAfzLong&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Abzugsort</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=tourEfzLong&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Ankunftsort</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=ladeBeginnAfz&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Beginn</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=entladeEndeEfz&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Ende</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=tourTourtyp&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Tourtyp</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=slKurzname&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>SL</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=tourStatus&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>Status</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=idKarte&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>ID-Karte</span><i></i></a>
            </th>

            <th class="wicket_orderNone">
                <a href="?onSort=true&amp;orderBy=bearbeitungDEN&amp;sortOrder=ASC&__gwfs=2799746007417212581"
                   class="mm_table_sort"><span>BEARB</span><i></i></a>
            </th>

        </tr>

                                </thead>
                                <tbody>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=0&__gwfs=2799746007417212581">20210502-0051</a>
                                    </td>
                                    <td>DEU 14641 BÖRN</td>
                                    <td>DEU 24539 NMÜN</td>
                                    <td>02.05.2021 22:30</td>
                                    <td>03.05.2021 03:30</td>
                                    <td>H</td>
                                    <td>RTS</td>
                                    <td>SX</td>
                                    <td></td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=1&__gwfs=2799746007417212581">20210502-0179</a>
                                    </td>
                                    <td>DEU 22113 BHAM</td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>02.05.2021 22:30</td>
                                    <td>03.05.2021 00:00</td>
                                    <td>S</td>
                                    <td>RTS</td>
                                    <td>BV</td>
                                    <td>15491</td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=2&__gwfs=2799746007417212581">20210503-0392</a>
                                    </td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>03.05.2021 02:30</td>
                                    <td>03.05.2021 04:00</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>BV</td>
                                    <td>15491</td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=3&__gwfs=2799746007417212581">20210503-0393</a>
                                    </td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>03.05.2021 04:00</td>
                                    <td>03.05.2021 05:45</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>BV</td>
                                    <td>15491</td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=4&__gwfs=2799746007417212581">20210503-0394</a>
                                    </td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>03.05.2021 06:20</td>
                                    <td>03.05.2021 08:05</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>BV</td>
                                    <td>15491</td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=5&__gwfs=2799746007417212581">20210503-0413</a>
                                    </td>
                                    <td>DEU 46282 DORS</td>
                                    <td>DEU 46282 DORS</td>
                                    <td>03.05.2021 04:00</td>
                                    <td>03.05.2021 19:25</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>BV</td>
                                    <td>15350</td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=6&__gwfs=2799746007417212581">20210503-0437</a>
                                    </td>
                                    <td>DEU 24539 NMÜN</td>
                                    <td>DEU 23560 MZB_LÜB</td>
                                    <td>03.05.2021 06:30</td>
                                    <td>03.05.2021 09:28</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>SX</td>
                                    <td></td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=7&__gwfs=2799746007417212581">20210503-0452</a>
                                    </td>
                                    <td>DEU 24539 NMÜN</td>
                                    <td>DEU 24539 NMÜN</td>
                                    <td>03.05.2021 05:30</td>
                                    <td>03.05.2021 11:01</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>SX</td>
                                    <td></td>
                                    <td>N</td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="/edg/gw/edg1web/TourDetail.action?tourListIndex=8&__gwfs=2799746007417212581">20210503-0482</a>
                                    </td>
                                    <td>DEU 17235 NSTR</td>
                                    <td>DEU 21035 HAMB</td>
                                    <td>03.05.2021 05:10</td>
                                    <td>03.05.2021 22:30</td>
                                    <td>N</td>
                                    <td>RTS</td>
                                    <td>BV</td>
                                    <td>15267</td>
                                    <td>N</td>
                                </tr>
                        

                                </tbody>
                            </table>
                        </div>
                    </div>

                    <!-- end: content -->

                </div>
                <!-- end: main -->
            </section>
            <!-- end: mm_container -->
            </div>

            <div id="mm_footer" class="mm_wrapper">
            <!-- begin: footer -->
                <footer class="footer">
            <!--
            JavaScript
            =======================================================
            Placed at the end of the document. Performance reasons.
            Non minified/merged versions for debugging purposes are
            replaced in the production ready build.
            -->

            <!-- Libs -->
            <script src="/edg/gw/edg1web/libs/libs.js"></script>

            <!-- Own JS -->
            <script src="/edg/gw/edg1web/assets/js/built.min.js"></script>

            <!-- External scripts (eg. analytics) should be placed here -->
            
        </footer>
            <!-- end: footer -->
            </div>
        </div>
        <!-- end: wrapper -->

    </body>
</html>

Thanks. I'll take a look at it.
It make take me a few days before I have any results, due to my schedule.

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.
http://area85.de/html.pdf

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.

html.zip (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:

image

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


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

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

HOW TO USE

  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.

MACRO SETUP

  • 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
      .

REQUIRES:

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

TAGS: @Example

==USE AT YOUR OWN RISK==

  • 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.

www.
area85
.de
/
cleanshot.mp4

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:
image

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.