您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
强制所有顽固跳转的链接都在当前标签页打开
当前为
// ==UserScript== // @name 禁止打开新标签 // @description 强制所有顽固跳转的链接都在当前标签页打开 // @version 1.4 // @author WJ // @match *://*/* // @license MIT // @grant none // @namespace https://greasyfork.org/users/914996 // ==/UserScript== (function() { 'use strict'; document.addEventListener('click', function(e) { const a = e.target.closest('a'); if (a?.href && !a.href.startsWith('javascript:')) { e.preventDefault(); location.href = a.href; } }, true); // 动态内容支持 new MutationObserver(function() { document.querySelectorAll('a').forEach(function(a) { a.target = '_self'; }); }).observe(document, { childList: true, subtree: true }); // 拦截window.open window.open = function(url) { return url ? (location.href = url, window) : window; }; })();