Greasy Fork is available in English.
谷歌、百度、搜狗、必应、F搜、头条、无追搜索、360、DuckDuckGo、Ecosia 搜索结果新标签打开
当前为
// ==UserScript==
// @name 搜索引擎新标签打开链接
// @description 谷歌、百度、搜狗、必应、F搜、头条、无追搜索、360、DuckDuckGo、Ecosia 搜索结果新标签打开
// @version 2.5
// @author ChatGPT
// @match *://www.wuzhuiso.com/*
// @match *://www.so.com/*
// @match *://m.so.com/*
// @match *://so.toutiao.com/*
// @match *://www.ecosia.org/*
// @match *://fsoufsou.com/*
// @match *://duckduckgo.com/*
// @match *://yandex.com/*
// @match *://www.google.co.jp/*
// @match *://www.google.com.hk/*
// @match *://www.google.com/*
// @match *://m.baidu.com/*
// @match *://www.baidu.com/*
// @match *://wap.sogou.com/*
// @match *://m.sogou.com/*
// @match *://www.sogou.com/*
// @match *://cn.bing.com/*
// @match *://www.bing.com/*
// @run-at document-end
// @grant none
// @namespace http://greasyfork.icu/users/452911
// ==/UserScript==
(function() {
'use strict';
if (window.location.href.search(/search|q=|wd=|word=/) !== -1) {
function modifyLinks() {
let links = document.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
if (links[i].classList.contains('sb_halfnext') || links[i].classList.value.startsWith('container') || links[i].classList.contains('control')) {
links[i].setAttribute('target', '_self');
} else {
links[i].setAttribute('target', '_blank');
}
}
let base = document.getElementsByTagName('base')[0];
if (base) {
base.setAttribute('target', '_blank');
} else {
let head = document.getElementsByTagName('head')[0];
let newBase = document.createElement('base');
newBase.setAttribute('target', '_blank');
head.appendChild(newBase);
}
}
modifyLinks();
let throttleTimer;
const throttle = () => {
if(throttleTimer) return;
throttleTimer = setTimeout(() => {
modifyLinks();
throttleTimer = null;
}, 800);
}
window.addEventListener('scroll', throttle);
}
})();