Greasy Fork is available in English.

搜索引擎快捷键跳转

通过 Ctrl、Shift 和 S 键组合按键在google和baidu之间互相跳转

// ==UserScript==
// @name         搜索引擎快捷键跳转
// @namespace    https://greasyfork.org/zh-CN/users/298906-jonolo
// @version      1.0
// @description  通过 Ctrl、Shift 和 S 键组合按键在google和baidu之间互相跳转
// @author       Jonolo
// @run-at       document-start
// @include      http*://*baidu.com/s*
// @include      http*://*baidu.com/baidu*
// @include      *://www.google.com/search?*
// @include      *://www.google.com.*/search?*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';


    document.addEventListener('keydown', (event) => {
        // 判断是否同时按下了 Ctrl、Shift 和 S 键
        if (event.ctrlKey && event.shiftKey && event.key === 'S') {
            // 阻止默认行为
            event.preventDefault();

            // 触发你的函数
            var hostname = window.location.hostname;
            if(hostname.match(RegExp(/google.com.*/))){
                google();
            }
            if(hostname.match(RegExp(/baidu.com/))){
                baidu();
            }


            yourFunction();
        }
    });


    function google(){
        var sVal = document.querySelector("input[name='q']").value
        var url_baidu_new = "https://www.baidu.com/s?wd=" + encodeURIComponent(sVal);
        window.location.href = url_baidu_new;
    }

    function baidu(){
        let sVal = document.getElementById('kw').value;
        let url_baidu_new = 'https://www.google.com/search?&ie=UTF-8&q=' + sVal;
        window.location.href = url_baidu_new;
    }
})();