From c3d6eced6c349790c7a7dc1f6bf41accb2a73f72 Mon Sep 17 00:00:00 2001 From: Oj Date: Thu, 21 Apr 2022 20:53:20 +0100 Subject: [PATCH] [JsInject] Initial Add --- src/bootstrap.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index d592828..c7b7756 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -38,17 +38,23 @@ const autoStart = require('./autoStart'); let desktopCore; const startCore = () => { + if (oaConfig.js) session.defaultSession.webRequest.onHeadersReceived((d, cb) => { + delete d.responseHeaders['content-security-policy']; + cb(d); + }); + app.on('browser-window-created', (e, bw) => { // Main window injection bw.webContents.on('dom-ready', () => { splash.pageReady(); // Override Core's pageReady with our own on dom-ready to show main window earlier const [ channel, hash ] = oaVersion.split('-'); // Split via - - bw.webContents.executeJavaScript( - readFileSync(join(__dirname, 'mainWindow.js'), 'utf8') - .replaceAll('', channel) - .replaceAll('', hash || 'custom') - ); + const exec = bw.webContents.executeJavaScript; + exec(readFileSync(join(__dirname, 'mainWindow.js'), 'utf8') + .replaceAll('', channel) + .replaceAll('', hash || 'custom')); + + if (oaConfig.js) exec(oaConfig.js); }); });