|
| 1 | +const { app, BrowserWindow } = require("electron"); |
| 2 | +const path = require("path"); |
| 3 | +const fs = require("fs"); |
| 4 | +const { Menu } = require('electron') |
| 5 | +const isMac = process.platform === 'darwin' |
| 6 | +const template = [ |
| 7 | + // { role: 'appMenu' } |
| 8 | + ...(isMac ? [{ |
| 9 | + label: app.name, |
| 10 | + submenu: [ |
| 11 | + { role: 'about' }, |
| 12 | + { type: 'separator' }, |
| 13 | + { role: 'services' }, |
| 14 | + { type: 'separator' }, |
| 15 | + { role: 'hide' }, |
| 16 | + { role: 'hideOthers' }, |
| 17 | + { role: 'unhide' }, |
| 18 | + { type: 'separator' }, |
| 19 | + { role: 'quit' } |
| 20 | + ] |
| 21 | + }] : []), |
| 22 | + // { role: 'fileMenu' } |
| 23 | + { |
| 24 | + label: 'File', |
| 25 | + submenu: [ |
| 26 | + isMac ? { role: 'close' } : { role: 'quit' } |
| 27 | + ] |
| 28 | + }, |
| 29 | + // { role: 'editMenu' } |
| 30 | + { |
| 31 | + label: 'Edit', |
| 32 | + submenu: [ |
| 33 | + { role: 'undo' }, |
| 34 | + { role: 'redo' }, |
| 35 | + { type: 'separator' }, |
| 36 | + { role: 'cut' }, |
| 37 | + { role: 'copy' }, |
| 38 | + { role: 'paste' }, |
| 39 | + ...(isMac ? [ |
| 40 | + { role: 'pasteAndMatchStyle' }, |
| 41 | + { role: 'delete' }, |
| 42 | + { role: 'selectAll' }, |
| 43 | + { type: 'separator' }, |
| 44 | + { |
| 45 | + label: 'Speech', |
| 46 | + submenu: [ |
| 47 | + { role: 'startSpeaking' }, |
| 48 | + { role: 'stopSpeaking' } |
| 49 | + ] |
| 50 | + } |
| 51 | + ] : [ |
| 52 | + { role: 'delete' }, |
| 53 | + { type: 'separator' }, |
| 54 | + { role: 'selectAll' } |
| 55 | + ]) |
| 56 | + ] |
| 57 | + }, |
| 58 | + // { role: 'viewMenu' } |
| 59 | + { |
| 60 | + label: 'View', |
| 61 | + submenu: [ |
| 62 | + { role: 'reload' }, |
| 63 | + { role: 'forceReload' }, |
| 64 | + { role: 'toggleDevTools' }, |
| 65 | + { type: 'separator' }, |
| 66 | + { role: 'resetZoom' }, |
| 67 | + { role: 'zoomIn' }, |
| 68 | + { role: 'zoomOut' }, |
| 69 | + { type: 'separator' }, |
| 70 | + { role: 'togglefullscreen' } |
| 71 | + ] |
| 72 | + }, |
| 73 | +] |
| 74 | +const menu = Menu.buildFromTemplate(template) |
| 75 | + |
| 76 | +let win; |
| 77 | +let pluginName; |
| 78 | + |
| 79 | +switch (process.platform) { |
| 80 | + case "win32": |
| 81 | + pluginName = process.arch == 'x64' ? 'x64/pepflashplayer.dll' : 'x32/pepflashplayer32.dll'; |
| 82 | + break; |
| 83 | + case 'linux': |
| 84 | + pluginName = 'libpepflashplayer.so' |
| 85 | + break; |
| 86 | + default: |
| 87 | + pluginName = 'x64/pepflashplayer.dll'; |
| 88 | + break; |
| 89 | +} |
| 90 | + |
| 91 | +app.commandLine.appendSwitch( |
| 92 | + "ppapi-flash-path", |
| 93 | + path.join(__dirname + pluginName) |
| 94 | +); |
| 95 | +app.commandLine.appendSwitch("ppapi-flash-version", "32.0.0.371"); |
| 96 | + |
| 97 | + |
| 98 | +function createWindow() { |
| 99 | + Menu.setApplicationMenu(menu) |
| 100 | + win = new BrowserWindow({ |
| 101 | + webPreferences: { |
| 102 | + nodeIntegration: false, |
| 103 | + contextIsolation: false, |
| 104 | + plugins: true, |
| 105 | + }, |
| 106 | + }); |
| 107 | + |
| 108 | + |
| 109 | + win.maximize(); |
| 110 | +win.loadURL("https://sploder.us.to/play.php");} |
| 111 | + |
| 112 | +app.whenReady().then(() => { |
| 113 | + createWindow(); |
| 114 | + |
| 115 | + app.on("activate", function () { |
| 116 | + if (BrowserWindow.getAllWindows().length === 0) createWindow(); |
| 117 | + }); |
| 118 | +}); |
| 119 | + |
| 120 | +app.on("window-all-closed", function () { |
| 121 | + if (process.platform !== "darwin") app.quit(); |
| 122 | +}); |
| 123 | + |
| 124 | + |
| 125 | +const clientId = '915116210570539058'; |
| 126 | +const rpc = new DiscordRPC.Client({ transport: 'ipc' }); |
| 127 | +const startTimestamp = new Date(); |
| 128 | + |
| 129 | +async function setActivity() { |
| 130 | + if (!rpc || !win) { |
| 131 | + return; |
| 132 | + } |
| 133 | + const boops = await win.webContents.executeJavaScript('window.boops'); |
| 134 | + |
| 135 | + // You'll need to have snek_large and snek_small assets uploaded to |
| 136 | + // https://discord.com/developers/applications/<application_id>/rich-presence/assets |
| 137 | + rpc.setActivity({ |
| 138 | + details: `${boops}`, |
| 139 | + startTimestamp, |
| 140 | + largeImageKey: 'icon', |
| 141 | + largeImageText: `${boops}` |
| 142 | + }); |
| 143 | +} |
| 144 | + |
| 145 | +rpc.on('ready', () => { |
| 146 | + setActivity(); |
| 147 | + |
| 148 | + // activity can only be set every 15 seconds |
| 149 | + setInterval(() => { |
| 150 | + setActivity(); |
| 151 | + }, 15e3); |
| 152 | +}); |
| 153 | + |
| 154 | +rpc.login({ clientId }).catch(console.error); |
| 155 | + |
0 commit comments