admin管理员组

文章数量:1535507


1、前言

最近使用 ChatGPT 总是出现「Something went wrong. If this issue persists please contact us through our help center at help.openai.」,在生成时经常断掉,甚至一开始就生成不了,还得需要我们手动刷新页面…
频繁操作,很是烦扰,今天手把手解决 ChatGPT 挂掉的简单方法。

2、问题详细描述

当和 ChatGPT 聊着聊着,突然出现类似于断线的提示,并且需要刷新页面,才可以继续访问,最近出现的频次越来越高,估计是为了防止恶意使用,但对我们每天正常使用用户来说,太麻烦。

3、问题解决方案

3.1、安装油猴插件

 https://chrome.google/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo

篡改猴 (Tampermonkey) 使管理您的用户脚本变得非常简单。位于右上方的 篡改猴 图标显示正在运行的脚本的数量,单击图标就可以看到正在运行的脚本和可能在这个网页上运行的脚本。

3.2、安装 ChatGPT HeartBeat

 https://greasyfork/zh-CN/scripts/462967-chatgpt-heartbeat ChatGPT HeartBeat 是一个 控制 ChatGPT 刷新频率的脚本

我们注意看这段脚本描述:

从原理上来说,这个刷新针对的是静态资源,由 Cloudflare 负责处理,是不会回源到 OpenAI 的。所以比起请求 https://chat.openai/api/auth/session ,我认为这个方案更不容易被封号。

我们把脚本源码复制下来,仔细研究,防止有恶意脚本威胁到安全:

// ==UserScript==
// @name         ChatGPT HeartBeat
// @namespace    http://tampermonkey/
// @version      0.2.6
// @license      GPLv3
// @description  USE AT YOUR OWN RISK!
// @author       https://v2ex/t/926890
// @homepage     https://v2ex/t/926890
// @homepageURL  https://v2ex/t/926890
// @match        https://chat.openai
// @match        https://chat.openai/*
// @icon         https://chat.openai/favicon.ico
// @require      https://greasyfork/scripts/395037-monkeyconfig-modern/code/MonkeyConfig%20Modern.js?version=764968
// @run-at       document-start
// @noframes
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_addStyle
// ==/UserScript==

/*
  需要保持非常久的,可以额外尝试在 chrome://discards 里禁用 `Auto Discardable`,
  或者用 https://github/WorldLanguages/DoNotDiscard
  否则就算保持了 Cookies 有效,Chrome 也有可能自动休眠标签页。
*/

/*
  从原理上来说,这个刷新针对的是静态资源,由 Cloudflare 负责处理,是不会回源到 OpenAI 的。
  所以比起请求 https://chat.openai/api/auth/session ,我认为这个方案更不容易被封号。
*/
(function () {
    function isWindow(obj) {
        return obj instanceof Window;
    }

    // 防止页面通过监听事件强制刷新
    // https://gist.github/fuzmish/bd444b1aadc2d22aada7c9b1a6de56ba
    const rawAddEventListener = EventTarget.prototype.addEventListener;
    EventTarget.prototype.addEventListener = function (...args) {
        const [eventName] = args;
        if (
            isWindow(this) &&
            ["focus", "focusin", "visibilitychange"].includes(eventName)
        ) {
            return;
        }
        return rawAddEventListener.apply(this, args);
    };

    const cfg = new MonkeyConfig({
        title: "Configuration",
        menuCommand: true,
        params: {
            refreshInterval: {
                type: "number",
                default: 30,
            },
            refreshURL: {
                type: "text",
                default:
                "https://chat.openai/_next/static/k9OKjvwgjWES7JT3k-6g9/_ssgManifest.js",
            },
        },
    });

    function getRefreshURL () {
        var refreshURL = cfg.get("refreshURL");
        // 如果手动配置了 _ssgManifest.js 以外的 URL,就不尝试获取最新的
        if (!refreshURL.endsWith("_ssgManifest.js")) {
            return refreshURL;
        }
        // 获取最新的 _ssgManifest.js 链接
        // https://v2ex/t/926890#r_12897849
        const manifestScript = document.querySelector(
            'script[src*="_ssgManifest.js"]'
        );
        if (manifestScript) {
            cfg.set("refreshURL", manifestScript.src);
            return manifestScript.src;
        }
        return refreshURL;
    };

    const heartbeat = document.createElement("iframe");
    heartbeat.style.display = "none";
    document.head.prepend(heartbeat);

    let count = 0;
    function refresh() {
        count = 0;
        heartbeat.src = `${getRefreshURL()}?${Date.now()}`;
    }
    setInterval(function () {
        try {
            let current = new URL(heartbeat.contentWindow.location.href);
            let expect = new URL(getRefreshURL());
            if ( heartbeat.contentWindow.location.href === '' ||
                heartbeat.contentWindow.location.href === 'about:blank' ||
                current.pathname === expect.pathname ||
                count++ * cfg.get("refreshInterval") >= 2 * 60) {
                refresh();
            }
        } catch (error) {
            // https://v2ex/t/926890#r_12935587
            console.error(error);
            refresh();
        }
    }, cfg.get("refreshInterval") * 1000);
})();
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.

3.3、油猴插件配置

点击油猴插件,在「管理面板」中查看是否开启的状态

3.4、设置刷新的时间

浏览器打开 ChatGPT,右击打开 Tampermonkey - ChatGPT HeartBeat - Configuration

设置刷新的时间为 3 秒,修改刷新 url 的链接。

4、查看结果

再也不会出现断线的问题了,给力!!!


原创作者: u_16609400 转载于: https://blog.51cto/u_16609400/10728337

本文标签: 解决方案chatGPTwrong