// ==UserScript== // @name Save ChatGPT as PDF // @namespace http://tampermonkey.net/ // @version 1.5 // @description Turn your chats into neatly formatted PDF. // @author PDFCrowd (https://pdfcrowd.com/) // @match https://chat.openai.com/* // @icon64 https://github.com/pdfcrowd/save-chatgpt-as-pdf/raw/master/icons/icon64.png // @run-at document-end // @grant GM_xmlhttpRequest // @connect api.pdfcrowd.com // @license MIT // @downloadURL none // ==/UserScript== /* globals pdfcrowdChatGPT */ // do not modify or delete the following line, it serves as a placeholder for // the common.js contents which is copied here by "make build-userscript-single-file" // // common.js placeholder 'use strict'; const pdfcrowdChatGPT = {}; pdfcrowdChatGPT.pdfcrowdAPI = 'https://api.pdfcrowd.com/convert/latest/'; pdfcrowdChatGPT.username = 'chat-gpt'; pdfcrowdChatGPT.apiKey = '29d211b1f6924c22b7a799b4e8fecb7e'; pdfcrowdChatGPT.init = function() { const urlPattern = /^.*?:\/\/chat\.openai\.com\/((c|g|share)\/.*)?$/; let currentUrl = ''; function checkUrlChange() { const newUrl = window.location.href; if(currentUrl !== newUrl) { currentUrl = newUrl; const blocks = document.getElementsByClassName('pdfcrowd-block'); if(urlPattern.test(currentUrl)) { for(let i = 0; i < blocks.length; i++) { blocks[i].classList.remove('pdfcrowd-hidden'); } } else { for(let i = 0; i < blocks.length; i++) { blocks[i].classList.add('pdfcrowd-hidden'); } } } } setInterval(checkUrlChange, 2000); // remote images live at least 1 minute const minImageDuration = 60000; const buttonIconFill = (typeof GM_xmlhttpRequest !== 'undefined') ? '#A72C16' : '#EA4C3A'; const pdfcrowdBlockHtml = `