Replace Poe Prompt Input with Monaco Editor

1.Replace Poe chat box with Monaco Editor; 2.Allow adjusting input box height;3.Change Enter Event to Ctrl+Enter.

Skaber
mercutiojohn
Daglige installationer
0
Installationer i alt
280
Bedømmelser
0 0 0
Version
0.2.1
Oprettet
05.05.2023
Opdateret
05.05.2023
Size
5,15 kB
Licens
MIT
Gælder for

en

This UserScript replaces the chat box in Poe website with Monaco Editor and provides the following features:

  1. Allow adjusting the input box height by dragging a slider.
  2. Change the Enter event to Ctrl+Enter for sending messages more conveniently.

Specifically, the script will:

  • Load the scripts and modules of Monaco Editor.
  • Find the textarea element in the chat box and hide it.
  • Create a slider as a tool for adjusting the input box height and add it before the input box.
  • Create a div element as an editor container and add it before the textarea. Then, instantiate the editor.
  • Synchronize the value of textarea with that of the editor when the editor content changes.
  • Add a Ctrl+Enter shortcut for sending messages.
  • Monitor the changes of the input box and editor container sizes, and adjust the editor container size dynamically.
  • Add an event listener for the slider and adjust the input box height dynamically when the slider value changes.

zh

主要功能:

  • 将 Poe 网站的聊天框替换为 Monaco Editor

并提供以下功能:

  • 可以通过拖动滑动条调整输入框的高度;
  • 将 Enter 事件改为 Ctrl+Enter,以便更方便地发送消息。

具体来说,该脚本会:

  • 加载 Monaco Editor 的脚本和模块;
  • 查找聊天框中的 textarea 元素,并将其隐藏;
  • 创建一个拖动条作为输入框的高度调整工具,并将其添加到输入框前面;
  • 创建一个 div 元素作为编辑器容器,将其添加到 textarea 前面,并将编辑器实例化;
  • 当编辑器内容发生变化时,同步更新 textarea 中的值;
  • 添加一个 Ctrl+Enter 的快捷键,以便更方便地发送消息;
  • 监听输入框和编辑器容器大小的变化,并调整编辑器容器的大小以适应新的大小;
  • 监听拖动条的变化,并在拖动条值发生变化时动态调整输入框的高度。