Firefox 浏览器附加组件
  • 扩展
  • 主题
    • 适用于 Firefox
    • 字典和语言包
登录
Right-Click to New-Tab 2026 预览

Right-Click to New-Tab 2026 作者: Sean Hollen

Right-clicking a link opens it in a new tab, at the position a middle-click would have used.

0(0 条评价)0(0 条评价)
9 个用户9 个用户
下载 Firefox 并安装扩展
下载文件

扩展元数据

关于此扩展
Right-clicking a link opens it in a new tab, at the position a middle-click would have used.

Why it exists

Extensions that already do this are unreliable in three ways:
  1. They miss links. On many sites the right-click falls through to the normal context menu and no tab opens. The causes were the same across extensions:
  2. attaching listeners late (document_idle) or only when the page changes;
  3. listening for mousedown/mouseup, which never fire when a page calls preventDefault() on pointerdown (carousels, sliders, drag libraries);
  4. listening at a point the page can stop first (stopPropagation in a window capture listener);
  5. not handling shadow DOM, SVG links, <area>, srcdoc iframes or pages that call document.open().
  6. They put tabs in the wrong place. Several use index: current + 1, so clicking links 1, 2, 3 gives tabs in the order 3, 2, 1. Others ignore what the browser does after you switch tabs, close a child tab or middle-click between right-clicks. Most open into the wrong window when another window has focus.
  7. They fire on things that aren't links. Some open a tab for href="#", images or canvases, or for a link that sits under the element you clicked. Some open two tabs for nested links, or open a tab after a right-button drag.

How it works
  • Content script, injected at document_start into every frame, including about:blank and srcdoc frames:
  • Window capture listeners for pointerdown, contextmenu and pointerup. They are registered before any page script, so the page can't block them. Pointer events still fire when the page cancels mouse events.
  • On press, it finds the link under the cursor by walking the flattened tree: into open and closed shadow roots (event.originalTarget, openOrClosedShadowRoot), through slots, and out via ShadowRoot.host. Only <a href>, <area href> and SVG href/xlink:href links with an http(s) URL count.
  • It cancels contextmenu only for those links. This works whether the menu event fires on press (Linux, macOS) or on release (Windows).
  • On release, it opens the tab unless the pointer moved more than 6 px in any direction or a modifier key is held. The URL is read at release, as a middle-click would, so links whose href is rewritten on press are honoured. If the page removed the link meanwhile, the URL from the press is used.
  • A MutationObserver on document re-adds the listeners after document.open() wipes them.
  • Background script creates tabs one at a time, in click order:
  • openerTabId is set and no index is given, so Firefox positions the tab with its own middle-click rule. That rule covers placing tabs after earlier tabs opened from the same page, resetting when you switch tabs, and tab groups.
  • cookieStoreId is passed through, so the tab opens in the same container as the page.

What it deliberately doesn't do
  • No tab for anything without a URL: <button>, role="link", href="#", javascript:/mailto:/data: links, images, canvases, or links inside editable areas. These keep their normal right-click behaviour.
  • No telemetry, remote configuration or network requests. Permissions are storage, plus cookies to open tabs in the right container. There are no host permissions beyond the content script match.
  • No work outside the right button. Other clicks return at the first check, and nothing scans or tags links on the page.

Holding Shift, Ctrl, Alt or Meta while right-clicking, or using the keyboard menu key, shows the normal context menu. The toolbar button turns the extension off or on for the current site.

Results

Every scenario is also run with a native middle-click and no extension. That run is the reference for correct tab order.

69 synthetic edge cases and 11 tab-order scenarios. The pages cover the constructions above: shadow DOM, frames, page scripts that swallow events, SVG/area links, drags, holds and false-positive traps.

| Extension | Edge cases / 69 | Tab order / 11 |
|---|---|---|
| This extension | 69 | 11 |
| Right Click Opens Link New Tab 0.1.1 | 50 | 8 |
| Right Links WE 0.5b12 | 44 | 10 |
| Right Click Opens Link in a Background Tab 1.5 | 42 | 8 |
| Right Click Opens Link New Tab Correct Order 0.0.9 | 40 | 8 |
| Right Click Opens Link New Tab 0.0.7 | 28 | 2 |

Extensions not available for Firefox were ported to run the same tests.

Real sites: 246 out of 246 links worked, across about 35 sites (news, search, shopping, forums, docs, social), picking real links before and after scrolling. "Worked" means exactly one new tab, with the link's URL, no context menu, and the source page unchanged.

Page cost: on a page with 3,000 links and 300 consecutive DOM changes, the measured time was 1222–1234 ms, against 1235 ms with no extension. The two extensions that rescan the page on every change took about 3600 ms.

Known limitations
  • It can't run where Firefox blocks extensions: the PDF viewer, Reader View and about: pages.
  • Opened tabs carry no referrer. The tab-creation API can't set one.
  • It can't hide the menu if dom.event.contextmenu.enabled is false. That setting stops pages and extensions from suppressing the context menu, so the menu still appears.
  • Pseudo-links have no URL. Buttons and divs that navigate through JavaScript keep the normal right-click.
评分 0(1 位用户)
登录以评价此扩展
目前尚无评分

已保存星级评分

5
0
4
0
3
0
2
0
1
0
尚无评价
权限与数据

必要权限:

  • 访问您在所有网站的数据

收集的数据:

  • 开发者称此扩展无需收集数据。
详细了解
更多信息
附加组件链接
  • 复制附加组件 ID
版本
1.2.0
大小
16.07 KB
上次更新
2 个月前 (2026年10月4日)
相关分类
  • 收取点、新闻和博客
  • 标签页
许可证
MIT 许可证
版本历史
  • 查看所有版本
添加到收藏集
举报此附加组件
转至 Mozilla 主页

附加组件

  • 关于
  • Firefox 附加组件博客
  • 扩展工坊
  • 开发者中心
  • 开发者政策
  • 社区博客
  • 论坛
  • 报告缺陷
  • 评价指南

下载

  • Download Firefox
  • Windows
  • macOS
  • iOS
  • Android
  • Linux
  • All

最新版本

  • Nightly
  • Beta

商用版 Firefox

  • Enterprise

社区

  • Connect
  • Contribute
  • Developer

关注

  • Instagram
  • YouTube
  • TikTok
  • Bluesky
  • Podcast
  • 隐私
  • Cookie
  • 法律

除非另有注明,否则本网站上的内容可按知识共享 署名-相同方式共享 3.0 或更新版本使用。