-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathvite.config.ts
96 lines (93 loc) · 3.77 KB
/
vite.config.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import preact from '@preact/preset-vite'
import { defineConfig } from 'vite'
import monkey, { cdn } from 'vite-plugin-monkey'
import packageJson from './package.json'
// https://vitejs.dev/config/
export default defineConfig({
// https://github.com/lisonge/vite-plugin-monkey/issues/10#issuecomment-1207264978
esbuild: {
charset: 'utf8',
},
plugins: [
preact({
devToolsEnabled: false,
devtoolsInProd: false,
}),
monkey({
entry: 'src/main.tsx',
userscript: {
'name': {
'': packageJson.title,
'zh-CN': packageJson['title:zh-CN'],
'zh-TW': packageJson['title:zh-TW'],
},
'author': packageJson.author,
'namespace': packageJson.author,
'description': {
'': packageJson.description,
'zh-CN': packageJson['description:zh-CN'],
'zh-TW': packageJson['description:zh-TW'],
},
'license': packageJson.license,
'match': [
'https://chat.openai.com/',
// support https://chat.openai.com/?model={model}
'https://chat.openai.com/?model=*',
// support https://chat.openai.com/c/123456789
'https://chat.openai.com/c/*',
// support https://chat.openai.com/g/g-123456789
'https://chat.openai.com/g/*',
// support https://chat.openai.com/gpts/
'https://chat.openai.com/gpts',
'https://chat.openai.com/gpts/*',
// support https://chat.openai.com/share/123456789
'https://chat.openai.com/share/*',
// support https://chat.openai.com/share/123456789/continue
'https://chat.openai.com/share/*/continue',
'https://chatgpt.com/',
'https://chatgpt.com/?model=*',
'https://chatgpt.com/c/*',
'https://chatgpt.com/g/*',
'https://chatgpt.com/gpts',
'https://chatgpt.com/gpts/*',
'https://chatgpt.com/share/*',
'https://chatgpt.com/share/*/continue',
'https://new.oaifree.com/',
'https://new.oaifree.com/?model=*',
'https://new.oaifree.com/c/*',
'https://new.oaifree.com/g/*',
'https://new.oaifree.com/gpts',
'https://new.oaifree.com/gpts/*',
'https://new.oaifree.com/share/*',
'https://new.oaifree.com/share/*/continue',
],
'icon': 'https://chat.openai.com/favicon.ico',
'run-at': 'document-end',
},
build: {
fileName: 'chatgpt.user.js',
externalGlobals: [
['jszip', cdn.jsdelivr('JSZip', 'dist/jszip.min.js')],
['html2canvas', cdn.jsdelivr('html2canvas', 'dist/html2canvas.min.js')],
],
cssSideEffects() {
return (e) => {
const o = document.createElement('style')
o.textContent = e
document.head.append(o)
setInterval(() => {
if (o.isConnected) return
document.head.append(o)
}, 300)
}
},
},
server: {
open: true,
},
}),
],
build: {
cssMinify: false,
},
})