cssnr / open-links-in-new-tab

https://open-links-in-new-tab.cssnr.com
GNU General Public License v3.0
3 stars 0 forks source link

Don't open a new tab for URL hash properties of the current page #27

Closed deadcombo closed 4 months ago

deadcombo commented 4 months ago

Hi.

Links such as https://wiki.archlinux.org/title/Systemd#Drop-in_files trigger a new tab at the moment. While that can be a desired behavior for complex pages it would be nice to have the option to not have a new tab when following # links. Ideally stored per-site.

Thanks! This add-on makes web-browsing a lot more consistent.

smashedr commented 4 months ago

That is a solid request. I will at minimum add a global option, and hopefully get a per-site option.

smashedr commented 4 months ago

I had a few pending updates, I released them and the global option for Anchor Links in 0.2.1. By default, anchor links for the same origin are disabled and can be enabled in the Popup or Options.

The core logic for the feature is as follows:

if (!options.anchorLinks && element.href.includes('#')) {
    const url = new URL(element.href)
    if (url.origin === window.location.origin) {
        continue // do not update this link
    }
}

Firefox publishing is almost always instant and available now. Google Chrome is pending review, but a signed release is always available form the latest release in the form of a .crx download from: https://github.com/cssnr/open-links-in-new-tab/releases/tag/0.2.1

There are a few pressing issues I need to resolve before implementing per-site options; therefore, I put it on the roadmap.

Thank you for reporting this issue as it was - not to sound like ChatGPT - an oversight on my part.

deadcombo commented 4 months ago

I've been using it since it hit Firefox, no bugs. Cheers 👍

I don't have a need for per-site, if I would a regular Ctrl+click should do. Mentioned it just for your consideration.