Created
January 7, 2019 21:25
-
-
Save vviikk/c47cd9c0af7fa3eabe4e9c378419545a to your computer and use it in GitHub Desktop.
Revisions
-
vviikk created this gist
Jan 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <html> <head> <style> </style> </head> <body> <form name="form"> <input name="input" placeholder="https://messenger.com/" value="https://messenger.com"> <button type="submit">submit</button> </form> <div class="tabs"> </div> <script type="text/javascript"> require('./renderer.js') </script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ const {app, BrowserWindow, BrowserView} = require('electron') app.on('ready', createWindow) const init = config => { } function createWindow(){ let win = new BrowserWindow({ width: 1000, height: 600, height: 600, "node-integration": "iframe", // and this line "web-preferences": { "web-security": false, "nodeIntegration": false, } }) win.on('closed', () => { win = null }) ///ipcMain.send() // In the main process. //win = null // }) const { BrowserView } = require('electron') const createView = (url, title = '', setAsMain = false) => { const view = new BrowserView({ webPreferences: { nodeIntegration: false } }) if (setAsMain) win.setBrowserView(view) view.setBounds({ x: 0, y: 100, width: 1000, height: 550 }) console.log('creating'+ url) view.webContents.loadURL(url) } //const views = let views; const ipcMain = require('electron').ipcMain; console.log('waiting for SITES') ipcMain.on('SITES', function(event, tabs) { //console.log('URL' + data); views = tabs.map(({url}) => createView(url, '', true)) }); win.webContents.openDevTools() // Load a remote URL //win.loadURL('https://github.com') // Or load a local HTML file win.loadURL(`file://${__dirname}/index.html`) /*win.webContents.session.webRequest.onHeadersReceived({}, (d, c) => { if(d.responseHeaders['x-frame-options'] || d.responseHeaders['X-Frame-Options']){ delete d.responseHeaders['x-frame-options'] delete d.responseHeaders['X-Frame-Options'] } c({cancel: false, responseHeaders: d.responseHeaders}) })*/ } //app.commandLine.appendSwitch('disable-web-security') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ const {app, BrowserWindow, BrowserView} = require('electron').remote let webviews = document.querySelector(".webviews") let tabs = document.querySelector(".tabs") document.getElementsByTagName("form")[0].onsubmit = function(event){ //createWebview(form.input.value) createBrowserView(form.input.value) return false; } function createBrowserView(url, title='', setAsMain = false){ const ipcRenderer = require('electron').ipcRenderer; const apps = [ { url: 'https://google.com' }, { url: 'https://web.whatsapp.com' }, { url: 'https://messenger.com' } ] ipcRenderer.send('SITES',apps) debugger; console.log('sent') //if (setAsMain) win.setBrowserView(view) //view.webContents.loadURL(url) //debugger apps.forEach(app, idx => { debugger let tab = document.createElement("div") tab.textContent = app.url //tab.target = webview tabs.appendChild(tab) console.log(idx) }) myNotification.show() console.log('asd') //const views = tabs.map(({url}) => createView(url, '', true)) } function createBrowserWindow(url){ let win = new BrowserWindow({ width: 800, height: 600, y: 100, x: 100, webPreferences: { webSecurity: false, nodeIntegration: false } }) win.setMenu(null) win.on('closed', () => { win = null }) view = new BrowserView({ webPreferences: { nodeIntegration: false } }) win.webContents.openDevTools() // Load a remote URL win.loadURL(url) }