-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
101 lines (72 loc) · 2.36 KB
/
server.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const express = require('express');
const { exec } = require('child_process');
const path = require('path');
const fs = require('fs');
const app = express();
const port = 8008; //change port if you want to
let isSorting = false;
app.use(express.json());
// Serve static files from the current directory
app.use(express.static(__dirname));
exec(`cscript //nologo "${"status.vbs"}"`)
function BrowserStats() {
exec('powershell.exe -ExecutionPolicy Bypass -File "./scripts/taskManager/usage.ps1"');
}
setInterval(BrowserStats, 2177);
function autoSort() {
if(isSorting) return;
isSorting = true;
fs.readFile('./scripts/sortDownloads/sort.txt', 'utf8', (err, data) => {
const toggle = data;
if(toggle === 'on') {
fs.readFile('./scripts/taskManager/browser_usage.txt', 'utf8', (err, data1) => {
if(!data1.trim()) return;
const usage = data1.split('\n');
if(usage[4].trim() == 'Downloads: True') {
setTimeout(() => {
exec(`cscript //nologo "${"scripts/sortDownloads/autoSort.vbs"}"`);
isSorting = false;
}, 50000);
}
else {
isSorting = false;
}
});
}
});
}
setInterval(() => {
if(!isSorting) autoSort();
}, 10000);
app.post('/scripts', (req) => {
const vbscriptPath = req.body.vbscriptPath;
const absolutePath = path.resolve(vbscriptPath);
exec(`cscript //nologo "${absolutePath}"`);
});
app.get('/browser-info', (req) => {
const browser = req.query.browser;
fs.readFile('status.txt', 'utf8', (err, data) => {
const lines = data.split('\n');
lines[5] = browser;
fs.writeFile('status.txt', lines.join('\n'), (err) => {})
});
});
app.get('/cmd', (req) => {
const command = req.query.command;
fs.writeFile('./scripts/cmd/command.txt', command, (err) => {})
const absolutePath = path.resolve("./scripts/cmd/cmd.vbs");
exec(`cscript //nologo "${absolutePath}"`);
});
app.get('/auto-sort', (req) => {
const toggle = req.query.toggle;
fs.writeFile('./scripts/sortDownloads/sort.txt', toggle, (err) => {})
});
app.get('/search', async (req, res) => {
let input = req.query.q;
const response = await fetch(`https://duckduckgo.com/ac/?q=${encodeURIComponent(input)}`);
const data = await response.json();
res.json(data);
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});