forked from deso-protocol/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
65 lines (51 loc) · 1.33 KB
/
main.js
File metadata and controls
65 lines (51 loc) · 1.33 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
const { app, BrowserWindow, shell } = require('electron')
// setup auto updates
require('update-electron-app')()
function createWindow () {
const win = new BrowserWindow({
width: 1440,
height: 900,
webPreferences: {
devTools: true,
contextIsolation: true,
sandbox: true,
}
})
win.loadURL("https://bitclout.com");
win.on('page-title-updated', (evt) => {
evt.preventDefault();
});
win.webContents.on('will-navigate', function(event, url) {
handleNavigate(win, event, url);
});
win.webContents.on('new-window', function(event, url) {
handleNavigate(win, event, url);
});
}
function handleNavigate(win, event, url) {
win.setTitle(url);
// Allow bitclout-approved URLs
if (url.startsWith('https://bitclout.com/') || url.startsWith('https://identity.bitclout.com/')) {
return;
}
event.preventDefault();
// Only allow URLs and emails
if(!url.startsWith('https://') && !url.startsWith('http://') && !url.startsWith('mailto:')) {
return;
}
// Open https links in external browser
shell.openExternal(url);
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})