OpenAI Playground (ChatGPT) - Continue Button

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

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