Save & Submit keyboard shortcut for ChatGPT

Press Alt + Enter to auto-click the Save & Submit button for Superpower ChatGPT and OpenAI

  1. // ==UserScript==
  2. // @name Save & Submit keyboard shortcut for ChatGPT
  3. // @description Press Alt + Enter to auto-click the Save & Submit button for Superpower ChatGPT and OpenAI
  4. // @author NWP
  5. // @namespace https://gf.qytechs.cn/users/877912
  6. // @version 0.6
  7. // @license MIT
  8. // @match https://chat.openai.com/*
  9. // @match https://chatgpt.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. document.addEventListener('keydown', function(event) {
  16. // Check if Alt key is pressed along with Enter key
  17. if (event.altKey && event.keyCode == 13) {
  18. event.preventDefault();
  19. const save_submit_openAIButton = document.querySelector("div > button.btn.relative.btn-primary");
  20. const save_submit_superpowerChatGPTButton = document.querySelector("div > button.btn.flex.justify-center.gap-2.btn-primary");
  21. (save_submit_openAIButton || save_submit_superpowerChatGPTButton).click();
  22. event.stopPropagation();
  23. }
  24. }, true);
  25. })();
  26.  
  27.  
  28. /*
  29.  
  30. TODO: to make it easy to find for which operating mode the save_and_submit_button has become obsolete
  31. detect if Superpower ChatGPT is enabled for Chrome and Firefox.
  32.  
  33. This only works for Chrome within a userscript:
  34.  
  35. const extensionId = 'amhmeenmapldpjdedekalnfifgnpfnkc';
  36. const resourcePath = 'icons/info.png'; // This works
  37. //const resourcePath = 'manifest.json'; // This doesn't work due to restrictions
  38. const imgUrl = `chrome-extension://${extensionId}/${resourcePath}`;
  39.  
  40. fetch(imgUrl)
  41. .then(response => {
  42. if(response.ok) console.log('Extension installed:', true);
  43. else throw new Error('Resource not accessible');
  44. })
  45. .catch(error => console.log('Extension installed:', false));
  46.  
  47. Since Firefox doesn't have a similar method that I know of, it's better to
  48. check for an element that has been injected by Superpower ChatGPT (Auto Sync ON/ OFF)
  49. for both Chrome and Firefox.
  50.  
  51. */

QingJ © 2025

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