您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
强制所有顽固跳转的链接都在当前标签页打开
当前为
// ==UserScript== // @name 禁止打开新标签 // @description 强制所有顽固跳转的链接都在当前标签页打开 // @version 1.5 // @author WJ // @match *://*/* // @license MIT // @grant none // @namespace https://greasyfork.org/users/914996 // ==/UserScript== (function() { 'use strict'; // 修正 base 设置 (document.querySelector('base') || document.head.appendChild(document.createElement('base'))).target = '_self'; // 处理所有 <a> const set = n => n.tagName === 'A' && (n.target = '_self'); const walk = r => r.querySelectorAll?.('a')?.forEach(set); walk(document); new MutationObserver(rs => rs.forEach(r => r.addedNodes.forEach(n => { set(n); walk(n); }))).observe(document, { childList: true, subtree: true }); // 拦截 window.open window.open = (u, _, __) => (u && (location.href = u), window); })();