grantwinney / generate-links-for-headers

A browser extension that generates links for all headers on the page (when it can) and makes it easier to share specific sections.
https://grantwinney.com/automatically-adding-links-next-to-all-headers-on-the-page-a-chrome-extension/
MIT License
15 stars 4 forks source link
anchor-links browser-extension chrome chrome-extension

Generate Links for Headers

I frequently want to share a link with someone, but I want to link to a specific section of the page. That means checking out the source code for the page, finding the header element or an anchor nearby, and (if it has an ID or Name assigned to it) appending it to the URL before sharing it.

I figured I can do better than that.

Create links for all headers automatically

Available for Firefox and Chrome (and so also Opera, Brave, and Edge), it scans the page and generates anchors for all headers on the page, assuming they have an ID or Name assigned.

Here's what it looks like.. pretty much. The screenshot is outdated but you get the point.

Headers with child elements

If the header itself doesn't have an ID or Name, it traverses all elements inside the header tags looking for the first element with an ID or Name assigned, since any element can be used as an anchor. If it finds one, it uses it as the anchor; if not, then there's nothing to link to and you won't see the icon appear for that header.

Excluded sites

The following sites are intentionally excluded, either due to implementing similar behavior already, or because displaying the icon doesn't work due to existing site layout/styles.

Questions? Issues?

If you have any questions, comments, or issues, feel free to create an issue and I'll check it out as my schedule permits.

Enjoy!


History

2018

2019

2020

2021

2022