DeepSeek Native Setter Injector

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

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        DeepSeek Native Setter Injector
// @description  Listens for postMessage events on chat.deepseek.com and logs them
// @match       https://chat.deepseek.com/*
// @grant       none
// @version 0.0.1.20250511171540
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';

    // Cache the native setter for HTMLTextAreaElement.value
    const valueSetter = Object.getOwnPropertyDescriptor(
        HTMLTextAreaElement.prototype, 'value'
    ).set;

    window.addEventListener('message', event => {
        // 1. Read the incoming message
        const message = event.data;

        // 2. Find DeepSeek’s chat textarea
        const ta = document.getElementById('chat-input');
        if (!ta) return;

        // 3. Focus so the app knows it’s active
        ta.focus();

        // 4. Use the native setter to update both DOM and React state
        valueSetter.call(ta, message);

        // 5. Dispatch a proper InputEvent for React/Vue/etc.
        ta.dispatchEvent(new InputEvent('input', { bubbles: true }));
    });
})();