-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement emulateWinChromiumPlatform Flag for OS Emulation (#1395)
* 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
1 parent
76b1339
commit dea645b
Showing
6 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters