您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Listens for postMessage events on chat.deepseek.com and logs them
当前为
- // ==UserScript==
- // @name DeepSeek Native Setter Injector
- // @description Listens for postMessage events on chat.deepseek.com and logs them
- // @match https://chat.deepseek.com/*
- // @version 0.0.1.20250515163325
- // @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 => {
- // find all primary filled buttons
- const buttons = document.querySelectorAll(
- 'div[role="button"].ds-button--primary.ds-button--filled'
- );
- if (event.data && event.data.type === 'searchButtonClicked') {
- // click the one whose visible label is “Search”
- for (const btn of buttons) {
- if (btn.textContent.trim() === 'Search') {
- btn.click();
- break;
- }
- }
- return;
- }
- if (event.data && event.data.type === 'reasonButtonClicked') {
- // click the one whose visible label is “DeepThink (R1)”
- for (const btn of buttons) {
- if (btn.textContent.trim() === 'DeepThink (R1)') {
- btn.click();
- break;
- }
- }
- return;
- }
- if (event.data?.type === 'newChatButtonClicked') {
- document.querySelector('svg path[d^="M9.10999"]').closest('div').click();
- return;
- }
- // Only respond to string messages
- if (typeof event.data !== 'string') return;
- const textarea = document.getElementById('chat-input');
- if (!textarea) return;
- // 1. Update both DOM and React state without shifting focus
- valueSetter.call(textarea, event.data);
- // 2. Notify React/Vue/etc. of the change
- textarea.dispatchEvent(new InputEvent('input', { bubbles: true }));
- // 3. Click the send button if enabled
- const sendBtn = document.querySelector('div[role="button"][aria-disabled="false"]');
- if (sendBtn) sendBtn.click();
- });
- })();