Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement partial UA client hints support for gmail #1715

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions js/preload/siteUnbreak.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(';'))
Expand Down
5 changes: 5 additions & 0 deletions main/UASwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
}
Expand Down