|
|
@ -288,8 +288,8 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
webview.addEventListener("did-start-loading", function() { |
|
|
|
webview.addEventListener("did-start-loading", function() { |
|
|
|
console.info('Start loading...', me.src); |
|
|
|
console.info('Start loading...', me.src); |
|
|
|
|
|
|
|
|
|
|
|
webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => { |
|
|
|
require('electron').remote.webContents.fromId(webview.getWebContentsId()).session.webRequest.onBeforeSendHeaders((details, callback) => { |
|
|
|
Rambox.app.config.googleURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'}) |
|
|
|
Rambox.app.config.googleURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'}); |
|
|
|
callback({ cancel: false, requestHeaders: details.requestHeaders }); |
|
|
|
callback({ cancel: false, requestHeaders: details.requestHeaders }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -504,7 +504,6 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
require('electron').shell.openExternal(e.url); |
|
|
|
require('electron').shell.openExternal(e.url); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -551,8 +550,8 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
js_inject += 'document.body.scrollTop=0;'; |
|
|
|
js_inject += 'document.body.scrollTop=0;'; |
|
|
|
|
|
|
|
|
|
|
|
// Handles Certificate Errors
|
|
|
|
// Handles Certificate Errors
|
|
|
|
webview.getWebContents().on('certificate-error', function(event, url, error, certificate, callback) { |
|
|
|
require('electron').remote.webContents.fromId(webview.getWebContentsId()).on('certificate-error', function(event, url, error, certificate, callback) { |
|
|
|
if ( me.record.get('trust') ) { |
|
|
|
if (me.record.get('trust')) { |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
|
callback(true); |
|
|
|
callback(true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -562,25 +561,25 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
me.down('statusbar').keep = true; |
|
|
|
me.down('statusbar').keep = true; |
|
|
|
me.down('statusbar').show(); |
|
|
|
me.down('statusbar').show(); |
|
|
|
me.down('statusbar').setStatus({ |
|
|
|
me.down('statusbar').setStatus({ |
|
|
|
text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning' |
|
|
|
text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning', |
|
|
|
}); |
|
|
|
}); |
|
|
|
me.down('statusbar').down('button').show(); |
|
|
|
me.down('statusbar').down('button').show(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (!eventsOnDom) { |
|
|
|
if (!eventsOnDom) { |
|
|
|
webview.getWebContents().on('before-input-event', (event, input) => { |
|
|
|
require('electron').remote.webContents.fromId(webview.getWebContentsId()).on('before-input-event', (event, input) => { |
|
|
|
if (input.type !== 'keyDown') return; |
|
|
|
if (input.type !== 'keyDown') return; |
|
|
|
|
|
|
|
|
|
|
|
var modifiers = []; |
|
|
|
var modifiers = []; |
|
|
|
if ( input.shift ) modifiers.push('shift'); |
|
|
|
if (input.shift) modifiers.push('shift'); |
|
|
|
if ( input.control ) modifiers.push('control'); |
|
|
|
if (input.control) modifiers.push('control'); |
|
|
|
if ( input.alt ) modifiers.push('alt'); |
|
|
|
if (input.alt) modifiers.push('alt'); |
|
|
|
if ( input.meta ) modifiers.push('meta'); |
|
|
|
if (input.meta) modifiers.push('meta'); |
|
|
|
if ( input.isAutoRepeat ) modifiers.push('isAutoRepeat'); |
|
|
|
if (input.isAutoRepeat) modifiers.push('isAutoRepeat'); |
|
|
|
|
|
|
|
|
|
|
|
if ( input.key === 'Tab' && !(modifiers && modifiers.length) ) return; |
|
|
|
if (input.key === 'Tab' && !(modifiers && modifiers.length)) return; |
|
|
|
|
|
|
|
|
|
|
|
// Maps special keys to fire the correct event in Mac OS
|
|
|
|
// Maps special keys to fire the correct event in Mac OS
|
|
|
|
if ( require('electron').remote.process.platform === 'darwin' ) { |
|
|
|
if (require('electron').remote.process.platform === 'darwin') { |
|
|
|
var keys = []; |
|
|
|
var keys = []; |
|
|
|
keys['ƒ'] = 'f'; // Search
|
|
|
|
keys['ƒ'] = 'f'; // Search
|
|
|
|
keys[' '] = 'l'; // Lock
|
|
|
|
keys[' '] = 'l'; // Lock
|
|
|
@ -589,14 +588,22 @@ Ext.define('Rambox.ux.WebView',{ |
|
|
|
input.key = keys[input.key] ? keys[input.key] : input.key; |
|
|
|
input.key = keys[input.key] ? keys[input.key] : input.key; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( input.key === 'F11' || input.key === 'a' || input.key === 'A' || input.key === 'F12' || input.key === 'q' || (input.key === 'F1' && modifiers.includes('control'))) return; |
|
|
|
if ( |
|
|
|
|
|
|
|
input.key === 'F11' || |
|
|
|
|
|
|
|
input.key === 'a' || |
|
|
|
|
|
|
|
input.key === 'A' || |
|
|
|
|
|
|
|
input.key === 'F12' || |
|
|
|
|
|
|
|
input.key === 'q' || |
|
|
|
|
|
|
|
(input.key === 'F1' && modifiers.includes('control')) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
require('electron').remote.getCurrentWebContents().sendInputEvent({ |
|
|
|
require('electron').remote.getCurrentWebContents().sendInputEvent({ |
|
|
|
type: input.type, |
|
|
|
type: input.type, |
|
|
|
keyCode: input.key, |
|
|
|
keyCode: input.key, |
|
|
|
modifiers: modifiers |
|
|
|
modifiers: modifiers, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
eventsOnDom = true; |
|
|
|
eventsOnDom = true; |
|
|
|
|
|
|
|
|
|
|
|
Rambox.app.config.googleURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() }) |
|
|
|
Rambox.app.config.googleURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() }) |
|
|
|