Add check for navigator userAgent

pull/495/head
Moses Gitau 2020-06-07 13:45:27 +03:00
parent ac81abf7fd
commit d15fb391f8
1 changed files with 9 additions and 7 deletions

View File

@ -3,15 +3,17 @@ var chromeMediaSource = 'screen';
var sourceId; var sourceId;
var screenCallback; var screenCallback;
var isFirefox = typeof window.InstallTrigger !== 'undefined'; var isFirefox = typeof window.InstallTrigger !== 'undefined';
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; var isOpera = !!window.opera || (navigator.userAgent && navigator.userAgent.indexOf(' OPR/') >= 0);
var isChrome = !!window.chrome && !isOpera; var isChrome = !!window.chrome && !isOpera;
window.addEventListener('message', function (event) { if(window.addEventListener){
if (event.origin != window.location.origin) { window.addEventListener('message', function (event) {
return; if (event.origin != window.location.origin) {
} return;
onMessageCallback(event.data); }
}); onMessageCallback(event.data);
});
}
// and the function that handles received messages // and the function that handles received messages
function onMessageCallback(data) { function onMessageCallback(data) {