| 28 | |
| 29 | let desktopCore; |
| 30 | const startCore = () => { |
| 31 | if (oaConfig.js || oaConfig.css) session.defaultSession.webRequest.onHeadersReceived((d, cb) => { |
| 32 | delete d.responseHeaders['content-security-policy']; |
| 33 | cb(d); |
| 34 | }); |
| 35 | |
| 36 | app.on('browser-window-created', (e, bw) => { // Main window injection |
| 37 | bw.webContents.on('dom-ready', () => { |
| 38 | if (!bw.resizable) return; // Main window only |
| 39 | splash.pageReady(); // Override Core's pageReady with our own on dom-ready to show main window earlier |
| 40 | |
| 41 | const [ channel = '', hash = '' ] = oaVersion.split('-'); // Split via - |
| 42 | |
| 43 | bw.webContents.executeJavaScript(readFileSync(join(__dirname, 'mainWindow.js'), 'utf8') |
| 44 | .replaceAll('<hash>', hash).replaceAll('<channel>', channel === 'nightly' ? '' : channel) |
| 45 | .replaceAll('<notrack>', oaConfig.noTrack !== false) |
| 46 | .replaceAll('<domopt>', oaConfig.domOptimizer !== false) |
| 47 | .replace('<css>', (oaConfig.css ?? '').replaceAll('\\', '\\\\').replaceAll('`', '\\`'))); |
| 48 | |
| 49 | if (oaConfig.js) bw.webContents.executeJavaScript(oaConfig.js); |
| 50 | }); |
| 51 | }); |
| 52 | |
| 53 | desktopCore = require('discord_desktop_core'); |
| 54 | |
| 55 | const desktopTTI = new Proxy({}, { |
| 56 | get: (target, prop) => { |
| 57 | if (typeof target[prop] === 'undefined') { |
| 58 | target[prop] = () => { }; |
| 59 | } |
| 60 | return target[prop]; |
| 61 | } |
| 62 | }); |
| 63 | |
| 64 | desktopCore.startup({ |
| 65 | splashScreen: splash, |
| 66 | moduleUpdater, |
| 67 | buildInfo, |
| 68 | Constants, |
| 69 | updater, |
| 70 | autoStart, |
| 71 | |
| 72 | // Just requires |
| 73 | appSettings: require('./appSettings'), |
| 74 | paths: require('./paths'), |
| 75 | |
| 76 | // Stubs |
| 77 | GPUSettings: { |
| 78 | replace: () => {} |
| 79 | }, |
| 80 | crashReporterSetup: { |
| 81 | isInitialized: () => true, |
| 82 | getGlobalSentry: () => null, |
| 83 | metadata: {} |
| 84 | }, |
| 85 | logger: { |
| 86 | initializeLogging: () => {}, |
| 87 | ipcMainRendererLogger: () => {} |