-
Notifications
You must be signed in to change notification settings - Fork 1
/
export-chat.js
38 lines (38 loc) · 1.23 KB
/
export-chat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
((redactables) => {
const mainNode = $('main')
const text = [
'<!DOCTYPE html>',
'<head>',
'<!-- generated: ' + new Date().toISOString() + ' -->',
'<!-- answares: ' + $$('.markdown').length + ' -->',
'<!-- title: ' + document.title + ' -->',
'<title>saved: ' + document.title + '</title>',
'<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>',
'<style>',
' button, form { display: none !important; }',
'</style>',
'</head>',
'<body>',
'<main class="' + mainNode.className + '">',
mainNode.innerHTML,
'</main>',
'</body>',
]
.map(line => redactables ? line.replaceAll(redactables, '[REDACTED]') : line)
const textBlob = new Blob(text, {
type: 'text/html',
});
const downloadAnchor = document.createElement('a');
downloadAnchor.download =
[
new Date().toISOString().split(':').splice(0,2).join('').split('T').join(' '),
'ChatGPT',
document.title,
// new Date().toLocaleString()
// new Date().toISOString().split('T')[0]
]
.join(' - ')
.concat('.html');
downloadAnchor.href = window.URL.createObjectURL(textBlob);
downloadAnchor.click();
})("{string literal or regexp to redact}")