initial
commit
323e2d66fc
@ -0,0 +1,18 @@
|
||||
# Archive cGPT Conv
|
||||
|
||||
This script allows you to export the current cGPT conversation to a markdown file.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install the browser extension [Tampermonkey](https://tampermonkey.net/) for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/) or [Chrome](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo).
|
||||
|
||||
2. Install the script by clicking [here](https://raw.githubusercontent.com/blob42/cgpt-save-conversation/master/archive-cgpt-conv.user.js)
|
||||
|
||||
## Usage
|
||||
|
||||
1. Open a conversation on the cGPT chat
|
||||
2. Right-click on the page and select "Export Conv"
|
||||
3. The markdown file will be downloaded automatically
|
||||
|
||||
If the script does not seem to work, please reload the page and try again.
|
||||
|
@ -0,0 +1,48 @@
|
||||
// ==UserScript==
|
||||
// @name Archive cGPT Conv
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 0.1
|
||||
// @description try to take over the world!
|
||||
// @author You
|
||||
// @match https://chat.openai.com/chat/*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
|
||||
// @grant GM_registerMenuCommand
|
||||
// ==/UserScript==
|
||||
(function() {
|
||||
'use strict';
|
||||
GM_registerMenuCommand("Export Conv", exportConv);
|
||||
|
||||
|
||||
|
||||
|
||||
function getConvMarkdown(){
|
||||
const title = document.querySelector('title').textContent;
|
||||
const title_save = title.replace(/ /g, '_').replace(/\n/g, '');
|
||||
const messages = document.querySelectorAll('.text-base');
|
||||
let markdown = '# ' + title + '\n';
|
||||
let currentParticipant = 'Me';
|
||||
for (let i = 0; i < messages.length; i++) {
|
||||
markdown += currentParticipant + ': ' + messages[i].innerText + '\n---\n';
|
||||
currentParticipant = currentParticipant === 'Me' ? 'GPT' : 'Me';
|
||||
}
|
||||
const filename = title_save + '.md';
|
||||
|
||||
return {
|
||||
filename: filename,
|
||||
content: markdown
|
||||
}
|
||||
}
|
||||
|
||||
function exportConv(){
|
||||
const conv = getConvMarkdown();
|
||||
const data = new Blob([conv.content], { type: 'text/plain' });
|
||||
const file = window.URL.createObjectURL(data);
|
||||
const a = document.createElement('a');
|
||||
a.href = file;
|
||||
a.download = conv.filename;
|
||||
a.click();
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
Loading…
Reference in New Issue