Prevent sites from opening links in a new tab.
当前为
// ==UserScript== // @name _blank sanity preserver // @namespace https://jvdl.dev/ // @version 1 // @description Prevent sites from opening links in a new tab. // @author John van der Loo <[email protected]> // @match https://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; document.body.addEventListener("click", (e) => { const link = e.target.closest("a"); if (link && link.matches("a[target='_blank']")) { location.href=link.href; e.preventDefault(); } }) // Your code here... })();