快乐ChatGPT

使用本脚本可以避免在免费版ChatGPT使用过程中经常性的报错问题,从此再也不用反复刷新网页,直逼plus版本的体验。

  1. // ==UserScript==
  2. // @name 快乐ChatGPT
  3. // @description 使用本脚本可以避免在免费版ChatGPT使用过程中经常性的报错问题,从此再也不用反复刷新网页,直逼plus版本的体验。
  4. // @version 0.0.1
  5. // @author 亿千个太阳
  6. // @namespace https://b23.tv/dESTNzK
  7. // @supportURL https://b23.tv/dESTNzK
  8. // @license GPL-2.0-only
  9. // @match https://chat.openai.com/*
  10. // @grant GM_addStyle
  11. // @grant GM_addElement
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // @grant unsafeWindow
  15. // @run-at document-idle
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20. var $ = (Selector, el) => (el || document).querySelector(Selector);
  21. var u = `/api/auth/session`;
  22. var sp_class_1 = 'nav>a.flex';
  23. var sp_class_2 = 'button.justify-center';
  24. var $$ = (Selector, el) => (el || document).querySelectorAll(Selector);
  25. var formatDate = function(d) {
  26. return (new Date(d)).toLocaleString();
  27. };
  28. var autoPingChatPGT = function() {
  29. fetch(u).then((response) => {
  30. response.text().then((data) => {
  31. try {
  32. var contentType = response.headers.get('Content-Type');
  33. if (contentType.indexOf("application/json") > -1 && response.status !== 403 && data.indexOf(`"expires":"`) > -1) {
  34. console.log(`快乐ChatGPT: FETCH: Expire date: ${formatDate(JSON.parse(data).expires)}`);
  35. }
  36. } catch (e) {
  37. console.log(`快乐ChatGPT: FETCH: ERROR: ${e},\nERROR RESPONSE:\n${data}`);
  38. }
  39. })
  40. });
  41. }
  42. var gdAuditModerations = function(action) {
  43. if (typeof _fetch == 'undefined') {
  44. var _fetch = fetch;
  45. }
  46. if (action == true) {
  47. unsafeWindow.fetch = new Proxy(fetch, {
  48. apply: function (target, thisArg, argumentsList) {
  49. var n = {};
  50. n.json = function() {return {};};
  51. return argumentsList[0].includes('moderations') ? Promise.resolve(n) : target.apply(thisArg, argumentsList);
  52. }
  53. });
  54. } else {
  55. unsafeWindow.fetch = _fetch;
  56. }
  57. };
  58.  
  59. var gdConversationNotFound = function(action) {
  60. if (typeof _fetch == 'undefined') {
  61. var _fetch = fetch;
  62. }
  63. if (action == true) {
  64. unsafeWindow.fetch = new Proxy(_fetch, {
  65. apply: function (target, thisArg, argumentsList) {
  66. try {
  67. if (argumentsList[0].includes('conversation')) {
  68. var post_body = JSON.parse(argumentsList[1].body);
  69. post_body.conversation_id = location.href.match(/\/c\/(.*)/)[1];
  70. argumentsList[1].body = JSON.stringify(post_body);
  71. }
  72. } catch (e) {}
  73. return target.apply(thisArg, argumentsList);
  74. }
  75. });
  76. } else {
  77. unsafeWindow.fetch = _fetch;
  78. }
  79. };
  80. setInterval(function() {
  81. if ($(sp_class_1) || $(sp_class_2)) {
  82. autoPingChatPGT();
  83. }
  84. }, 1000 * (10 + Math.floor(Math.random()*7)));
  85. gdConversationNotFound(true);
  86. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址