百度页面带谷歌搜索

百度搜索加上谷歌按钮

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         百度页面带谷歌搜索
// @namespace    https://github.com/kana112233/Tampermonkey-user-js
// @version      1.0.2
// @description  百度搜索加上谷歌按钮
// @author       makey
// @grant        GM_openInTab
// @include      https://www.baidu.com/*
// @require      https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
// ==/UserScript==
(function() {
   'use strict';

   function getGoogleUrl(searchText) {
       return 'https://www.google.com/search?q=' + searchText;
   }
   function googleIt() {
       var searchText = document.querySelector('#kw').value;
       GM_openInTab( getGoogleUrl(searchText), false);
   }
   $('#su').after('<input type="button" id="google" value="Google一下" class="btn self-btn bg s_btn" style="background-color:black;" />');

   $("#google").click(function() {
       googleIt();
   });

   setInterval(function(){
       if($("#google").val() !== "Google一下"){
           $("#google").val("Google一下");
       }
   }, 50);

})();