-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (63 loc) · 2.03 KB
/
index.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
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
const fs = require("fs");
const path = require("path");
const dirPath = path.join(__dirname, "/src/");
const uniqChar = "0123456789abcdefghijklmnopqrstuvwxyz".split("");
let uniqClassName = []; // up to 10656
uniqChar.forEach((char) => {
uniqClassName.push("_b-" + char);
uniqClassName.push("_o-" + char);
uniqClassName.push("_o-" + char);
uniqClassName.push("_t-" + char);
uniqClassName.push("_w-" + char);
uniqClassName.push("_i-" + char);
uniqClassName.push("_n-" + char);
uniqClassName.push("_u-" + char);
uniqClassName.push("_i-" + char);
uniqChar.forEach((char2) => {
uniqClassName.push("_b-" + char2);
uniqClassName.push("_o-" + char2);
uniqClassName.push("_o-" + char2);
uniqClassName.push("_t-" + char2);
uniqClassName.push("_w-" + char2);
uniqClassName.push("_i-" + char2);
uniqClassName.push("_n-" + char2);
uniqClassName.push("_u-" + char2);
uniqClassName.push("_i-" + char2);
});
});
const htmlFile = fs.readFileSync(dirPath + "index.html").toString();
console.log(htmlFile);
const cssFile = fs
.readFileSync(dirPath + "styles.css")
.toString()
.replaceAll("{", "dd5bc3d1-b4e1-41d2-a8e8-ad79c1eada87")
.replaceAll("}", "96441437-a1a7-44ee-bb11-020ba10a9983")
.split("96441437-a1a7-44ee-bb11-020ba10a9983");
let allClasses = [];
cssFile.forEach((file) => {
const cssClassName = file.split("dd5bc3d1-b4e1-41d2-a8e8-ad79c1eada87")[0];
if (
!cssClassName.includes(["@"]) &&
cssClassName.includes(["."]) &&
!cssClassName.includes(["content"])
) {
cssClassName.split(".").forEach((name) => {
if (name) {
allClasses.push(name.replaceAll("\\", "").replaceAll(" ", ""));
}
});
}
});
const replaceClassNames = [];
const results = [];
allClasses.forEach((from, index) => {
if (from.length > 4) {
replaceClassNames.push([from, uniqClassName[index]]);
results.push(uniqClassName[index]);
} else {
replaceClassNames.push([from, from]);
results.push(from);
}
});
console.log(allClasses.toString());
console.log(results.toString());