谷歌搜索+百度(极简)

google with baidu

目前为 2021-05-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         谷歌搜索+百度(极简)
// @version      1.0.1
// @description  google with baidu
// @author       Janet
// @grant        GM_openInTab
// @grant       GM_addStyle
// @grant       GM_getResourceText
// @resource    customCSS https://lib.baomitu.com/bttn.css/0.2.4/bttn.css
// @include      https://www.google.com*


// @namespace https://greasyfork.org/users/249577
// ==/UserScript==
(function() {
  'use strict';
  var newCSS = GM_getResourceText ("customCSS");
  GM_addStyle (newCSS);
  GM_addStyle (`
     #mybtn{
         line-height:10px;
     }
   `)

  function searchByBaidu(search_content) {
    return 'https://www.baidu.com/s?wd=' + search_content;
  }
  function baiduClick() {
    var search_content = document.querySelector('input.gLFyf').value;
    GM_openInTab( searchByBaidu(search_content), false);
  }
  let box = document.querySelector(".RNNXgb")
  let mybtn = document.createElement("button")
  mybtn.innerHTML="百度"
  mybtn.setAttribute("type", "reset")
  mybtn.setAttribute("id", "mybtn")
  mybtn.setAttribute("class", "bttn-pill bttn-md bttn-primary")
  box.appendChild(mybtn)

  mybtn.addEventListener("click",(e)=>{
    e.preventDefault()
    baiduClick()
  })

})();