-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.ts
28 lines (22 loc) · 827 Bytes
/
content.ts
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
import type { PlasmoCSConfig } from "plasmo"
import { copy, download, extractMarkdown } from "./lib"
export const config: PlasmoCSConfig = {
matches: ["https://chat.openai.com/chat/*"]
}
// **************************************************
// Key combination configuration, feel free to change
// **************************************************
const KEY_COMBINATION = (event: KeyboardEvent) => ({
// Copy: ctrl + '
copy: event.ctrlKey && event.key === "'",
// Download: ctrl + shift + '
download: event.ctrlKey && event.shiftKey && event.key === "'"
})
document.addEventListener("keydown", (event) => {
const detectedCommand = KEY_COMBINATION(event)
if (detectedCommand.download) {
download(extractMarkdown())
} else if (detectedCommand.copy) {
copy(extractMarkdown().markdownContent)
}
})