-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmanifest.json.make.ts
59 lines (54 loc) · 1.57 KB
/
manifest.json.make.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
import fs from "fs/promises";
/** Googleの公式情報から検索ドメインを取ってきます。 */
async function selectGoogleSearchUrls(): Promise<string[]> {
const response = await fetch("https://www.google.com/supported_domains");
const text = await response.text();
return text
.split("\n")
.filter((domain) => domain.includes("google"))
.map((domain) => `https://www${domain}/search*`);
}
/** manifest.jsonを生成して書き込みます。 */
async function writeManifestJson(): Promise<void> {
return fs.writeFile(
"manifest.json",
JSON.stringify(
{
manifest_version: 2,
name: "google-search-title-qualified",
version: "0.14.0",
description:
"Google will omit the title of the web page. With this add-on, the original title is used as much as possible.",
browser_specific_settings: {
gecko: {
id: "google-search-title-qualified@ncaq.net",
strict_min_version: "102.0",
},
},
icons: {
"48": "icon-48.png",
"96": "icon-96.png",
"128": "icon-128.png",
},
permissions: ["<all_urls>"],
background: {
scripts: ["dist/background/main.js"],
},
content_scripts: [
{
js: ["dist/content/main.js"],
matches: await selectGoogleSearchUrls(),
},
],
},
null,
2
)
);
}
// ts-nodeとかで実行させます。
if (require.main === module) {
writeManifestJson().catch((e) => {
throw e;
});
}