OpenAI Playground (ChatGPT) - Continue Button

press the [Continue] button instead of 'Add message > continue > Ctrl+Enter', configure panel optionally saves 'Temperature', 'Maximum Length' and 'Instructions'

目前為 2023-06-26 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name OpenAI Playground (ChatGPT) - Continue Button
  3. // @namespace https://greasyfork.org/en/users/10118-drhouse
  4. // @version 2.1
  5. // @description press the [Continue] button instead of 'Add message > continue > Ctrl+Enter', configure panel optionally saves 'Temperature', 'Maximum Length' and 'Instructions'
  6. // @include https://platform.openai.com/playground?mode*
  7. // @match https://platform.openai.com/playground?mode*
  8. // @require http://code.jquery.com/jquery-3.4.1.min.js
  9. // @require https://greasyfork.org/scripts/439099-monkeyconfig-modern-reloaded/code/MonkeyConfig%20Modern%20Reloaded.js?version=1012538
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
  11. // @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_deleteValue
  15. // @grant GM_addStyle
  16. // @grant GM_registerMenuCommand
  17. // @author drhouse
  18. // @license CC-BY-NC-SA-4.0
  19. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  20. // ==/UserScript==
  21. /* global jQuery, $ */
  22. this.$ = this.jQuery = jQuery.noConflict(true);
  23. (function($){
  24.  
  25. setTimeout(function(){
  26. var cfg = new MonkeyConfig({
  27. title: 'Configure',
  28. menuCommand: true,
  29. params: {
  30. 'Automatic Temperature': {
  31. type: 'checkbox',
  32. default: true
  33. },
  34. 'Temperature': {
  35. type: 'number',
  36. default: '1'
  37. },
  38. 'Automatic Maximum Length': {
  39. type: 'checkbox',
  40. default: true
  41. },
  42. 'Maximum Length': {
  43. type: 'number',
  44. default: '2048'
  45. },
  46. 'Automatic Instructions': {
  47. type: 'checkbox',
  48. default: true
  49. },
  50. chatGPT_instructions: {
  51. type: 'text',
  52. default: ''
  53. },
  54.  
  55. },
  56. // onSave: setOptions
  57. })
  58.  
  59. var path = "#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-footer > span > button.btn.btn-sm.btn-minimal.btn-neutral"
  60. $('<button id="continue" tabindex="0" class="btn btn-sm btn-filled btn-primary" type="button" data-testid="pg-submit-btn" aria-haspopup="true" aria-expanded="false"><span class="btn-label-wrap"><span class="btn-label-inner">Continue&zwj;</span></span></button>').insertAfter(path)
  61.  
  62. var e = jQuery.Event("keypress");
  63. e.which = 9;
  64. e.keyCode = 9;
  65.  
  66. if (cfg.get('Automatic Temperature')) {
  67. $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-right > div.pg-right-content > div > div > div:nth-child(3) > div > div.css-1povu0j > input").val(Number(cfg.get('Temperature')))
  68. $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-right > div.pg-right-content > div > div > div:nth-child(3) > div > div.css-1povu0j > input").focus().trigger(e);
  69. }
  70. if (cfg.get('Automatic Maximum Length')) {
  71. $("body > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > input:nth-child(2)").val(Number(cfg.get('Maximum Length')))
  72. $("body > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > input:nth-child(2)").focus().trigger(e);
  73. }
  74.  
  75. // chat-pg-instructions
  76. $('#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div:nth-child(1) > div > div.text-input-header-wrapper.overflow-wrapper.text-input > textarea').focus()
  77.  
  78. if (cfg.get('Automatic Instructions')) {
  79. $('#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div:nth-child(1) > div > div.text-input-header-wrapper.overflow-wrapper.text-input > textarea').text(cfg.get('chatGPT_instructions'))
  80. }
  81.  
  82. $("button[id='continue']").click(function(){
  83. $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-panel-wrapper > div > div > div.chat-pg-message.add-message")[0].click()
  84. setTimeout(function(){
  85. $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-panel-wrapper > div > div > div:nth-child(3) > div.text-input-with-focus > textarea").text('continue')
  86. }, 500);
  87. setTimeout(function(){
  88. $("#root > div.route-container > div > div.pg-root.page-body.full-width.flush > div > div.pg-body > div.pg-editor > div > div > div.chat-pg-right-wrapper > div.chat-pg-footer > span > button:nth-child(1)")[0].click()
  89. }, 1000);
  90. });
  91.  
  92.  
  93. }, 1000);
  94. })(jQuery);