4

Can several links be opened at once in Safari? Imagine you are on a page with a lot of links:

enter image description here

Would it be possible to select all the links and open them all in one single Command-click? As such:

enter image description here

I am often finding myself Command-clicking links for dozens of minutes a day, and wishing I could open more links all at once. Surely I'm not the only person in this situation!

3
  • 1
    For anyone who is open to using another browser, there are many extensions for firefox and chrome that do this. For Chrome I'd recommend Linkclump and for Firefox Multi Links Plus
    – Joonas
    Feb 27, 2017 at 12:46
  • Thank you for this comment. Sleipnir has a function that does this natively. Apr 21, 2017 at 18:24
  • Also, I'm not "against" using, say, Chrome, but the direct right-click option to "save image to downloads" in Safari is a huge time gain (and other features) May 23, 2018 at 18:11

2 Answers 2

1

There is a way to do something close - it involves adding a bookmarklet to Safari and selecting that once you're on the page.

However, this will either open only the hyperlinks you've selected (i.e. highlighted) on the page or it will open all hyperlinks found on the page if you haven't highlighted any. In other words, it doesn't work in the Command + click manner you want.

If you're interested, here's the process to set this up:

  1. Visit any page using Safari
  2. Press CommandD to add a bookmark to the page you just visited
  3. In the highlighted field that appears in the window, change the text to something like Open all hyperlinks
  4. Press OptionCommandB to edit bookmarks
  5. Find the bookmark you just added and right-click on it
  6. Select Edit Address... from the context menu
  7. This should highlight the URL. Press Delete to remove it
  8. Now paste the following code where the URL was previously:

javascript:(function(){var n_to_open,dl,dll,i; function linkIsSafe(u) { if (u.substr(0,7)=='mailto:') return false; if (u.substr(0,11)=='javascript:') return false; return true; } n_to_open = 0; dl = document.links; dll = dl.length; if (window.getSelection && window.getSelection().containsNode) { /* mozilla */ for(i=0; i<dll; ++i) { if (window.getSelection().containsNode(dl[i], true) && linkIsSafe(dl[i].href)) ++n_to_open; } if (n_to_open && confirm('Open ' + n_to_open + ' selected links in new windows?')) { for(i=0; i<dll; ++i) if (window.getSelection().containsNode(dl[i], true) && linkIsSafe(dl[i].href)) window.open(dl[i].href); } } /* /mozilla */ if (!n_to_open) { /*ie, or mozilla with no links selected: this section matches open_all_links, except for the alert text */ for(i = 0; i < dll; ++i) { if (linkIsSafe(dl[i].href)) ++n_to_open; } if (!n_to_open) alert ('no links'); else { if (confirm('No links selected. Open ' + n_to_open + ' links in new windows?')) for (i = 0; i < dll; ++i) if (linkIsSafe(dl[i].href)) window.open(dl[i].href); } } })();

  1. Press Return to accept the code

To make this work, open any page in Safari and then select the bookmarklet. One of the following things will happen:

  • if you haven't highlighted any hyperlinks on the page, the code will proceed to open all hyperlinks in a separate tab
  • if you've highlighted x number of hyperlinks, then the code will proceed to open those selected hyperlinks in separate tabs

IMPORTANT: If this doesn't work for you, ensure that you have Javascript enabled. You can do this via Safari > Preferences > Security.

One more thing - I have tried many times to get the above javascript to work as a Service in Safari (thinking that would be better than the bookmark approach), but have never been able to get it to work. On the off-chance you do, please share how. :)

1
  • 1
    The most recent (at least a recent) Safari upgrade appears to have broken this ... the script is only opening the first link. Any suggestions on a fix?
    – Chris
    Sep 30, 2017 at 2:16
0

Try https://greasyfork.org/scripts/471560 if you can use Tampermonkey in Safari, it's a reimplement of Linkclump, but in userscript

You can install Tampermonkey or Stay by search the name in MacOS app store

1
  • 1
    This might be more useful with some explanations on how to get/install Tampermonkey for Safari.
    – nohillside
    Jul 24, 2023 at 6:25

You must log in to answer this question.

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