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. // @grant none
  6. // @version 0.0.1.20250511171540
  7. // @namespace https://greasyfork.org/users/1435046
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. // Cache the native setter for HTMLTextAreaElement.value
  14. const valueSetter = Object.getOwnPropertyDescriptor(
  15. HTMLTextAreaElement.prototype, 'value'
  16. ).set;
  17.  
  18. window.addEventListener('message', event => {
  19. // 1. Read the incoming message
  20. const message = event.data;
  21.  
  22. // 2. Find DeepSeek’s chat textarea
  23. const ta = document.getElementById('chat-input');
  24. if (!ta) return;
  25.  
  26. // 3. Focus so the app knows it’s active
  27. ta.focus();
  28.  
  29. // 4. Use the native setter to update both DOM and React state
  30. valueSetter.call(ta, message);
  31.  
  32. // 5. Dispatch a proper InputEvent for React/Vue/etc.
  33. ta.dispatchEvent(new InputEvent('input', { bubbles: true }));
  34. });
  35. })();