Discord Kill Autofocus

Prevent chat auto focus on Discord desktop and mobile.

// ==UserScript==
// @name         Discord Kill Autofocus
// @description  Prevent chat auto focus on Discord desktop and mobile.
// @author C89sd
// @version      0.5
// @match        https://discord.com/*
// @namespace https://gf.qytechs.cn/users/1376767
// ==/UserScript==

(function() {
    'use strict';

    let clickInTextbox = false;
    document.addEventListener('mousedown', (event) => {
        if (event.target.closest('div[role="textbox"], textarea')) {
            clickInTextbox = true;
        }
    });
    document.addEventListener('mouseup', (event) => {
        setTimeout(() => {
          clickInTextbox = false;
        }, 100);
    });

    function detectAndRemoveFocus(event) {
        const target = event.target;
        if (!clickInTextbox && target && target.matches && target.matches('div[role="textbox"], textarea')) {
            target.blur();
        } else {
          clickInTextbox = false;
        }
    }
    document.addEventListener('focus', detectAndRemoveFocus, true);
})();

QingJ © 2025

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