Greasy Fork

Greasy Fork is available in English.

ChatGLM 插嘴功能

Clicks the stop button when Enter is pressed in the first textarea on chatglm.cn

目前为 2024-01-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         ChatGLM 插嘴功能
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Clicks the stop button when Enter is pressed in the first textarea on chatglm.cn
// @author       You
// @match        https://chatglm.cn/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 等待页面加载完成
    window.addEventListener('load', function() {
        // 获取页面中的第一个<textarea>元素
        var textarea = document.querySelector('textarea');

        // 如果找到了<textarea>元素,则为其添加键盘事件监听器
        if (textarea) {
            textarea.addEventListener('keydown', function(event) {
                // 检查是否是单个Enter键按下
                if (event.key === 'Enter' && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) {
                    // 查找类名为"btn stop"的按钮
                    var stopButton = document.querySelector('.btn.stop');

                    // 如果找到了按钮,则触发click事件
                    if (stopButton) {
                        stopButton.click();
                    }
                }
            });
        }
    }, false);
})();