-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
38 lines (36 loc) · 933 Bytes
/
build.js
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
var JavaScriptObfuscator = require("javascript-obfuscator");
var fs = require("fs");
var codes = ["background.js", "content.js"];
codes.forEach(codePath => {
fs.readFile(codePath, "utf8", function(err, data) {
var obfuscationResult = JavaScriptObfuscator.obfuscate(data, {
compact: true,
debugProtection: true,
simplify: true,
disableConsoleOutput: true,
deadCodeInjection: true,
controlFlowFlattening: false
});
fs.writeFile(
"build/" + codePath,
obfuscationResult.getObfuscatedCode(),
() => {
console.log("Writing " + codePath);
}
);
});
});
var files = fs.readdirSync("./");
files.forEach(file => {
if (
!codes.includes(file) &&
file != ".git" &&
file != "build" &&
file != "node_modules"
) {
fs.copyFile(file, "build/" + file, err => {
if (err) throw err;
console.log("Copied " + file);
});
}
});