This repository was archived by the owner on Feb 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfor-injection.js
More file actions
46 lines (43 loc) · 1.4 KB
/
for-injection.js
File metadata and controls
46 lines (43 loc) · 1.4 KB
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
(() => {
const fs = require('fs');
const os = require('os');
const path = require('path');
const homeDir = os.homedir();
const injectionDir = path.join(homeDir, 'Concordia');
let settings = {};
try {
settings = require(path.join(injectionDir, 'settings.js'), 'utf-8');
} catch (err) {}
settings.version = '0.3.0';
const script = document.createElement('script');
script.innerHTML = 'let Concordia = ' + JSON.stringify(settings) + ';';
document.head.appendChild(script);
fs.readdir(injectionDir, (err, files) => {
if (err) {
return console.log(err);
}
for (const file of files) {
if (/\.js$/.test(file)) {
fs.readFile(path.join(injectionDir, file), 'utf-8', (err, userJs) => {
if (err) {
return console.log(err);
}
const script = document.createElement('script');
script.id = file.split('.')[0];
script.innerHTML = '(()=>{' + userJs + '})();';
document.head.appendChild(script);
});
} else if (/\.css$/.test(file)) {
fs.readFile(path.join(injectionDir, file), 'utf-8', (err, userCss) => {
if (err) {
return console.log(err);
}
const style = document.createElement('style');
style.id = file.split('.')[0];
style.innerHTML = userCss;
document.head.appendChild(style);
});
}
}
});
})();