百度搜索添加google按钮

百度搜索快速切换到google搜索

当前为 2020-11-21 提交的版本,查看 最新版本

// ==UserScript==
// @name        baidu2google
// @name:zh-CN  百度搜索添加google按钮
// @description add a button to google from baidu
// @description:zh-CN   百度搜索快速切换到google搜索
// @namespace   https://github.com/beijiyouyu/Greasyforks
// @author      北极有鱼
// @include     *://www.baidu.com/*
// @run-at document-end
// @version     1.0.0
// ==/UserScript==


// 判断当前搜索引擎地址
var engine = window.location.host
if (engine==="www.baidu.com") {
    // 如果是百度搜索
    console.log("baidu2google is running...")
    var content = '  <div class="engine" id="google">\n' +
        '    <a href="javascript:void(0);" onclick="window.location.href=\'https://www.google.com/search?q=\' + document.getElementById(\'kw\').value" >换google</a>\n' +
        '  </div>'
    var dom = document.getElementById('form')
    var another = document.createElement('div')
    another.innerHTML = content
    dom.appendChild(another)
    // 追加样式
    var style = '#google{position:absolute;right:-145px;width:90px;text-align:center;line-height:40px;top:50%;transform:translate(-50%,-50%);border-radius:13px;font-size:13px;background:#fbbc05;}#google:hover{background:#d2a00e;}#google a{color:white;text-decoration:none;display:inline-block;width: 100%;}'
    var st = document.createElement('style')
    st.innerHTML = style
    dom.appendChild(st)
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址