Fanly ChatGPT

OpenAI ChatGPT自动点击"Continue generating"按钮,实现自动继续生成,并且添加“100字总结”按钮,对生成的内容实现快速总结,帮助编辑人员提高效率。

当前为 2023-08-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fanly ChatGPT
  3. // @description OpenAI ChatGPT自动点击"Continue generating"按钮,实现自动继续生成,并且添加“100字总结”按钮,对生成的内容实现快速总结,帮助编辑人员提高效率。
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @author Fanly
  7. // @match https://chat.openai.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  9. // @grant none
  10. // @run-at document-idle
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. console.log('ChatGPT Auto Summarize and Continue')
  17.  
  18. var auto_summarize_and_continue = function(){
  19. var buttons = document.querySelectorAll('button.btn-neutral');
  20. for (var i=buttons.length-1; i>=0; i--){
  21. if (buttons[i].innerText =='Continue generating') { // If it is the Continue generating button
  22. setTimeout((function(i){
  23. return function(){
  24. buttons[i].click();
  25. }
  26. })(i),1000);
  27. break;
  28. }
  29. else if (buttons[i].innerText =='Regenerate') { // If it is the Regenerate button
  30.  
  31. // Check if the 100字总结 button already exists
  32. var summaryButtonExists = false;
  33. for (var j=0; j<buttons.length; j++){
  34. if (buttons[j].innerText =='100字总结') {
  35. summaryButtonExists = true;
  36. break;
  37. }
  38. }
  39.  
  40. // If it does not exist, create and add it
  41. if (!summaryButtonExists) {
  42. var button = document.createElement("button");
  43. button.className = "btn relative btn-neutral sumup";
  44. button.innerText='100字总结';
  45.  
  46. button.onclick = function() {
  47. var textarea = document.getElementById('prompt-textarea');
  48.  
  49. // Simulate user input instead of directly changing the value
  50. var inputEvent = new InputEvent('input', {
  51. bubbles: true,
  52. cancelable: true,
  53. });
  54. textarea.value = '100字总结';
  55. textarea.dispatchEvent(inputEvent);
  56. textarea.focus(); // Focus the cursor in the textarea
  57. var event = new KeyboardEvent('keydown',{'key':'Enter'});
  58. textarea.dispatchEvent(event);
  59. };
  60.  
  61. buttons[i].after(button);
  62. }
  63. break;
  64. }
  65. }
  66. }
  67.  
  68. // Call the function every second
  69. setInterval(auto_summarize_and_continue,1000);
  70. })();