// ==UserScript== // @name Download ChatGPT record // @namespace http://tampermonkey.net/ // @version 0.3 // @description 通过右下角的按钮以html文件的形式保存当前页面下ChatGPT的对话记录:Save the chat record of ChatGPT on the current page in the form of html file, and click the button at the bottom right corner // @author YYForReal // @match https://chat.openai.com/chat* // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; (function(){ // 原本官网的域名,用于连接资源 // const ResourceDomain = "https://chat.openai.com/" // 使用Gitee仓库内托管的资源 const ResourceDomain = "https://gitee.com/friendArt/download-ChatGPT-record/raw/master/resource/" function downloadInit(){ // 替换所有的href链接 let links = document.head.querySelectorAll("link"); for (let link of links) { if (link.getAttribute("href").indexOf("http") !== 0) { link.setAttribute("href", ResourceDomain + link.getAttribute("href")); } } // 移除head内部的script代码 let scripts = document.head.querySelectorAll("script"); for (let scriptDom of scripts) { scriptDom.parentElement.removeChild(scriptDom); // 如果需要继续使用的话可以拼接保留 // if (link.getAttribute("href").indexOf("http") !== 0) { // link.setAttribute("href", ResourceDomain + link.getAttribute("href")); // } } // 移除底部栏 let bottom = document.body.querySelector('.absolute.bottom-0') console.log("bottom",bottom) bottom.parentNode.removeChild(bottom) // 修改样式,使之可以滚动 let overflowDoms = document.body.querySelectorAll('.overflow-hidden') for (let dom of overflowDoms){ dom.classList.remove("overflow-hidden") } // 修改样式,使之紧凑不换行 // let wrapDoms = document.body.querySelectorAll('.whitespace-pre-wrap') // for (let dom of wrapDoms){ // dom.classList.remove("whitespace-pre-wrap") // } // 拿到修改之后的字符串文本 // 获取主体的main元素和开头的head元素 let main = document.getElementsByTagName('main')[0]; let mainStr = main.outerHTML; let headStr = document.head.outerHTML; // 去除所有的