Browse Source

Strip userAgent of Electron/app name. Remove default userAgent overrides.

I've kept around an entire custom User Agent builder, just in case.

Mostly fixes #75.
Everything else is due to them expecting stable Chrome
instead of whatever Electron stable is using.
It'll be easier to add a version override specifically for that now.
pull/3202/head
TheGoddessInari 6 years ago
parent
commit
4aab913087
No known key found for this signature in database
GPG Key ID: 1209B1B7632D69A
  1. 6
      app/store/ServicesList.js
  2. 126
      app/ux/WebView.js

6
app/store/ServicesList.js

@ -29,7 +29,6 @@ Ext.define('Rambox.store.ServicesList', {
,url: 'https://web.whatsapp.com/'
,type: 'messaging'
,js_unread: `let checkUnread=()=>{const elements=document.querySelectorAll(".CxUIE, .unread");let count=0;for(let i of elements)0===i.querySelectorAll('*[data-icon="muted"]').length&&count++;rambox.updateBadge(count)};setInterval(checkUnread,1e3);let unregister_queue=[];navigator.serviceWorker.getRegistrations().then(registrations=>{for(const registration of registrations)unregister_queue.push(registration.unregister());return unregister_queue}).then(queue=>{}).catch(err=>{});`
,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36'
},
{
id: 'slack'
@ -57,7 +56,6 @@ Ext.define('Rambox.store.ServicesList', {
,type: 'messaging'
,titleBlink: true
,note: 'To enable desktop notifications, you have to go to Options inside Messenger.'
,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36'
},
{
id: 'skype'
@ -66,7 +64,6 @@ Ext.define('Rambox.store.ServicesList', {
,description: locale['services[4]']
,url: 'https://web.skype.com/'
,type: 'messaging'
,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36'
,note: 'Text and Audio calls are supported only. <a href="https://github.com/TheGoddessInari/rambox/wiki/Skype" target="_blank">Read more...</a>'
},
{
@ -185,7 +182,6 @@ Ext.define('Rambox.store.ServicesList', {
,titleBlink: true
,js_unread: `let getAlertCount=badges=>{let alerts=0;for(const badge of badges)if(badge&&badge.childNodes&&badge.childNodes.length>0){const count=parseInt(badge.childNodes[0].nodeValue,10);alerts+=count.isNaN?1:count}else alerts++;return alerts},checkUnread=()=>{let direct=0,indirect=document.getElementsByClassName("container-2td-dC unread-2OHH1w").length;const guildDirect=document.getElementsByClassName("wrapper-232cHJ badge-3dItlm"),directMessages=document.getElementsByClassName("wrapper-232cHJ badge-2_fwUZ");direct+=getAlertCount(guildDirect),direct+=getAlertCount(directMessages),indirect+=document.getElementsByClassName("unread-1Dp-OI").length,rambox.updateBadge(direct,indirect)};setInterval(checkUnread,3e3);`
,note: 'To enable desktop notifications, you have to go to Options inside Discord.'
,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36'
},
{
id: 'outlook'
@ -215,7 +211,6 @@ Ext.define('Rambox.store.ServicesList', {
,url: 'https://mail.yahoo.com/'
,type: 'email'
,note: 'To enable desktop notifications, you have to go to Options inside Yahoo! Mail.'
,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36'
},
{
id: 'protonmail'
@ -684,7 +679,6 @@ Ext.define('Rambox.store.ServicesList', {
,description: 'Microsoft Teams is the chat-based workspace in Office 365 that integrates all the people, content, and tools your team needs to be more engaged and effective.'
,url: 'https://teams.microsoft.com'
,type: 'messaging'
,userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3445.2 Safari/537.36'
},
{
id: 'kezmo'

126
app/ux/WebView.js

@ -169,7 +169,7 @@ Ext.define('Rambox.ux.WebView',{
,autosize: 'on'
,webpreferences: '' //,nativeWindowOpen=true
//,disablewebsecurity: 'on' // Disabled because some services (Like Google Drive) dont work with this enabled
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent')
,userAgent: me.getUserAgent()
,preload: './resources/js/rambox-service-api.js'
}
}];
@ -286,7 +286,7 @@ Ext.define('Rambox.ux.WebView',{
,src: e.url
,style: 'width:100%;height:100%;'
,partition: me.getWebView().partition
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent')
,useragent: me.getUserAgent()
}
}
}).show();
@ -314,7 +314,7 @@ Ext.define('Rambox.ux.WebView',{
,src: e.url
,style: 'width:100%;height:100%;'
,partition: me.getWebView().partition
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent')
,useragent: me.getUserAgent()
}
}
}).show();
@ -344,7 +344,7 @@ Ext.define('Rambox.ux.WebView',{
,src: e.url
,style: 'width:100%;height:100%;'
,partition: me.getWebView().partition
,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent')
,useragent: me.getUserAgent()
,preload: './resources/js/rambox-modal-api.js'
}
}
@ -817,7 +817,123 @@ Ext.define('Rambox.ux.WebView',{
return false;
}
}
,blur: function () {
,getUserAgent: function() {
const me = this;
// TODO: Keep just in case we need our own User Agent builder.
// const default_ua = `Mozilla/5.0` +
// ` (${me.getOSPlatform()})` +
// ` AppleWebKit/537.36 (KHTML, like Gecko)` +
// ` Chrome/${me.getChromeVersion()} Safari/537.36`;
const default_ua = window.navigator.userAgent
.replace(`Electron/${me.getElectronVersion()} `,'')
.replace(`Rambox/${me.getAppVersion()} `, '');
const service_ua = Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent');
const ua = service_ua ? service_ua : default_ua;
return ua;
}
,getOSArch: function() {
const me = this;
let platform = require('os').platform();
let arch = require('os').arch();
switch (platform) {
case 'win32':
arch = me.is32bit() ? 'WOW64' : 'Win64; x64';
break;
case 'freebsd':
arch = me.is32bit ? 'i386' : 'amd64';
break;
case 'sunos':
arch = me.is32bit() ? 'i86pc' : 'x86_64';
break;
case 'linux':
default:
arch = me.is32bit() ? 'i686' : 'x86_64';
break;
}
return arch;
}
,getOSArchType: function() {
let arch = require('os').arch();
switch(arch) {
case 'x64':
case 'ia32':
case 'x32':
arch='Intel';
break;
case 'arm64':
case 'arm':
arch='ARM';
break;
case 'mips':
case 'mipsel':
arch='MIPS';
break;
case 'ppc64':
case 'ppc':
arch='PPC';
break;
case 's390x':
case 's390':
arch='S390';
break;
default:
arch='Unknown';
break;
}
return arch;
}
,getOSPlatform: function() {
const me = this;
let platform = require('os').platform();
switch (platform) {
case 'win32':
platform = `Windows NT ${me.getOSRelease()}; ${me.getOSArch()}`;
break;
case 'linux':
platform = `X11; Linux ${me.getOSArch()}`;
break;
case 'darwin':
platform = `${me.getOSArchType()} Mac OS X ${me.getOSRelease()}`;
break;
case 'freebsd':
platform = `X11; FreeBSD ${me.getOSArch()}`;
break;
case 'sunos':
platform = `X11; SunOS i86pc`;
break;
default:
platform = `X11; ${platform} ${me.getOSArch()}`;
}
return platform;
}
,isWindows: function() {
return require('os').platform() === 'win32';
}
,is32bit: function() {
const arch = require('os').arch();
if (arch === 'ia32' || arch === 'x32')
return true;
else
return false;
}
,getOSRelease: function() {
const me = this;
return me.isWindows() ?
require('os').release().match(/([0-9]+\.[0-9]+)/)[0]
: require('os').release();
}
,getChromeVersion: function() {
return require('process').versions['chrome'];
}
,getElectronVersion: function() {
return require('process').versions['electron'];
}
,getAppVersion: function() {
return require('electron').remote.app.getVersion();
}
,blur: function() {
this.getWebView().blur();
}
,focus: function()

Loading…
Cancel
Save