-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
111 lines (96 loc) · 2.11 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
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
102
103
104
105
106
107
108
109
110
111
'use strict';
const { Tray, app, BrowserWindow, globalShortcut, dialog, Menu } = require('electron');
let mainWindow = null;
let contextMenu = null;
function createWindow() {
mainWindow = new BrowserWindow({
title: "Messages for web",
width: 480,
height: 720,
resizable: false,
backgroundColor: '#000000',
frame: true,
fullScreen: true,
titleBarStyle: 'hidden',
transparent: false,
webPreferences: {
//devTools: false,
preload: __dirname + '/renderer.js'
}
});
mainWindow.loadURL("https://messages.google.com/web/authentication");
mainWindow.setMenu(null);
mainWindow.on('closed', () => {
mainWindow = null;
});
mainWindow.on('maximize', function(event){
event.preventDefault();
mainWindow.unmaximize();
});
var tray = new Tray(__dirname + "/messages_96dp.png");
mainWindow.on('close', function (event) {
if (!app.isQuiting){
event.preventDefault();
mainWindow.hide();
}
return false;
});
contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: function(){
mainWindow.show();
} },
{ label: 'Quit', click: function(){
app.isQuiting = true;
app.quit();
} }
]);
tray.setContextMenu(contextMenu);
tray.setToolTip('Messages for web');
tray.on("click", () => {
mainWindow.show()
});
}
var exitDialogExists = false;
function exit() {
if (exitDialogExists) return null;
exitDialogExists = true;
dialog.showMessageBox(null, {
type: "warning",
title: "Confirm",
message: "Are you sure you want to exit?",
buttons: [
"No",
"Yes"
],
defaultId: 0
}, (response) => {
exitDialogExists = false;
if (response > 0) {
app.quit();
}
});
}
app.on('ready', createWindow);
app.on('ready', () => {
//globalShortcut.register('CommandOrControl+Shift+I', () => {
// return false;
//});
mainWindow.setTitle("Messages");
});
app.on('window-all-closed', () => {
app.quit();
});
let first_ = false;
app.on('browser-window-created', (ev, win) => {
if (first_) {
win.close();
} else {
first_ = true;
return;
}
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});