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-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OpenAI Playground (ChatGPT) - Continue Button
  3. // @namespace https://greasyfork.org/en/users/10118-drhouse
  4. // @version 2.0
  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. // @require http://code.jquery.com/jquery-3.4.1.min.js
  8. // @require https://greasyfork.org/scripts/439099-monkeyconfig-modern-reloaded/code/MonkeyConfig%20Modern%20Reloaded.js?version=1012538
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_deleteValue
  14. // @grant GM_addStyle
  15. // @grant GM_registerMenuCommand
  16. // @author drhouse
  17. // @license CC-BY-NC-SA-4.0
  18. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  19. // ==/UserScript==
  20. /* global jQuery, $ */
  21. this.$ = this.jQuery = jQuery.noConflict(true);
  22. (function($){
  23.  
  24. setTimeout(function(){
  25. var cfg = new MonkeyConfig({
  26. title: 'Configure',
  27. menuCommand: true,
  28. params: {
  29. 'Automatic Temperature': {
  30. type: 'checkbox',
  31. default: true
  32. },
  33. 'Temperature': {
  34. type: 'number',
  35. default: '1'
  36. },
  37. 'Automatic Maximum Length': {
  38. type: 'checkbox',
  39. default: true
  40. },
  41. 'Maximum Length': {
  42. type: 'number',
  43. default: '2048'
  44. },
  45. 'Automatic Instructions': {
  46. type: 'checkbox',
  47. default: true
  48. },
  49. chatGPT_instructions: {
  50. type: 'text',
  51. default: ''
  52. },
  53.  
  54. },
  55. // onSave: setOptions
  56. })
  57.  
  58. 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"
  59. $('<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)
  60.  
  61. var e = jQuery.Event("keypress");
  62. e.which = 9;
  63. e.keyCode = 9;
  64.  
  65. if (cfg.get('Automatic Temperature')) {
  66. $("#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')))
  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").focus().trigger(e);
  68. }
  69. if (cfg.get('Automatic Maximum Length')) {
  70. $("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')))
  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)").focus().trigger(e);
  72. }
  73.  
  74. // chat-pg-instructions
  75. $('#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()
  76.  
  77. if (cfg.get('Automatic Instructions')) {
  78. $('#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'))
  79. }
  80.  
  81. $("button[id='continue']").click(function(){
  82. $("#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()
  83. setTimeout(function(){
  84. $("#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')
  85. }, 500);
  86. setTimeout(function(){
  87. $("#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()
  88. }, 1000);
  89. });
  90.  
  91.  
  92. }, 1000);
  93. })(jQuery);