-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmanifest.config.ts
85 lines (82 loc) · 2.44 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
import { defineManifest } from "@crxjs/vite-plugin";
import packageJson from "./package.json";
import type { ManifestV3Export } from "@crxjs/vite-plugin";
const { version } = packageJson;
const target = process.env.BUILD_TARGET;
// Convert from Semver (example: 0.1.0-beta6)
const [major, minor, patch, label = "0"] = version
// can only contain digits, dots, or dash
.replace(/[^\d.-]+/g, "")
// split into version parts
.split(/[.-]/);
let json: ManifestV3Export = {
manifest_version: 3,
name: "lingo link",
// up to four numbers separated by dots
version: `${major}.${minor}.${patch}.${label}`,
// semver is OK in "version_name"
version_name: version,
icons: {
128: "src/assets/icon.png",
},
action: {
default_icon: "src/assets/icon.png",
default_popup: "src/pages/popup/index.html",
},
permissions: [
"activeTab",
"identity",
"storage",
"contextMenus",
"identity.email",
],
content_scripts: [
{
js: ["src/contentScript/index.tsx"],
matches: ["*://*/*"],
},
],
options_page: "src/pages/options/index.html",
background: {
service_worker: "src/background.ts",
type: "module",
},
host_permissions: ["https://www.youdao.com/*", "https://dict.youdao.com/*"],
externally_connectable: {
matches: ["http://localhost:7777/*", "https://*.mywords.cc/*"],
},
};
if (target === "chrome") {
json = {
...json,
...{
key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApXvVjpN4kxyWPCZuhsoHZYavMOI+U5w6FHXITdHUuF5UKzlAJr0Lqu5ZY5+b6U+Y19ZLh9SDfhFi4fk5PtF3I8cQbUI8p2eXxwUio7IgxWJQgruQLwILO08LvLTa55BinA/Sgstl6zbYTAeFLthd1JJyz5FDN26NwH6CcbqEY7AC2Vr9/VtwH4buz92qetjuR5MpfrzNUN0QtSlKnXPJ8wasCGeWDcerynYw/OEVXwbgiENfK8+K9hHKnsZLK+U4Y4yrNEZPOfMBSe+Q1o2+eof2DQFxsDxy9ohyk3P1/oyP3vmhD2xxuJOtsS9hp31lDm+2nlreCC3w5IKsUZABDQIDAQAB",
oauth2: {
client_id:
"33611715893-c00c0ofv209ophmc2tf113t3t6luslkt.apps.googleusercontent.com",
scopes: [
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
],
},
},
};
}
if (target === "firefox") {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
json = {
...json,
...{
browser_specific_settings:{
gecko: {
id: "[email protected]",
}
},
background: {
page: "background.html"
},
}
}
}
export default defineManifest(async () => json);