Chat GPT会话多了,打开会有点慢。因此只能删除,重新训练。为此涉及批量删除工作。
1、打开chatgpt
2、在页面的任何空白区域上点击右键,然后从选项中选择“检查”。在调试窗口中点击控制台菜单console。
3、粘贴以下代码,并按回车执行。过几秒刷新可以看到会话已经全部清空。粘贴代码可以会被禁用,按提示先输入确认字符,就可以粘贴了。
const anchors = document.querySelectorAll(".flex.items-center.gap-2.p-2");
const ids = Array.from(anchors)
.map((a) => a.href?.split("/").slice(-1)[0])
.filter((id) => !!id);
const deleteAllConversations = async () => {
const { accessToken } = await fetch("https://chatgpt.com/api/auth/session", {
method: "GET",
credentials: "include",
}).then(res => res.json());
const idPromises = ids.map(async (id) => {
fetch(`https://chatgpt.com/backend-api/conversation/${id}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
},
body: JSON.stringify({is_visible: false}),
method: "PATCH",
credentials: "include",
});
});
Promise.all(idPromises);
};
deleteAllConversations();
