OpenAI Chat AutoFiller

Automatically fill in chat messages on OpenAI Chat using a predefined text when checkbox is checked and user completes a message补充说明:panel在窗口右上角,勾选checkbox后,触发模式为, 输入框最后三个字符为“///”

目前為 2023-04-01 提交的版本,檢視 最新版本

// ==UserScript==
// @name         OpenAI Chat AutoFiller
// @namespace    openai-chat-autofiller
// @version      2.1
// @description  Automatically fill in chat messages on OpenAI Chat using a predefined text when checkbox is checked and user completes a message补充说明:panel在窗口右上角,勾选checkbox后,触发模式为, 输入框最后三个字符为“///”
// @author       ChatGPT & philos
// @match        https://chat.openai.com/*
// @grant        none
// ==/UserScript==

(function() {
  // create checkbox and fillText elements
  const checkbox = document.createElement('input');
  checkbox.type = 'checkbox';
  checkbox.id = 'autofill-checkbox';
  const fillText = document.createElement('input');
  fillText.type = 'text';
  fillText.id = 'autofill-text';
  fillText.value = '每段话的开头请加上“【见字如晤】”回答我';
  fillText.style.display = 'none'; // hide the fillText element by default

  // create control panel and append elements
  const controlPanel = document.createElement('div');
  controlPanel.style.position = 'fixed';
  controlPanel.style.top = '0';
  controlPanel.style.right = '0';
  controlPanel.style.padding = '10px';
  controlPanel.style.backgroundColor = '#fff';
  controlPanel.style.border = '1px solid #ccc';
  controlPanel.appendChild(checkbox);
  controlPanel.appendChild(fillText);

  // add control panel to the document
  document.body.appendChild(controlPanel);

  // add event listener to checkbox
  checkbox.addEventListener('change', () => {
    if (checkbox.checked) {
      // show the fillText element when checkbox is checked
      fillText.style.display = 'inline-block';
      // add event listener to chat input element
      document.querySelector('textarea').addEventListener('input', autofillText);
    } else {
      // hide the fillText element when checkbox is unchecked
      fillText.style.display = 'none';
      // remove event listener from chat input element
      document.querySelector('textarea').removeEventListener('input', autofillText);
    }
  });

  // define autofillText function to be called when checkbox is checked and user completes a message
  const autofillText = () => {
    const chatInput = document.querySelector('textarea');
    const lastChars = chatInput.value.slice(-3);
    if (lastChars === '///') {
      chatInput.value += '\n' + fillText.value + '\n';
    }
  };
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址