【油猴脚本】谷歌链接点击跳转新一页

因为谷歌搜索每次链接点击后总是在当前页面加载,让我很难受,所以随便弄了个油猴脚本

// ==UserScript==
// @name         Google Search Open in New Tab
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Make Google Search results open in new tabs by default when clicked with the left mouse button.
// @author       马克思
// @include        *://*google.*/*
// @grant        none
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// ==/UserScript==

(function() {
    'use strict';
    document.querySelectorAll('a').forEach(function(link) {
        if (link.href && link.closest('#search')) {
            link.setAttribute('target', '_blank'); // Open in new tab
            link.addEventListener('click', function(e) {
                // Prevent the default action of opening in the same tab
                e.preventDefault();
                window.open(link.href, '_blank');
            });
        }
    });
})();

4 个赞

搜索设置 (google.com)
看这

5 个赞

这个其实是可以设置的

1 个赞

之前没看到在哪设置

1 个赞

很实用 :grinning:

1 个赞

居然藏得这么深,又学到了

1 个赞

病友软件开发

按住Ctrl键点击也一样的噢

1 个赞

滚轮点击亦可

3 个赞

我擦,我一直鼠标中键点击。。。

1 个赞