Redirect To Google

Fuck default baidu.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Redirect To Google
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Fuck default baidu.
// @author       Hnayan
// @match        *://www.baidu.com/s?wd=*
// ==/UserScript==

(function() {
    'use strict';
    //Just use '=' to split it,because all '=' in query's inside will convert to '%D3',as same as blank will convert.
    //So don't think about 'wd=bla=blah=bl3' and 'hello world'.
    const query = window.location.search.split('=')[1];
    const googleSite = `https://www.google.com.hk/search?q=${query}`;
    //I don't want to see baidu's page
    const mask = document.createElement("div");
    mask.id = 'maskk';
    mask.style = 'position:absolute;width:100%;height:100%;z-index:9999;left:0;top:0;background-color:gray;opacity:0.95;';
    document.body.appendChild(mask);
    //open in current tab
    const virtualButton=document.createElement("a");
    virtualButton.setAttribute('href', googleSite);
    virtualButton.click();
})();