ChatGPT Enhanced Interface

Enhances ChatGPT interface with various features.

  1. // ==UserScript==
  2. // @name ChatGPT Enhanced Interface
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2.1
  5. // @description Enhances ChatGPT interface with various features.
  6. // @author lundeen-bryan
  7. // @match https://chat.openai.com/*
  8. // @grant none
  9. // @license GPL
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Function to handle key presses
  17. function handleKeyPress(event) {
  18. const inputBox = document.querySelector('textarea');
  19. if (event.key === 'Enter' && !event.metaKey && inputBox) {
  20. event.stopPropagation();
  21. }
  22. if (event.key === 'Enter' && event.ctrlKey) { // Check if Ctrl+Enter are pressed together
  23. document.querySelector('[data-testid="send-button"]').click(); // Simulate click on the send button
  24. }
  25. }
  26.  
  27.  
  28. // Add or remove the key press event listener
  29. function overrideEnterKey() {
  30. const inputBox = document.querySelector('textarea');
  31. if (inputBox) {
  32. inputBox.removeEventListener('keydown', handleKeyPress, true);
  33. inputBox.addEventListener('keydown', handleKeyPress, true);
  34. }
  35. }
  36.  
  37. // Observe for changes to reapply the key press event listener
  38. const observerForKeyPress = new MutationObserver(overrideEnterKey);
  39. observerForKeyPress.observe(document, { childList: true, subtree: true });
  40.  
  41. // Custom styles
  42. const customStyle = document.createElement('style');
  43. customStyle.textContent = `
  44. /* Style for focused button */
  45. .focused-gizmo {
  46. background-color: #19c37d !important; /* New button color */
  47. }
  48. .focused-gizmo svg {
  49. color: white !important; /* New arrow color */
  50. }
  51.  
  52. /* Specific style for the send button */
  53. [data-testid="send-button"] {
  54. max-height: 200px;
  55. height: 30px;
  56. overflow-y: hidden;
  57. min-height: 30px;
  58. padding-right: 5px;
  59. padding-left: 5px;
  60. }
  61. /* Style for the textarea with ID 'prompt-textarea' */
  62. #prompt-textarea {
  63. padding-left: 45px;
  64. padding-right: 60px;
  65. padding-bottom: 10px;
  66. padding-top: 10px;
  67. font-size: 1.1em;
  68. }
  69. /* Style for elements with the class .md\\:right-3 */
  70. .md\\:right-3 {
  71. right: 2.75rem;
  72. }
  73. /* Style for elements with the class.md\\:left-3 */
  74. p {
  75. font-size: 1.4em;
  76. width: 100%;
  77. }
  78. .w-full {
  79. /* wide scrollbar */
  80. width: 99%;
  81. }
  82. /* Move text area far to the left to give more room to write */
  83. .xl\:max-w-3xl {
  84. max-width: 59rem;
  85. margin-left: 30px;
  86. }
  87. /* Adjust padding values for the result counter */
  88. .text-token-text-tertiary {
  89. padding-left: 54px !important; /* Adjust left padding */
  90. padding-bottom: 4px !important; /* Adjust bottom padding */
  91. }
  92. `;
  93. document.head.appendChild(customStyle);
  94.  
  95.  
  96. // Function to toggle focus style
  97. function toggleFocusStyle(event) {
  98. const button = document.querySelector('[data-testid="send-button"]');
  99. if (button) {
  100. if (event.type === 'focus') {
  101. button.classList.add('focused-gizmo');
  102. } else if (event.type === 'blur') {
  103. button.classList.remove('focused-gizmo');
  104. }
  105. }
  106. }
  107.  
  108. // Add focus and blur event listeners to the button
  109. function addButtonFocusListener() {
  110. const button = document.querySelector('[data-testid="send-button"]');
  111. if (button) {
  112. button.addEventListener('focus', toggleFocusStyle);
  113. button.addEventListener('blur', toggleFocusStyle);
  114. }
  115. }
  116.  
  117. // Observe for button to add focus and blur listeners
  118. const observerForButtonFocus = new MutationObserver(addButtonFocusListener);
  119. observerForButtonFocus.observe(document.body, { childList: true, subtree: true });
  120.  
  121. // Keyboard shortcut functionality
  122. document.addEventListener('keydown', function(event) {
  123. if (event.altKey && event.key === 'k') {
  124. const targetButton = document.getElementById('expand-sidebar-bottom-button');
  125. if (targetButton) {
  126. targetButton.click();
  127. }
  128. }
  129. });
  130. })();

QingJ © 2025

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