
Ask HN: Is there a browser extension for opening all links on HN in new tabs? - KoenDG
By this I mean: add an option to the context menu of the browser that says &quot;open all links on this HN page&quot;.<p>And as a result of that, 25 tabs get opened, that being all the links on the page.<p>That&#x27;s my use case: I want to open up all the links, at the same time, each in their own tab, and I can just CTRL+TAB through them as I please.<p>I&#x27;m just asking here on the off-chance that it exists but I somehow could not find it. If it doesn&#x27;t exist yet, I may well have to write it myself, which I frankly hope doesn&#x27;t take too much effort. Let&#x27;s hope there&#x27;s some decent boilerplate for this, that can be easily found.<p>Thanks in advance for any help.
======
neckardt
I hacked together a quick bookmarklet, here's how to get it working in
firefox:

1\. Create a new bookmark to any page, name it whatever.

2\. Right click the bookmark -> Properties

3\. Replace the "Location" field with:

    
    
      javascript:stories=document.getElementsByClassName("storylink");for(idx=0;idx<stories.length;idx++){ window.open(stories[idx].href)}
    

While on HN if you click the bookmarklet, it will open all of the links in a
new tab.

~~~
gabrielsroka
That's great! Thanks for sharing.

------
brudgers
I once wrote a greasemonkey script to do exactly that. The tricky bit was the
rate limit of HN requests required adding an empirically determined delay
inside the loop iterating through the links (there are thirty on the main page
not 25).

Even with the delay one or two of the thirty requests would usually hit the
rate limit, but this was faster than slowing the loop down with a larger delay
in terms of how I used the script. It was kludge coded but good enough for my
needs.

Note that “all the links” is not all the links. There are flag and vote and
user account and site history and two discussion links for the typical front
page story. Plus the header and footer links and the login or logged in links.

------
gabrielsroka
I took @neckardt's bookmarklet and wrote a slightly shorter/different version:

    
    
      javascript:document.querySelectorAll('.storylink').forEach(s=>open(s.href)) //Open All HN
    

To install, select all the text (including the "//Open All HN" comment) and
drag it to your bookmarks toolbar. The comment becomes the bookmark name in
Chrome and it kinda works in Safari, but not in Firefox.

Is anyone worried about opening 30 random-ish links? I wouldn't do it...

------
scott31
[https://github.com/clarete/hackernews.el](https://github.com/clarete/hackernews.el)
This should do what you are asking

------
DonCopal
There are also some alternative HN web clients and I believe some have
Previous/Next thread buttons, but I can't remember now.

------
stevekemp
Not an extension, but this is a common thing that could be done with a
bookmarklet - open all links on the current page in a new tab.

Perhaps this is a good starting point:

[https://gist.github.com/toastal/01c2387456ad2e6385f4](https://gist.github.com/toastal/01c2387456ad2e6385f4)

------
jituc
It would be easier to write greasemonkey script. I use it to read manga, just
loop through title links and open with _blank target with time delay of 1s as
setTimeOut delay

------
thanatos519
ISTR there was a gesture to do this in Galeon, but tabbed browsing has gone
downhill since then.

------
KoenDG
Sweet, thanks for the replies. I hadn't considered simply using a bookmarklet,
even.

