KeepChatGPT

让我们在使用ChatGPT过程中更高效、更顺畅,完美解决ChatGPT网络错误,不再频繁地刷新网页,足足省去10个多余的步骤。解决了这几类报错: (1)NetworkError when attempting to fetch resource. (2)Something went wrong. If this issue persists please contact us through our help center at help.openai.com.

当前为 2023-04-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name KeepChatGPT
  3. // @description 让我们在使用ChatGPT过程中更高效、更顺畅,完美解决ChatGPT网络错误,不再频繁地刷新网页,足足省去10个多余的步骤。解决了这几类报错: (1)NetworkError when attempting to fetch resource. (2)Something went wrong. If this issue persists please contact us through our help center at help.openai.com.
  4. // @version 2.6
  5. // @author xcanwin
  6. // @description:en Let's make our use of ChatGPT more efficient and smoother, by perfecting the solution to ChatGPT network errors. This saves us from frequently refreshing the webpage and eliminates over 10 unnecessary steps. The following errors have been resolved: (1) NetworkError when attempting to fetch resource. (2) Something went wrong. If this issue persists please contact us through our help center at help.openai.com.
  7. // @namespace https://github.com/xcanwin/KeepChatGPT/
  8. // @supportURL https://github.com/xcanwin/KeepChatGPT/
  9. // @icon data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="2" fill="none" stroke="currentColor"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg>
  10. // @license GPL-2.0-only
  11. // @match *://chat.openai.com/chat*
  12. // @grant none
  13. // @run-at document-idie
  14. // ==/UserScript==
  15.  
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. var loadifr = function() {
  21. var u = `/api/${GM_info.script.author.slice(2,3)}uth/s${GM_info.script.name.slice(1, 2)}ssion`;
  22. if(!window.xcanwin){
  23. var ifr = document.createElement('iframe');
  24. ifr.id = "xcanwin";
  25. ifr.style.display = 'none';
  26. ifr.src = u;
  27. ifr.style.width = document.querySelector("nav a").offsetWidth + 'px';
  28. ifr.style.height = '75px';
  29. ifr.onload = function() {
  30. try {
  31. console.log(`KeepChatGPT: ${JSON.parse(ifr.contentDocument.body.innerText)['expires']}`);
  32. ifr.contentWindow.document.body.style.background = '#555';
  33. var cf_checkbox = document.querySelector(".ctp-checkbox-label");
  34. if (cf_checkbox) {
  35. cf_checkbox.click();
  36. }
  37. } catch (e) {
  38. }
  39. };
  40. document.querySelector("nav").appendChild(ifr);
  41. } else{
  42. window.xcanwin.src = u;
  43. }
  44. }
  45.  
  46. var loadhead = function() {
  47. if(!window.ndivid){
  48. loadifr();
  49. var ndiv = document.createElement("div");
  50. ndiv.id = "ndivid";
  51. ndiv.setAttribute("class", document.querySelector("nav a").className);
  52. ndiv.innerHTML = `<img src='${GM_info.script.icon}' />KeepChatGPT by xcanwin`;
  53. ndiv.onclick = kcg;
  54. var nav = document.querySelector('nav');
  55. nav.insertBefore(ndiv, nav.childNodes[0]);
  56. var newstyle = document.createElement('style');
  57. newstyle.innerHTML = `
  58. #ndivid {
  59. color: #555;
  60. background: linear-gradient(to top right, #F0B27A, #FDE184, #F0B27A);
  61. animation: gradient 6s ease-in-out infinite;
  62. position: relative;
  63. overflow: hidden;
  64. font-weight: bold;
  65. user-select: none;
  66. }
  67. @keyframes gradient {
  68. 0%{background-color:#F0B27A;}
  69. 50%{background-color:#FDE184;}
  70. 100%{background-color:#F0B27A;}
  71. }
  72.  
  73. #ndivid::before {
  74. content: '';
  75. position: absolute;
  76. top: -50%;
  77. left: -50%;
  78. width: 200%;
  79. height: 200%;
  80. background: linear-gradient(
  81. to bottom right,
  82. rgba(255, 255, 255, 0.3),
  83. rgba(255, 255, 255, 0.15),
  84. rgba(255, 255, 255, 0)
  85. );
  86. transform: rotate(-45deg);
  87. animation: shine 2.8s linear infinite;
  88. }
  89. @keyframes shine {
  90. from {
  91. transform: translateX(-50%) translateY(-50%) rotate(-45deg);
  92. }
  93. to {
  94. transform: translateX(150%) translateY(150%) rotate(-45deg);
  95. }
  96. }
  97. `;
  98. document.body.appendChild(newstyle);
  99. }
  100. }
  101.  
  102. var kcg = function() {
  103. window.xcanwin ? xcanwin.style.display == "none" ? xcanwin.style.display = "" : xcanwin.style.display = "none" : 0;
  104. }
  105.  
  106. setInterval(function() {
  107. if (document.querySelector("nav a")) {
  108. loadhead();
  109. }
  110. }, 300);
  111.  
  112. setInterval(function() {
  113. if (document.querySelector("nav a")) {
  114. loadifr();
  115. }
  116. }, 1000 * 30);
  117.  
  118. })();