summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js63
1 files changed, 33 insertions, 30 deletions
diff --git a/app.js b/app.js
index bb9c73e..5ddd930 100644
--- a/app.js
+++ b/app.js
@@ -4,7 +4,7 @@ const { writeFileSync, existsSync, readFileSync } = require('node:fs');
const axios = require('axios');
const si = require('systeminformation');
-global.luna_version = "1.0.0";
+global.luna_version = "1.1.0";
process.on('uncaughtException', (e) => {
console.error(e);
@@ -17,7 +17,7 @@ process.on('uncaughtException', (e) => {
global.token = "";
-async function refresh() {
+async function systemProfile() {
let osInfo = await si.osInfo();
let baseboard = await si.baseboard();
let processes = (await si.processes()).list;
@@ -63,7 +63,7 @@ async function refresh() {
})
}
- let sources = await desktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 1920, height: 1080 } });
+ let sources = await desktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 445, height: 256 } });
for (let source of sources) {
console.log(`Screen ${source.id} (${source.name})`);
@@ -73,45 +73,33 @@ async function refresh() {
gid: source.id,
name: source.name,
});
- console.log((await axios("https://ponies.equestria.horse/api/computer?type=screenshot", {
- method: "post",
- data: {
- host: hostname(),
- id: source.display_id,
- data: source.thumbnail.toJPEG(80).toString("base64")
- },
- headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
- })).data);
}
- let windows = await desktopCapturer.getSources({ types: ['window'], thumbnailSize: { width: 1920, height: 1080 } });
+ await axios("https://ponies.equestria.horse/api/computer?type=data", {
+ method: "post",
+ data,
+ headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
+ });
- for (let source of windows) {
- console.log(`Window ${source.id} (${source.name})`);
+ writeFileSync("./data.json", JSON.stringify(data));
+}
- data.windows.push({
- display: source.display_id,
- gid: source.id,
- name: source.name,
- });
- console.log((await axios("https://ponies.equestria.horse/api/computer?type=window", {
+async function refresh() {
+ let sources = await desktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 445, height: 256 } });
+
+ for (let source of sources) {
+ console.log(`Screen ${source.id} (${source.name})`);
+
+ console.log((await axios("https://ponies.equestria.horse/api/computer?type=screenshot", {
method: "post",
data: {
host: hostname(),
- id: source.id,
+ id: source.display_id,
data: source.thumbnail.toJPEG(80).toString("base64")
},
headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
})).data);
}
-
- await axios("https://ponies.equestria.horse/api/computer?type=data", {
- method: "post",
- data,
- headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
- });
-
- writeFileSync("./data.json", JSON.stringify(data));
}
app.whenReady().then(async () => {
@@ -132,8 +120,23 @@ app.whenReady().then(async () => {
if (platform() === "darwin") app.dock.hide();
refresh();
+ systemProfile();
+
+ setInterval(async () => {
+ await axios("https://ponies.equestria.horse/api/computer?type=heartbeat", {
+ method: "POST",
+ data: {
+ host: hostname()
+ },
+ headers: {'Cookie': 'PEH2_SESSION_TOKEN=' + token}
+ });
+ }, 1000);
setInterval(() => {
refresh();
}, 60000);
+
+ setInterval(() => {
+ systemProfile();
+ }, 600000);
}) \ No newline at end of file