🏠 Home 

遗弃百度,拥抱谷歌

使用百度时自动携带搜索参数跳转去谷歌


Install this script?
// ==UserScript==
// @name         遗弃百度,拥抱谷歌
// @namespace    gogogoghost
// @version      0.4
// @description  使用百度时自动携带搜索参数跳转去谷歌
// @author       $(ghost)
// @license     MIT
// @match        https://www.baidu.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==
(function() {
'use strict';
if(window.leaveBaidu){
return;
}
window.leaveBaidu=true;
const srcKey='wd=';
const destUrl='https://www.google.com/search?q=';
let search=window.location.search;
let indexStart=search.indexOf(srcKey);
if(indexStart>0){
indexStart+=srcKey.length-1;
let indexEnd=search.indexOf('&',indexStart);
if(indexEnd<0){
indexEnd=search.length;
}
let keyword=search.substring(indexStart+1,indexEnd);
window.location.href=destUrl+keyword;
}
})();