This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
forked from SrWither/DiscordBSD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
91 lines (75 loc) · 2.16 KB
/
index.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
const { app, BrowserWindow, Tray, Menu, desktopCapturer, shell } = require('electron');
const path = require('path');
const userAgent =
"Mozilla/5.0 (X11; FreeBSD amd64 13982.82.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.157 Safari/537.36";
const contextMenu = require('electron-context-menu');
contextMenu({
showSaveImageAs: true,
showSaveImage: true,
showSaveLinkAs: true,
showCopyImageAddress: true
});
// Disable Menu
Menu.setApplicationMenu(false)
// Win - Icons Var
var splash
var win = '',
appIcon = null,
iconpath = path.join(__dirname, 'discord.png');
// Create WIndow
function createWindow() {
// New Window
win = new BrowserWindow({
width: 1280,
height: 720,
show: false,
// frame: false, // Disable appmenu
webPreferences: {
nodeIntegration: true
},
icon: path.join(__dirname, 'discord.png'),
title: 'Discord',
});
// Tray
var contextMenu = Menu.buildFromTemplate([
{
label: 'Open Discord', click: function () {
win.show()
}
},
{
label: 'Quit', click: function () {
app.isQuiting = true;
app.quit();
}
}
]);
appIcon = new Tray(iconpath);
appIcon.setContextMenu(contextMenu);
// Close Window
win.on('close', function (event) {
if (!app.isQuiting) {
event.preventDefault();
win.hide();
}
return false;
});
// 516 × 360
//Splash
splash = new BrowserWindow({ width: 516, height: 360, transparent: true, frame: false, alwaysOnTop: true });
splash.loadFile("boot.html");
// Load Discord
win.webContents.setUserAgent(userAgent);
win.webContents.setWindowOpenHandler(({ url }) => {
// config.fileProtocol is my custom file protocol
// open url in a browser and prevent default
shell.openExternal(url);
return { action: 'deny' };
});
win.loadURL('https://discord.com/app');
win.once('ready-to-show', () => {
splash.destroy();
win.show();
});
}
app.on('ready', createWindow);