// ==UserScript== // @name Google 搜索结果在新标签页打开 // @namespace https://github.com/Black-Cyan // @icon https://www.google.com/images/branding/product/1x/googleg_32dp.png // @version 1.0.0 // @description 在新标签页中打开 Google 搜索结果 // @match https://www.google.com/search* // @match https://www.google.com.hk/search* // @match https://www.google.co.jp/search* // @match https://www.google.co.uk/search* // @grant none // @run-at document-end // @license MIT // ==/UserScript== (function () { 'use strict'; function setTargetBlank() { const links = document.querySelectorAll( 'div#search a:has(h3)' ); links.forEach(link => { link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); }); } // 初始化 setTargetBlank(); // 监听动态加载的搜索结果 const observer = new MutationObserver(setTargetBlank); observer.observe(document.body, { childList: true, subtree: true }); })();