Baidu2Google

change search engine from baidu to google

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Baidu2Google
// @name:zh-CN  百度搜索切换到Google
// @description change search engine from baidu to google
// @description:zh-CN   百度搜索携带搜索词快速切换到google搜索
// @namespace   https://github.com/beijiyouyu/Browser
// @license     MIT
// @author      北极有鱼
// @include     *://www.baidu.com/*
// @run-at document-end
// @version     2.0.0
// ==/UserScript==

(function() {
    'use strict';
    let domain = window.location.host

    if (domain !== 'www.baidu.com') {
        return
    }
    console.log('Baidu2Google is running...')  // 控制台输出运行状态

    let insert = `
        <div class="engine" id="google">
          <a href="javascript:void(0);" onclick="window.location.href = 'https://www.google.com/search?q=' + document.getElementById('kw').value">换google</a>
        </div>
    `

    // 先生成div
    let insertDom = document.createElement('div')  // 生成待插入的元素
    let documentDom = document.getElementById('form')  // 获取需要插入的位置
    insertDom.innerHTML = insert  // 元素赋值
    documentDom.appendChild(insertDom)
    // 再添加样式
    let style = `
        #google {
            position:absolute;
            right:-136px;
            width:85px;
            text-align:center;
            line-height:40px;
            top:50%;
            transform:translate(-50%,-50%);
            border-radius:24px;
            font-size:14px;
            background:#fbbc05;
        }
        #google:hover {
            background:#d2a00e;
        }
        #google a {
            color:white;
            text-decoration:none;
            display:inline-block;
            width: 100%;
        }
    `

    let styleDom = document.createElement('style')
    styleDom.innerHTML = style
    documentDom.appendChild(styleDom)
// 打完收功
})();