Simple method to reduce the need for frequent refreshing of ChatGPT official webpage#
Reprinted from: https://www.v2ex.com/t/926890
Open another tab and visit a link that requires verification but does not have any interactive requests, for example:
Install an automatic refresh plugin, I used one I found on GitHub:
https://github.com/Claxtastic/just-refresh (jquery.min.js has been compared with the official website and is identical)
I set the interval to 3 seconds, which works well for me. I hope it can help you too.
The principle is simple and can also be implemented in a more elegant way.
Tampermonkey Script#
For Tampermonkey version, if you don't want to install Tampermonkey, you can directly execute it in DevTools - Console on the chat page.
It's a bit more elegant and doesn't require opening multiple tabs.
I don't think anyone cares about having many 404 requests in DevTools - Network, right?
// ==UserScript==
// @name ChatGPT heartbeat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author https://v2ex.com/t/926890
// @match https://chat.openai.com/*
// @icon https://chat.openai.com/favicon.ico
// @grant none
// ==/UserScript==
(function() {
'use strict';
setInterval(function(){
fetch('https://chat.openai.com/404');
}, 3000);
})();
The above Tampermonkey script seems to be less effective than automatic refreshing by just fetching 404. In my test, I still needed to refresh, so I used an iframe instead. The code may not be good, so any suggestions are welcome:
// ==UserScript==
// @name ChatGPT heartbeat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author https://v2ex.com/t/926890
// @match https://chat.openai.com/*
// @icon https://chat.openai.com/favicon.ico
// @grant none
// ==/UserScript==
(function () {
var iframe = document.createElement("iframe");
iframe.id = "heartbeat";
iframe.style = "display:none";
iframe.name = "heartbeat";
iframe.src = "https://chat.openai.com/404/";
var fn = function () {
setTimeout(function(){
iframe.src = "https://chat.openai.com/404/" + Math.random();
}, 3000);
};
if (iframe.attachEvent) {
iframe.attachEvent("onload", fn);
} else {
iframe.onload = fn;
}
document.body.insertBefore(iframe, document.body.firstChild);
})();
The above Tampermonkey script consumes too much resources and the fan runs loudly.
In my test, robots.txt also works (fetch may fail due to Cloudflare's header detection?).
Below is the ChatGPT heartbeat that will not be modified anymore. If robots.txt becomes ineffective in the future, you can modify the link to 404 by yourself. If you think requesting every 5 seconds is too frequent, you can adjust the time interval by yourself.
// ==UserScript==
// @name ChatGPT heartbeat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author https://v2ex.com/t/926890
// @match https://chat.openai.com/chat/*
// @icon https://chat.openai.com/favicon.ico
// @grant none
// ==/UserScript==
(function () {
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(){
document.getElementById('heartbeat').contentWindow.location.reload(true);
}, 5000);
};
if (iframe.attachEvent) {
iframe.attachEvent("onload", fn);
} else {
iframe.onload = fn;
}
document.body.insertBefore(iframe, document.body.firstChild);
})();