Greasy Fork 还支持 简体中文。

Prevent Autofocus on AllenAI, Mistral

Blocks programmatic focus on <textarea> and contenteditable elements

  1. // ==UserScript==
  2. // @name Prevent Autofocus on AllenAI, Mistral
  3. // @description Blocks programmatic focus on <textarea> and contenteditable elements
  4. // @match https://playground.allenai.org/*
  5. // @match https://chat.mistral.ai/*
  6. // @match https://www.kimi.com/*
  7. // @run-at document-start
  8. // @version 0.0.1.20250715101215
  9. // @namespace https://greasyfork.org/users/1435046
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Save original focus
  16. const originalFocus = HTMLElement.prototype.focus;
  17.  
  18. // Override focus globally
  19. Object.defineProperty(HTMLElement.prototype, 'focus', {
  20. configurable: true,
  21. enumerable: true,
  22. writable: true,
  23. value: function(...args) {
  24. // If it's a <textarea> or a contenteditable element, do nothing
  25. if (this.tagName === 'TEXTAREA' || this.isContentEditable) {
  26. return;
  27. }
  28. // Otherwise proceed as normal
  29. return originalFocus.apply(this, args);
  30. }
  31. });
  32. })();