-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.js
More file actions
47 lines (39 loc) · 1.31 KB
/
convert.js
File metadata and controls
47 lines (39 loc) · 1.31 KB
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
// https://github.com/FoxRefire/ChromeXPIPorter/blob/main/patchExt.js
import manifest from './src/manifest.js'
import packageData from './package.json' assert { type: 'json' }
const isDev = process.env.NODE_ENV === 'development'
export async function patchManifest() {
const newExtId = `${packageData.name}${isDev ? '-dev' : ''}@${packageData.author}.com`
if (!manifest.background) {
manifest.background = {
scripts: [],
}
}
if (manifest.background?.service_worker) {
manifest.background.scripts = [manifest.background.service_worker]
delete manifest.background.service_worker
}
manifest.background.scripts.push('uninstallHandler.js')
if (manifest.permissions?.includes('sidePanel')) {
manifest.permissions = manifest.permissions.filter((permission) => permission !== 'sidePanel')
}
if (manifest.side_panel) {
manifest['sidebar_action'] = {
default_title: manifest.name,
default_panel: manifest.side_panel.default_path,
default_icon: manifest.icons[16],
}
delete manifest.side_panel
}
manifest.browser_specific_settings = {
gecko: {
id: newExtId,
},
}
if (manifest.web_accessible_resources) {
manifest.web_accessible_resources.forEach((res) => {
if (res.extension_ids) res.extension_ids = [newExtId]
})
}
return manifest
}