Tiện ích trình duyệt Firefox
  • Tiện ích mở rộng
  • Chủ đề
    • cho Firefox
    • Từ điển & gói ngôn ngữ
    • Các trang web trình duyệt khác
    • Tiện ích cho Android
Đăng nhập
Xem trước Force New Tab

Force New Tab bởi SurgWaterfox

Opens JavaScript driven buttons in new tabs like standard html links.

0 (0 đánh giá)0 (0 đánh giá)
Tải xuống Firefox và tải tiện ích mở rộng
Tải xuống tập tin

Siêu dữ liệu mở rộng

Ảnh chụp màn hình
Về tiện ích mở rộng này
Force New Tab

A Firefox extension that forces middle-click on any element to open in a new tab — including JavaScript-driven buttons, cards, and links that normally ignore middle click.

The Problem

Modern websites are often built as Single Page Applications (SPAs) using frameworks like React, Vue, and Angular. Navigation on these sites is handled entirely by JavaScript rather than standard <a href> links. As a result, middle-clicking elements like cards, buttons, and tiles either does nothing or navigates the current tab instead of opening a new one. Force New Tab solves this transparently, without breaking normal browser behaviour.

How It Works

When you middle-click an element, the extension works through a chain of fallbacks in order, stopping as soon as it finds a URL to open:

Real links are ignored — if the clicked element is a genuine <a href> link, the extension does nothing and lets the browser handle it natively. (Opens in new tab by default.)

data-* attribute scan — checks the clicked element and its ancestors for common URL attributes like data-href, data-url, data-link, data-navigate etc.

Child anchor search — searches inside the card container for any <a href> link. Useful for sites like Spotify where the image and text are separate elements inside the same card, but only the text has a real link.

Page world hooks — intercepts standard JavaScript navigation methods:
window.open
history.pushState
history.replaceState
location.href
location.assign
location.replace

Click replay — if nothing is captured after 500ms, the extension re-fires mousedown, mouseup, and click events on the element to trigger its JavaScript handler, then intercepts the resulting navigation.

URL polling — as a last resort, monitors window.location.href for changes after the click replay fires. If the URL changes, the new URL is opened in a new tab and the current tab is snapped back to its original URL.


Compatibility

The extension is designed to work on as many sites as possible. Tested on:
Site Status Method used
YouTube ✅ Works Page world hooks
Reddit ✅ Works Page world hooks
Twitter / X ✅ Works Page world hooks
Spotify ✅ Works Child anchor search
GitHub ✅ Works Real links / page world hooks
Twitch ✅ Works Page world hooks
Pinterest (cards) ✅ Works Child anchor search
Pinterest (filter buttons) ⚠️ Partial URL polling — current tab also navigates, use back button to restore

Known Limitations

Strict CSP sites — some sites (like Pinterest) block page-world script injection via Content Security Policy. The extension degrades gracefully, falling back to DOM-based methods that don't require page-world access.
Modal/dialog triggers — buttons that open dialogs rather than navigating to a new page have no URL to open. The extension correctly does nothing in these cases.
Internal framework routers — some sites use heavily customised internal routers (like Spotify's) that bypass all standard navigation methods. The child anchor search and click replay fallbacks handle most of these cases.


Permissions

The extension requests the following permissions:

tabs — required to open URLs in new background tabs


No data is collected, stored, or transmitted. The extension has no network access and makes no external requests. All processing happens locally in your browser.

Version History
v1.3.0

Added URL polling fallback for sites that bypass all JavaScript hooks
Added child anchor search for Spotify-style card components
Added history.replaceState interception


v1.2.0

Added location.href, location.assign, and location.replace interception
Added click replay fallback


v1.1.0

window.open, history.pushState interception
Real link passthrough
data-* attribute fallback


v1.0.0

Initial public release


License
MIT
Chú thích của nhà phát triển
Purpose:
This extension enables users to middle-click JavaScript driven elements (such as buttons or divs with onclick handlers) and force them to open their destinations in a new browser tab, similar to how native anchor (<a href="">) elements behave. It does not modify or collect page content.
Content Script Scope (<all_urls>)
The content script runs on all URLs (<all_urls>) because it needs to be active on any website where the user may want to use middle-click to force a new tab; even on JavaScript heavy SPAs. However, the script does not collect, transmit, or store any content or personal user data. It acts only on user initiated middle-clicks.

Use of Script Injection
To enable interception of navigation APIs (e.g., window.open, history.pushState, and history.replaceState), the extension injects a helper script into the page context. This allows the interception of navigation caused by JS driven buttons that don’t generate standard click events. The injected script does not collect data or introduce additional functionality beyond enabling new tab navigation. This pattern is necessary because content scripts cannot patch page navigation APIs directly.

Background Service Worker
The background script is a Manifest V3 service worker. It simply opens the specified destination URL in a background tab in response to the content script’s message. It does not store data between invocations or use persistent storage. Deduplication is only handled within the brief window of a single service worker session (to prevent multiple simultaneous tabs from opening on accidental double clicks).

Privacy Practices
The extension does NOT transmit user data to any remote server, nor does it collect, read, or modify page content, cookies, or history. Only destination URLs from the click action are used, and only for the sole purpose of opening a new tab as per user intent.

Permissions Requested
The only permission requested is tabs, which is strictly required to open new tabs in response to user actions.
Được xếp hạng 0 (bởi 1 người dùng)
Đăng nhập để đánh giá tiện ích này
Chưa có xếp hạng nào

Đã lưu xếp hạng sao

5
0
4
0
3
0
2
0
1
0
Chưa có đánh giá
Quyền hạn và dữ liệu

Quyền hạn bắt buộc:

  • Truy cập các thẻ trên trình duyệt
  • Truy cập dữ liệu của bạn trên mọi trang web

Thu thập dữ liệu:

  • Nhà phát triển cho biết tiện ích mở rộng này không yêu cầu thu thập dữ liệu.
Tìm hiểu thêm
Thêm thông tin
Phiên bản
1.3.0
Kích cỡ
12,43 KB
Cập nhật gần nhất
21 ngày trước (21 Thg 04 2026)
Thể loại có liên quan
  • Thẻ
Giấy phép
Giấy phép MIT
Lịch sử các phiên bản
  • Xem tất cả phiên bản
Thêm vào bộ sưu tập
Báo cáo tiện ích này
Đi đến trang chủ Mozilla

Tiện ích

  • Giới thiệu
  • Blog tiện ích Firefox
  • Extension Workshop
  • Trung tâm nhà phát triển
  • Chính sách nhà phát triển
  • Blog cộng đồng
  • Diễn đàn
  • Báo cáo một lỗi
  • Hướng dẫn đánh giá

Trình duyệt

  • Desktop
  • Mobile
  • Enterprise

Sản phẩm

  • Browsers
  • VPN
  • Relay
  • Monitor
  • Pocket
  • Bluesky (@firefox.com)
  • Instagram (Firefox)
  • YouTube (firefoxchannel)
  • Riêng tư
  • Cookie
  • Pháp lý

Trừ trường hợp khác đã ghi chú, nội dung trên trang này được cấp phép theo giấy phép Creative Commons Attribution Share-Alike v3.0 hoặc bất kỳ phiên bản nào sau này.