forked from web-scrobbler/web-scrobbler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.config.ts
122 lines (109 loc) · 2.61 KB
/
manifest.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { Manifest } from 'webextension-polyfill';
import pkg from './package.json';
import { releaseTarget } from './scripts/util';
/**
* Common properties between all browsers manifests
*/
export const common: Manifest.WebExtensionManifest = {
manifest_version: 3,
name: 'Web Scrobbler',
default_locale: 'en',
description: '__MSG_extDescription__',
version: pkg.version,
permissions: ['storage', 'contextMenus', 'notifications', 'scripting'],
host_permissions: ['http://*/', 'https://*/'],
content_scripts: [
{
matches: ['<all_urls>'],
js: ['content/main.js'],
all_frames: true,
},
],
web_accessible_resources: [
{
resources: ['connectors/*'],
matches: ['<all_urls>'],
},
{
resources: ['icons/*'],
matches: ['<all_urls>'],
},
],
options_ui: {
page: 'src/ui/options/index.html',
open_in_tab: true,
},
icons: {
16: 'icons/icon_main_16.png',
48: 'icons/icon_main_48.png',
96: 'icons/icon_main_96.png',
128: 'icons/icon_main_128.png',
256: 'icons/icon_main_256.png',
512: 'icons/icon_main_512.png',
},
action: getAction(releaseTarget),
commands: {
'toggle-connector': {
description: '__MSG_hotkeyToggleConnector__',
},
'love-song': {
description: '__MSG_hotkeyLoveSong__',
},
'unlove-song': {
description: '__MSG_hotkeyUnloveSong__',
},
},
};
/**
* Manifest for chromium browsers
*/
export const chromeManifest: Manifest.WebExtensionManifest = {
...common,
background: {
service_worker: 'background/main.js',
},
};
/**
* Manifest for safari
*/
export const safariManifest: Manifest.WebExtensionManifest = {
...common,
background: {
scripts: ['background/main.js'],
persistent: false,
},
};
/**
* Manifest for firefox
*/
export const firefoxManifest: Manifest.WebExtensionManifest = {
...common,
background: {
scripts: ['background/main.js'],
},
browser_specific_settings: {
gecko: {
id: '{799c0914-748b-41df-a25c-22d008f9e83f}',
},
},
};
/**
* Gets action with defaults for a browser
*
* @param browser - browser to get action for
* @returns manifest action object
*/
function getAction(browser?: string) {
// default to light theme in browsers that have themed icon as we cannot dynamically set in manifest.
const defaultType = browser === 'safari' ? 'safari' : 'light';
return {
default_icon: {
16: `icons/action_unsupported_16_${defaultType}.png`,
19: `icons/action_unsupported_19_${defaultType}.png`,
32: `icons/action_unsupported_32_${defaultType}.png`,
38: `icons/action_unsupported_38_${defaultType}.png`,
},
default_title: '__MSG_pageActionUnsupported__',
default_popup: 'src/ui/popup/index.html',
};
}