DDG Focus Fix

Keep focusing on the search bar when window focus changes

// ==UserScript==
// @name         DDG Focus Fix
// @namespace    http://tampermonkey.net/
// @license      MIT
// @version      0.1
// @description  Keep focusing on the search bar when window focus changes
// @author       mechtifs
// @match        https://duckduckgo.com/*
// @icon         https://duckduckgo.com/favicon.ico
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const originalAddEventListener = EventTarget.prototype.addEventListener;
    EventTarget.prototype.addEventListener = function(type, listener, options) {
        if (type == 'blur') {
            const newListener = function(event) {
                if (document.hasFocus()) {
                    return listener.apply(this, arguments);
                }
            };
            return originalAddEventListener.call(this, type, newListener, options);
        }
        return originalAddEventListener.call(this, type, listener, options);
    };
})();

QingJ © 2025

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