-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmanifest.ts
36 lines (31 loc) · 1.11 KB
/
manifest.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
import { distFileName } from 'userscripter/build'
import Manifest from 'webextension-manifest'
import metadataFactory from './metadata'
import U from './src/userscript'
const metadata = metadataFactory()
type RunAt = 'document_start' | 'document_end' | 'document_idle'
// Used to translate the userscript meta syntax to webextension
const runAtMetadataToManifest: { [key: string]: RunAt } = {
'document-end': 'document_end',
'document-start': 'document_start',
'document-idle': 'document_idle',
}
// Will generate the manifest.json for the code as web extension
export default function manifestConfigFactory(): Manifest {
return {
manifest_version: 2,
name: metadata.name,
version: metadata.version,
description: metadata.description,
author: metadata.author,
content_scripts: [
{
matches: metadata.match,
js: [distFileName(U.id, 'user')],
run_at: runAtMetadataToManifest[metadata.run_at],
// Must be true to load the extension into cypress e2e tests scenario
all_frames: process.env.NODE_ENV === 'test' ? true : !metadata.noframes,
},
],
}
}