DeepSeek Native Setter Injector

Listens for postMessage events on chat.deepseek.com and logs them

当前为 2025-05-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DeepSeek Native Setter Injector
  3. // @description Listens for postMessage events on chat.deepseek.com and logs them
  4. // @match https://chat.deepseek.com/*
  5. // @version 0.0.1.20250511172250
  6. // @namespace https://greasyfork.org/users/1435046
  7. // ==/UserScript==
  8.  
  9. (function() {
  10. 'use strict';
  11.  
  12. // Cache the native setter for HTMLTextAreaElement.value
  13. const valueSetter = Object.getOwnPropertyDescriptor(
  14. HTMLTextAreaElement.prototype, 'value'
  15. ).set;
  16.  
  17. window.addEventListener('message', event => {
  18. const message = event.data;
  19. const ta = document.getElementById('chat-input');
  20. if (!ta) return;
  21.  
  22. // 1. Update both DOM and React state without shifting focus
  23. valueSetter.call(ta, message);
  24.  
  25. // 2. Notify React/Vue/etc. of the change
  26. ta.dispatchEvent(new InputEvent('input', { bubbles: true }));
  27.  
  28. // 3. Click the send button if enabled
  29. const sendBtn = document.querySelector('div[role="button"][aria-disabled="false"]');
  30. if (sendBtn) sendBtn.click();
  31. });
  32. })();