Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
83 lines (66 loc) · 2.9 KB

File metadata and controls

83 lines (66 loc) · 2.9 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
const fs = require("fs");
const AdmZip = require("adm-zip");
const pjson = require('../package.json');
const ChromeExtension = require('crx');
const { execSync } = require("child_process");
// 处理manifest version
let str = fs.readFileSync("./build/scriptcat/manifest.json").toString();
str = str.replace(/"version": "(.*?)"/, '"version": "' + pjson.version + '"');
fs.writeFileSync("./build/scriptcat/manifest.json", str);
// 处理config.ts version
str = fs.readFileSync("./src/apps/config.ts").toString();
str = str.replace(/ExtVersion = '(.*?)';/, 'ExtVersion = \'' + pjson.version + '\';');
fs.writeFileSync("./src/apps/config.ts", str);
execSync("npm run build", { stdio: 'inherit' });
execSync("npm run build-no-split", { stdio: 'inherit' });
// 处理 ts.worker.js 和 editor.worker.js
let list = fs.readdirSync("./build/scriptcat/src");
let monaco = [];
for (let i = 0; i < list.length; i++) {
if (list[i].indexOf("monaco") === 0 && list[i].substr(list[i].indexOf(".js")) === ".js") {
monaco.push(list[i]);
}
}
let old = fs.readFileSync("./build/scriptcat/src/ts.worker.js", "utf-8");
fs.writeFileSync(
"./build/scriptcat/src/ts.worker.js",
'importScripts("' + monaco.join('","') + '");\n' + old.toString(),
);
old = fs.readFileSync("./build/scriptcat/src/editor.worker.js", "utf-8");
fs.writeFileSync(
"./build/scriptcat/src/editor.worker.js",
'importScripts("' + monaco.join('","') + '");\n' + old.toString(),
);
// 处理firefox和chrome的zip压缩包
jsonStr = fs.readFileSync("./build/scriptcat/manifest.json");
let jsonFirefox = JSON.parse(jsonStr);
let jsonChrome = JSON.parse(jsonStr);
delete jsonFirefox['sandbox'];
// delete jsonFirefox['background'];
// delete jsonFirefox['debugger'];
// jsonFirefox['content_security_policy'] = "script-src 'self' 'unsafe-eval'; object-src 'self'";
jsonFirefox['browser_specific_settings'] = { 'gecko': { 'strict_min_version': '91.1.0' } };
fs.writeFileSync("./build/manifest_firefox.json", JSON.stringify(jsonFirefox));
// delete jsonChrome['content_security_policy'];
fs.writeFileSync("./build/manifest_chrome.json", JSON.stringify(jsonChrome));
let chrome = new AdmZip();
let firefox = new AdmZip();
chrome.addLocalFile("./build/manifest_chrome.json", ".", "manifest.json");
chrome.addLocalFolder("./build/scriptcat", ".", (filename) => {
return filename !== "manifest.json";
});
firefox.addLocalFile("./build/manifest_firefox.json", ".", "manifest.json");
firefox.addLocalFolder("./build/scriptcat", ".", (filename) => {
return filename !== "manifest.json";
});
chrome.writeZip("./build/scriptcat.zip");
firefox.writeZip("./build/scriptcat_firefox.zip");
// 处理crx
const crx = new ChromeExtension({
privateKey: fs.readFileSync('./build/scriptcat.pem')
});
crx.load('./build/scriptcat').then((crx) => crx.pack()).then((crxBuffer) => {
fs.writeFileSync('./build/scriptcat.crx', crxBuffer);
}).catch((err) => {
console.error(err);
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.