ChatGPT - 让ChatGPT更持久

简介: ChatGPT - 让ChatGPT更持久


问题


解决办法

1。 先安装一个油猴

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


2。 安装 ChatGPT HeartBeat

https://greasyfork.org/zh-CN/scripts/462967-chatgpt-heartbeat


Code

// ==UserScript==
// @name         ChatGPT HeartBeat
// @namespace    http://tampermonkey.net/
// @version      0.2.6
// @license      GPLv3
// @description  USE AT YOUR OWN RISK!
// @author       https://v2ex.com/t/926890
// @homepage     https://v2ex.com/t/926890
// @homepageURL  https://v2ex.com/t/926890
// @match        https://chat.openai.com
// @match        https://chat.openai.com/*
// @icon         https://chat.openai.com/favicon.ico
// @require      https://greasyfork.org/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.com/WorldLanguages/DoNotDiscard
  否则就算保持了 Cookies 有效,Chrome 也有可能自动休眠标签页。
*/
/*
  从原理上来说,这个刷新针对的是静态资源,由 Cloudflare 负责处理,是不会回源到 OpenAI 的。
  所以比起请求 https://chat.openai.com/api/auth/session ,我认为这个方案更不容易被封号。
*/
(function () {
    function isWindow(obj) {
        return obj instanceof Window;
    }
    // 防止页面通过监听事件强制刷新
    // https://gist.github.com/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.com/_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.com/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.com/t/926890#r_12935587
            console.error(error);
            refresh();
        }
    }, cfg.get("refreshInterval") * 1000);
})();

原理: 每过 30 秒请求一次 ChatGPT 保持在线


相关文章
|
监控 网络协议 Ubuntu
Linux网络监控工具 - iftop
Linux网络监控工具 - iftop
491 1
|
5月前
|
JSON 监控 API
抖音视频列表API秘籍!轻松获取视频列表数据
抖音视频列表API是抖音开放平台提供的核心接口,支持按关键词、分类、排序方式筛选视频,适用于内容推荐、趋势分析等场景。接口返回含视频ID、标题、播放量等50+字段,支持分页获取,通过HTTP GET请求调用,返回JSON格式数据,便于开发者快速集成与处理。需注册平台账号获取访问权限。
1179 56
|
存储 安全 API
OpenStack的块存储卷管理卷 (Volume)
【8月更文挑战第26天】
562 5
|
11月前
|
人工智能 自然语言处理 搜索推荐
小米实测:Deepseek——你的私人旅游攻略定制专家!
大家好,我是小米,一个31岁的技术爱好者。今天分享如何用Deepseek规划完美旅行。Deepseek能快速整合信息、提供个性化推荐,省时省力,并支持实时问答。从目的地选择到行程规划,再到预订机票住宿和旅行中的实时帮助,它都能提供强大支持。希望今天的分享能帮到你,期待你用Deepseek规划出属于自己的精彩旅程!如果你觉得有用,欢迎点赞、转发并关注我的微信公众号“软件求生”,获取更多技术干货。
965 8
|
弹性计算 网络协议
计算机网络-数据链路层
计算机网络-数据链路层
计算机网络-数据链路层
|
机器学习/深度学习 人工智能 算法
AI辅助医疗影像:提高诊断准确性
【10月更文挑战第2天】医学影像技术是现代医学诊断的关键手段,但传统方法依赖医生经验,存在误诊风险。AI辅助医疗影像通过自动化图像识别、疾病预测和辅助诊断决策,显著提升了诊断准确性与效率。利用深度学习、数据增强及迁移学习等技术,AI不仅能快速分析影像,还能提供个性化诊疗建议,并实时监测疾病变化。尽管面临数据质量、算法可解释性和伦理法律等挑战,但多模态影像分析、跨学科合作及VR融合等趋势将推动AI在医疗影像领域的广泛应用,助力实现更精准、高效的医疗服务。
1086 3
|
安全 网络安全 数据安全/隐私保护
第六问:http和https区别与联系
HTTP 和 HTTPS 是现代网络通信中的两种重要协议。HTTP 是明文传输协议,无加密功能;HTTPS 在 HTTP 基础上加入 SSL/TLS 加密层,提供数据加密、身份验证和数据完整性保障。HTTP 适用于非敏感信息传输,如新闻网站;HTTPS 适用于在线支付、账户登录等需要保护用户数据的场景。
|
算法 机器人 计算机视觉
图像处理之Canny边缘检测
图像处理之Canny边缘检测
724 1
|
Python
PyQt中资源文件的使用(详细步骤介绍)
PyQt中资源文件的使用(详细步骤介绍)
744 1
语法树的画法(根据文法求字符串)
语法树的画法(根据文法求字符串)
319 1