Greasy Fork

来自缓存

Greasy Fork is available in English.

ChatGPT heartbeat

减少 ChatGPT 官方网页需要频繁刷新的简单办法

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ChatGPT heartbeat
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  减少 ChatGPT 官方网页需要频繁刷新的简单办法
// @author       https://v2ex.com/t/926890
// @match        https://chat.openai.com/chat*
// @icon         https://chat.openai.com/favicon.ico
// @grant        none
// @license MIT
// ==/UserScript==

/*
  需要保持非常久的,可以额外尝试在 chrome://discards 里禁用 `Auto Discardable`,
  或者用 https://github.com/WorldLanguages/DoNotDiscard
  否则就算保持了 Cookies 有效,Chrome 也有可能自动休眠标签页。
*/
(function () {
  var count = 0;
  var iframe = document.createElement("iframe");
  iframe.id = "heartbeat";
  iframe.style = "display:none";
  iframe.name = "heartbeat";
  iframe.src = "https://chat.openai.com/robots.txt";
  var fn = function () {
    setTimeout(function () {
      if (count++ % 60 === 59) {
        iframe.src = "https://chat.openai.com/404";
      } else if (iframe.src === "https://chat.openai.com/robots.txt") {
        iframe.contentWindow.location.reload(true);
      } else {
        iframe.src = "https://chat.openai.com/robots.txt";
      }
    }, Math.floor(Math.random() * 5) * 1000 + 5000);
  };
  if (iframe.attachEvent) {
    iframe.attachEvent("onload", fn);
  } else {
    iframe.onload = fn;
  }
  document.head.insertBefore(iframe, document.head.firstChild);
})();