I am trying to detect Chromium based Edge browser in google slides addon.
function onInstall(event) {
onOpen(event);
}
function onOpen(event) {
SlidesApp.getUi().createAddonMenu()
.addItem('Open the sidebar', '_showSidebar')
.addToUi();
_showSidebar();
}
function _showSidebar() {
var ui = HtmlService
.createHtmlOutputFromFile('index')
.setTitle('Test add-on');
SlidesApp.getUi().showSidebar(ui);
}
<html>
<head>
<base target="_top">
<script>
const onButtonClick = () => {
console.log(window.navigator.userAgent);
}
</script>
</head>
<body>
<button onclick="onButtonClick()">Click me</button>
</body>
</html>
Clicking on the button in sidebar logs to console:
5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
But when I manually type window.navigator.userAgent
to browser console log looks differently (Edg/84.0.522.49
is missing):
5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 Edg/84.0.522.49
The main problem is that your Google Slides addon/sidebar is running inside an iframe which is hosted on docs.google.com
.
The new Chromium based Microsoft Edge browser overrides User-Agent on some sites to maximize compatibility. If you open edge://compat/useragent
in your Edge you will see that the docs.google.com
is listed in that "User agent overrides" list:
To disable the user agent overrides functionality, you may run the Microsoft Edge executable using the following command line argument:
--disable-domain-action-user-agent-override