Skip to content

Commit

Permalink
Implement emulateWinChromiumPlatform Flag for OS Emulation (#1395)
Browse files Browse the repository at this point in the history
* add feature to emulate platform for chromium

* fix styling

* fix formatting

* update readme file

* avoid using boolean literal

* update version information for package.json and app.xml

* Update com.github.IsmaelMartinez.teams_for_linux.appdata.xml

---------

Co-authored-by: wix woo <[email protected]>
Co-authored-by: Wix Woo <[email protected]>
Co-authored-by: IsmaelMartinez <[email protected]>
  • Loading branch information
4 people authored Sep 10, 2024
1 parent 76b1339 commit dea645b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
return { onclick: null, onclose: null, onerror: null };
}
}

static async requestPermission() {
return 'granted';
}
Expand All @@ -69,4 +69,5 @@ function initializeModules(config, ipcRenderer) {
require('./tools/settings').init(config, ipcRenderer);
require('./tools/customBackgrounds')(config, ipcRenderer);
require('./tools/theme').init(config, ipcRenderer);
require('./tools/emulatePlatform').init(config);
}
34 changes: 34 additions & 0 deletions app/browser/tools/emulatePlatform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class PlatformEmulator {
init(config) {
//proceed without emulating windows platform in browser
if (!config.emulateWinChromiumPlatform) {
return
}

// update property platform property in navigator.navigator
const win32Str = "Win32"
const windowsStr = "Windows"
Object.defineProperty(Navigator.prototype, "platform", { get: () => { return win32Str } })


//update userAgentData object
let originalUserAgentData = navigator.userAgentData
let customUserAgentData = JSON.parse(JSON.stringify(originalUserAgentData))
customUserAgentData = {
...customUserAgentData,
platform: windowsStr,
getHighEntropyValues: async function (input) {
let highEntropyValue = await originalUserAgentData.getHighEntropyValues(input)
if (highEntropyValue['platform']) {
highEntropyValue['platform'] = windowsStr
}
return highEntropyValue
}
}
Object.defineProperty(Navigator.prototype, "userAgentData", { get: () => { return customUserAgentData } })


}
}

module.exports = new PlatformEmulator;
1 change: 1 addition & 0 deletions app/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Here is the list of available arguments and its usage:
| disableNotificationWindowFlash | Disable window flashing when there is a notification | false |
| disableGlobalShortcuts | Array of global shortcuts to disable while the app is in focus. See https://www.electronjs.org/docs/latest/api/accelerator for available accelerators to use | [] |
| electronCLIFlags | Electron CLI flags to be added when the app starts | [] |
| emulateWinChromiumPlatform| Use windows platform information in chromium. This is helpful if MFA app does not support Linux.| false |
| followSystemTheme | Boolean to determine if to follow system theme | false |
| incomingCallCommand | Command to execute on an incoming call. (string) | |
| incomingCallCommandArgs | Arguments for the incomming call command. | [] |
Expand Down
4 changes: 4 additions & 0 deletions app/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ function extractYargConfig(configObject, appVersion) {
describe: 'custom CSS styles file location',
type: 'string'
},
emulateWinChromiumPlatform: {
default: false,
describe: 'Use windows platform information in chromium. This is helpful if MFA app does not support Linux.'
},
followSystemTheme: {
default: false,
describe: 'Follow system theme',
Expand Down
7 changes: 7 additions & 0 deletions com.github.IsmaelMartinez.teams_for_linux.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<url type="bugtracker">https://github.com/IsmaelMartinez/teams-for-linux/issues</url>
<launchable type="desktop-id">com.github.IsmaelMartinez.teams_for_linux.desktop</launchable>
<releases>
<release version="1.10.2" date="2024-09-10">
<description>
<ul>
<li>Add support to simulate Windows-based Chromium Browser</li>
</ul>
</description>
</release>
<release version="1.10.1" date="2024-09-09">
<description>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teams-for-linux",
"version": "1.10.1",
"version": "1.10.2",
"main": "app/index.js",
"description": "Unofficial client for Microsoft Teams for Linux",
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",
Expand Down

0 comments on commit dea645b

Please sign in to comment.