-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
112 lines (89 loc) · 3.08 KB
/
main.js
File metadata and controls
112 lines (89 loc) · 3.08 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
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
112
const { app, BrowserWindow, Menu, Tray, shell } = require('electron');
const path = require('path');
let mainWindow;
let tray = null;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: false,
contextIsolation: true, // Enable context isolation for security
// preload: path.join(__dirname, 'preload.js') // Use a preload script
webviewTag: true,
},
icon: path.join(__dirname, './assets/icons/four-arrows-48.png')
});
loadTelegram(); // Load Telegram by default
const menu = Menu.buildFromTemplate([
{
label: 'Chat Services',
submenu: [
{ label: 'Telegram', click: () => loadTelegram() },
{ label: 'Discord', click: () => loadDiscord() },
{ label: 'Messages', click: () => loadMessages() },
{ label: 'Facebook', click: () => loadFacebook() },
{ label: 'Matrix', click: () => loadMatrix() },
{ label: 'Lemmy', click: () => loadLemmy() },
{ label: 'Mastodon', click: () => loadMastodon() },
{ label: 'Notion', click: () => loadNotion() },
{ label: 'Quit', click: () => app.quit() }
]
}
]);
Menu.setApplicationMenu(menu);
createTray();
mainWindow.webContents.on('new-window', function(event, url) {
event.preventDefault(); // Prevent opening new Electron window
shell.openExternal(url); // Open URL in default browser
});
mainWindow.loadFile('src/index.html');
// You will need to replace 'electron' with whatever you named the exposed object in the preload script.
}
function loadTelegram() {
mainWindow.loadURL('https://web.telegram.org/');
}
function loadDiscord() {
mainWindow.loadURL('https://discord.com/login');
}
function loadMessages() {
mainWindow.loadURL('https://messages.google.com/web/');
};
function loadFacebook() {
mainWindow.loadURL('https://www.messenger.com/login/')
};
function loadMatrix() {
mainWindow.loadURL('https://riot.im/app')
};
function loadLemmy() {
mainWindow.loadURL('https://programming.dev/')
};
function loadMastodon() {
mainWindow.loadURL('https://mastodon.social/home')
};
function loadNotion() {
mainWindow.loadURL('https://notion.so')
};
function createTray() {
tray = new Tray(path.join(__dirname, './assets/icons/four-arrows-22.png'));
const contextMenu = Menu.buildFromTemplate([
{ label: 'Open', click: () => mainWindow.show() },
{ label: 'Quit', click: () => app.quit() }
]);
tray.setToolTip('MegaChat');
tray.setContextMenu(contextMenu);
tray.on('click', () => {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
});
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});