KeepChatGPT

ChatGPT网络异常拜拜员. Chatgpt no longer network error. 解决这几类报错: (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-03-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name KeepChatGPT
  3. // @description ChatGPT网络异常拜拜员. Chatgpt no longer network error. 解决这几类报错: (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.1
  5. // @author xcanwin
  6. // @namespace https://github.com/xcanwin/KeepChatGPT/
  7. // @supportURL https://github.com/xcanwin/KeepChatGPT/
  8. // @license GPL-2.0-only
  9. // @match *://chat.openai.com/chat*
  10. // @grant none
  11. // @run-at document-idie
  12. // ==/UserScript==
  13.  
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. window.ifrurl = "/api/auth/session";
  19. var loadifr = function() {
  20. if(!window.xcanwin){
  21. var ifr = document.createElement('iframe');
  22. ifr.id = "xcanwin";
  23. ifr.style.display = 'none';
  24. ifr.src = window.ifrurl;
  25. ifr.style.width = document.querySelector("nav a").offsetWidth + 'px';
  26. ifr.style.height = '75px';
  27. ifr.onload = function() {
  28. try {
  29. console.log(`KeepChatGPT: ${JSON.parse(ifr.contentDocument.body.innerText)['expires']}`);
  30. ifr.contentWindow.document.body.style.background = '#555';
  31. } catch (e) {
  32. }
  33. };
  34. document.querySelector("nav").appendChild(ifr);
  35. } else{
  36. window.xcanwin.src = window.ifrurl;
  37. }
  38. }
  39.  
  40. var loadhead = function() {
  41. if(!window.ndivid){
  42. loadifr();
  43. var ndiv = document.createElement("div");
  44. ndiv.id = "ndivid";
  45. ndiv.setAttribute("class", document.querySelector("nav a").className);
  46. ndiv.innerHTML = `
  47. <svg height="24" width="24" stroke-width="2" fill="none" stroke="currentColor">
  48. <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
  49. 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">
  50. </path>
  51. </svg>
  52. KeepChatGPT by xcanwin
  53. `;
  54. ndiv.onclick = kcg;
  55. var nav = document.querySelector('nav');
  56. nav.insertBefore(ndiv, nav.childNodes[0]);
  57. var newstyle = document.createElement('style');
  58. newstyle.innerHTML = `
  59. #ndivid {
  60. color: #555;
  61. background: linear-gradient(to top right, #F0B27A, #FDE184, #F0B27A);
  62. animation: gradient 6s ease-in-out infinite;
  63. position: relative;
  64. overflow: hidden;
  65. font-weight: bold;
  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. })();