-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
87 lines (72 loc) · 2.8 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
const {app, BrowserWindow, dialog} = require('electron');
const isDev = require('electron-is-dev');
const { autoUpdater } = require("electron-updater");
const DiscordRPC = require('discord-rpc');
//const {app, BrowserWindow} = require('electron');
const path = require('path');
let pluginName
switch (process.platform) {
case 'win32':
pluginName = 'flash/pepflashplayer64_32_0_0_303.dll'
break
case 'darwin':
pluginName = 'flash/PepperFlashPlayer.plugin'
break
case 'linux':
pluginName = 'flash/libpepflashplayer.so'
break
}
app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, pluginName));
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
autoUpdater.checkForUpdatesAndNotify();
let mainWindow;
function clearCache() {
mainWindow.webContents.session.clearCache();
}
function createWindow () {
mainWindow = new BrowserWindow({
width: 1280,
height: 720,
title: "Connecting...",
icon: __dirname + '/favicon.ico',
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
plugins: true
}
});
mainWindow.setMenu(null);
clearCache();
mainWindow.loadURL('https://waddlepenguins.tk/launcher/'); // Replace https://waddlepenguins.tk/launcher/ with your play page (ex. play.your.cpps) or a landing page like a home page.
// RICH PRESENCE START
// Change 796476157415522354 with your own application ID. You can register an application at https://discord.com/developers/applications. Remember to change waddlepenguins.tk in details. Otherwise your Discord RPC will show it as the detail link.
const clientId = '796476157415522354'; DiscordRPC.register(clientId); const rpc = new DiscordRPC.Client({ transport: 'ipc' }); const startTimestamp = new Date();
rpc.on('ready', () => {
rpc.setActivity({
details: `waddlepenguins.tk`,
state: `Client - Made by AltoDev.`,
startTimestamp,
largeImageKey: `main-logo`//,
//largeImageText: "LARGE IMAGE TEXT",
//smallImageKey: "favicon_512",
//smallImageText: "SMALL IMAGE TEXT"
});
});
rpc.login({ clientId }).catch(console.error);
//mainWindow.webContents.openDevTools();
mainWindow.on('closed', function () {
mainWindow = null
});
}
app.on('ready', createWindow);
app.on('window-all-closed', function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
});
setInterval(clearCache, 1000*60*5);