您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
默认在新标签页中打开所有 GitHub 链接
// ==UserScript== // @name GitHub 在新标签页中打开链接 // @namespace http://example.com/your-namespace // @version 1.0 // @description 默认在新标签页中打开所有 GitHub 链接 // @author YuChujiu // @match https://github.com/* // @license MIT // @grant none // ==/UserScript== (function() { 'use strict'; // 定义一个函数,将所有链接设置为在新标签页中打开 function openLinksInNewTab() { document.querySelectorAll('a').forEach(function(link) { // 如果链接没有设置 target 属性,则设置 target="_blank" if (!link.hasAttribute('target')) { link.setAttribute('target', '_blank'); } }); } // 页面加载时立即执行该函数 openLinksInNewTab(); // 使用 MutationObserver 监听页面的变化(处理 GitHub 动态加载的内容) const observer = new MutationObserver(openLinksInNewTab); // 监控整个页面的变化,子节点和嵌套子节点的变化都会触发 observer.observe(document.body, { childList: true, subtree: true }); })();