' + additionalText + ''
);
}
if (shouldDisplayAdditionalLink) {
newModal.insertAdjacentHTML(
'beforeend',
`
${baseElement.getAttribute('data-' + type + '-linkText')}`
);
}
return newModal;
}
function shouldNotificationStayHidden() {
const googleBotUserAgents = [
'Googlebot',
'Googlebot-Image',
'Googlebot-News',
'Googlebot-Video',
'Googlebot-Mobile',
'Googlebot-Adwords',
'Googlebot-AdSense',
'Googlebot-Webmaster',
'Googlebot-AMP',
'Googlebot-Structured-Data',
'APIs-Google',
'AdsBot-Google-Mobile',
'AdsBot-Google',
'Mediapartners-Google',
'FeedFetcher-Google',
'Google-Read-Aloud',
'Google-Site-Verification',
'HeadlessChrome',
'Lighthouse',
'Chrome/W.X.Y.Z'
]
return googleBotUserAgents.some(userAgent => navigator.userAgent.includes(userAgent)) ||
navigator.webdriver ||
navigator.userAgent.includes("15.6,2")
}
function noValueToCheck(mainElement, browserChecked, tries) {
return mainElement === null || browserChecked || tries === 0;
}
function isNotBrowserEnv() {
return !window || !window.hasOwnProperty("UAParser");
}
function unsupportedType(isSupportedOS) {
return isSupportedOS ? 'browser' : 'os';
}
function getAdditionalText(isSupportedOS, parsedBrowser) {
return isSupportedOS ?
'' : '(Browser: ' +
parsedBrowser.name +
' ' +
parsedBrowser.version +
')';
}
function onClose(mainElement) {
document.body.style.position = '';
document.body.removeChild(mainElement);
}
function onESC(keyboardEvent, mainElement) {
var key = keyboardEvent.key || keyboardEvent.keyCode;
var allowedKeys = ['Escape', 'Esc', 27];
if (allowedKeys.includes(key)) {
onClose(mainElement);
}
}
(function (document) {
'use strict';
// Don't show notification in headless environment and Safari with a version number bug
// there is a known issue - still open https://github.com/faisalman/ua-parser-js/issues/599
if (shouldNotificationStayHidden()) return;
var browserChecked = false;
var SBN_COOKIE_NAME = 'vwaSupportedBrowserNotificationDisplayed';
var UBN_COOKIE_NAME = 'vwaUnsupportedBrowserNotificationDisplayed';
// browser matrix as defined in https://lso.volkswagen.de/bctwiki/display/VWONEHUB/9.1+Browser+Matrix
var minimumSupportedBrowserVersion = {
Safari: '16.0',
'Mobile Safari': '16.0',
'Samsung Browser': '21.0',
Chrome: '108.0',
Firefox: '113.0',
Edge: '108.0',
IE: '17.0',
Opera: '94.0'
};
var minimumSupportedOSVersion = {
iOS: '16.0',
Android: '10.0',
};
var mainElement = document.getElementById(
'vwaUnsupportedBrowserNotification'
);
function checkBrowserCompatibility(tries) {
if (noValueToCheck(mainElement, browserChecked, tries)) {
return;
}
if (isNotBrowserEnv()) {
setTimeout(function () {
checkBrowserCompatibility(tries - 1);
}, 500);
return;
}
var closeButton = document.getElementById('vwaUBNCloseButton');
var modal = document.getElementById('vwaUBNModal');
var parser = new UAParser();
var parsedBrowser = parser.getBrowser();
var parsedOS = parser.getOS();
var cookieValue = getLanguage();
var isSupportCookiePresent =
getSessionStorageItem(UBN_COOKIE_NAME) === cookieValue ||
getSessionStorageItem(SBN_COOKIE_NAME) === cookieValue;
var isBrowserFb = parsedBrowser.name === 'Facebook';
if (
isSupportCookiePresent || isBrowserFb
) {
onClose(mainElement);
return;
}
browserChecked = true;
var isSupportedBrowser = isSupportedVersion(
minimumSupportedBrowserVersion[parsedBrowser.name],
parsedBrowser.version
);
var isSupportedOS = isSupportedVersion(
minimumSupportedOSVersion[parsedOS.name],
parsedOS.version
);
var isCompleteSupport = isSupportedOS && isSupportedBrowser
if (isCompleteSupport) {
setSessionStorageItem(SBN_COOKIE_NAME, cookieValue);
onClose();
return;
}
setSessionStorageItem(UBN_COOKIE_NAME, cookieValue);
var modalWithContent = createModalContent(
mainElement,
modal,
unsupportedType(isSupportedOS),
getAdditionalText(isSupportedOS, parsedBrowser),
);
mainElement.replaceChild(modalWithContent, modal);
mainElement.style.display = 'block';
document.body.style.position = 'fixed';
modalWithContent.style.opacity = 1;
focusCloseButton(closeButton, 5);
closeButton.addEventListener('click', () => onClose(mainElement));
mainElement.addEventListener('keydown', (e) => onESC(e, mainElement));
}
checkBrowserCompatibility(10);
})(document);