Greasy Fork is available in English.
可恶的openai为什么要让我刷新页面
当前为
// ==UserScript==
// @name 自动刷新失效的ChatGPT页面,并自动复制输入框文本防丢失
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description 可恶的openai为什么要让我刷新页面
// @author CJM
// @match https://chat.openai.com/chat*
// @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
let txt = '';
const func = ()=>fetch("https://chat.openai.com/api/auth/session", {
"method": "GET",
"mode": "cors",
"credentials": "include"
}).then(res=>{
if(res.status===403){
location.reload()
}
});
// Your code here...
//setInterval(()=>{
//},40*1000+10*Math.random())
let flag = true;
window.addEventListener('keydown',(a1,a2,a3)=>{
let myTextArea = document.querySelector("textarea[tabindex='0']")
if(flag && myTextArea){
flag = false;
myTextArea && myTextArea.addEventListener("input", function() {
txt = myTextArea.value;
});
}
if(a1.code==='Enter'){
txt && navigator.clipboard.writeText(txt).then(()=>{
console.log('Copied to clipboard!');
})
func();
}
})
})();