您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
a标签添加target=_blank属性
// ==UserScript== // @name 链接新标签页打开 // @namespace https://bestlzk.cn/ // @version 1.0 // @description a标签添加target=_blank属性 // @author bestlzk // @license MIT // @match *://*/* // @grant none // @run-at document-end // ==/UserScript== function updateLinks(selector) { document.querySelectorAll(selector).forEach(link => { if (!link.target) link.target = '_blank'; }); } // document.querySelectorAll('').forEach(link => {console.log(link.href)}) const linkUpdateConfig = { 'news.ycombinator.com': [ 'td.title > span > a' ] }; (function() { const hostname = location.hostname; const selectors = linkUpdateConfig[hostname]; if (!Array.isArray(selectors)) return; selectors.forEach(updateLinks); const observer = new MutationObserver(() => { selectors.forEach(updateLinks); }); observer.observe(document.body, { childList: true, subtree: true }); })();