This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
67 lines (53 loc) · 1.88 KB
/
main.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
const {app, Tray, Menu, BrowserWindow} = require('electron');
const path = require('path');
const request = require('request');
const open = require('openurl').open;
const parse = require('node-html-parser').parse;
const iconPath = path.join(__dirname, 'icon.png');
let appIcon = null;
let win = null;
var DATA_URL = "http://jiofi.local.html";
var updateData = function(){
request(DATA_URL, (err, res, body) => {
if(err) { return console.log(err);}
var root = parse(body);
var batteryPercentage = root.querySelector("#batterylevel").attributes.value;
var noOfClient = root.querySelector('#noOfClient').attributes.value;
var signalStrength = root.querySelector("#signalstrength").attributes.value;
var batteryStatus = root.querySelector('#batterystatus').attributes.value;
var chargeIcon = ""
if ( batteryStatus == "Charging" ) {
chargeIcon = " ⚡";
}
var message = "🔋"+ chargeIcon+ " : "+ batteryPercentage
+ "\n📱 : " + noOfClient
+ "\n📶 : " + signalStrength;
appIcon.setToolTip(message);
});
}
app.on('ready', function(){
win = new BrowserWindow({show: false});
appIcon = new Tray(iconPath);
var contextMenu = Menu.buildFromTemplate([
{
label: 'JioFi Status',
enabled: false
},
{
label: 'About',
click: function() {
open("https://anandu.net/")
}
},
{
label: 'Quit',
// accelerator: 'Ctrl+W',
// selector: 'terminate:',
click: app.quit
}
]);
appIcon.setToolTip("Loading");
appIcon.setContextMenu(contextMenu);
updateData();
setInterval(updateData, 10000)
});