您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
让所有网页链接都在新标签页中打开,提升浏览效率。
- // ==UserScript==
- // @name Force Link Open in New
- // @name:zh-CN 强制新标签页打开链接
- // @namespace http://tampermonkey.net/
- // @version 0.3
- // @description Opens all web links in new tabs, enhancing browsing efficiency and preventing loss of work progress.
- // @description:zh-CN 让所有网页链接都在新标签页中打开,提升浏览效率。
- // @author Yearly
- // @license AGPL-v3.0
- // @match *://*/*
- // @exclude *://*.greasyfork.org/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Capture all click events and open links in a new tab
- document.addEventListener('click', function(event) {
- let anchor = event.target.closest('a');
- if (anchor && anchor.href) {
- event.preventDefault();
- window.open(anchor.href, '_blank');
- }
- }, true);
- // Override window.open method to open URLs in a new tab
- const originalOpen = window.open;
- window.open = function(url, target = '_blank', features) {
- if (['_self', '_parent', '_top'].includes(target)) {
- target = '_blank';
- }
- return originalOpen.call(window, url, target, features);
- };
- })();