Press "d" to DuckDuckGo from Kagi

Press "d" to DuckDuckGo from Kagi.

目前為 2023-10-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Press "d" to DuckDuckGo from Kagi
// @namespace   https://github.com/gslin/press-d-to-duckduckgo-from-kagi
// @match       https://kagi.com/search*
// @grant       GM_addStyle
// @grant       GM_getValue
// @grant       GM_registerMenuCommand
// @grant       GM_setValue
// @version     0.20231006.0
// @author      Gea-Suan Lin <[email protected]>
// @description Press "d" to DuckDuckGo from Kagi.
// @require     https://gf.qytechs.cn/scripts/38445-monkeyconfig/code/MonkeyConfig.js?version=251319
// @license     MIT
// ==/UserScript==

(() => {
    'use strict';

    const cfg = new MonkeyConfig({
        menuCommand: true,
        params: {
            search_engine: {
                type: 'text',
                default: 'https://www.duckduckgo.com/?q=',
            },
        },
        title: 'Press "d" to DuckDuckGo in Kagi',
    });

    window.addEventListener('keyup', function(event) {
        if (['input', 'textarea'].indexOf(document.activeElement.tagName.toLowerCase()) >= 0) {
            return;
        }
        if ('d' !== event.key) {
            return;
        }

        let q = document.getElementById('searchBar').value;
        let q_encoded = encodeURIComponent(q).replace(/%20/g, '+');
        let url = cfg.get('search_engine') + q_encoded;

        document.location = url;
    });
})();

QingJ © 2025

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