diff --git a/js/preload/siteUnbreak.js b/js/preload/siteUnbreak.js index 7059ffa98..93484a2bb 100644 --- a/js/preload/siteUnbreak.js +++ b/js/preload/siteUnbreak.js @@ -96,6 +96,29 @@ if (window.location.hostname === 'calendar.google.com') { `) } +/* Gmail - required for loading standard version (otherwise redirects to basic HTML) */ + +if (window.location.hostname === 'mail.google.com') { + const chromiumVersion = process.versions.chrome.split('.')[0] + scriptsToRun.push(` + (function() { + const simulatedUAData = { + brands: [ + {brand: "Chromium", version: "${chromiumVersion}"}, + {brand: "Not A;Brand", version: "99"} + ], + mobile: false, + getHighEntropyValues: function() { + console.warn('getHighEntropyValues is unimplemented', arguments) + return null + } + } + + Object.defineProperty(navigator, 'userAgentData', {get: () => simulatedUAData}) + })() + `) +} + if (scriptsToRun.length > 0) { setTimeout(function () { electron.webFrame.executeJavaScript(scriptsToRun.join(';')) diff --git a/main/UASwitcher.js b/main/UASwitcher.js index 40fb63011..8d007cb9e 100644 --- a/main/UASwitcher.js +++ b/main/UASwitcher.js @@ -26,6 +26,11 @@ function enableGoogleUASwitcher (ses) { details.requestHeaders['User-Agent'] = newUserAgent + ' Edg/' + process.versions.chrome } } + + const chromiumVersion = process.versions.chrome.split('.')[0] + details.requestHeaders['SEC-CH-UA'] = `"Chromium";v="${chromiumVersion}", " Not A;Brand";v="99"` + details.requestHeaders['SEC-CH-UA-MOBILE'] = '?0' + callback({ cancel: false, requestHeaders: details.requestHeaders }) }) }