assets/js/browsercheck.js

Last modified Fri Sep 24 09:08:56 UTC 2021



// browsercheck.js

var safari = false;
var brave = false;
var iPhone = false;
var iPad = false;


function getParams(url) {
	var params = {};
	var parser = document.createElement('a');
	parser.href = url;
	var query = parser.search.substring(1);
	var vars = query.split('&');
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split('=');
		params[pair[0]] = decodeURIComponent(pair[1]);
	}
	return params;
};

function browserCheck(){

var arg = getParams(window.location.href);

if(arg["force"] == "true"){
	return;
}

if ((typeof(window.crypto) !== "object") || (typeof(window.crypto.subtle) !== "object")) {
	window.location.href = "alert/nocrypto.html";
}

var uA = window.navigator.userAgent;

if(uA.indexOf("Edge/") > -1){  
	window.location.href = "alert/edge.html"; 
	return; 
	}  

if(uA.indexOf("Trident") > -1){  
	window.location.href = "alert/ie.html";
	return;  
}  

if(uA.indexOf("DuckDuckGo") > -1){  
	window.location.href = "alert/duckduckgo.html";
	return;
}  

if(uA.indexOf("Firefox") > -1){  
	if(uA.indexOf("Android") > -1){
		window.location.href = "alert/general.html";
		return;
	}
}

if(uA.indexOf("YaBrowser") > -1){  
	window.location.href = "alert/general.html";
	return;
}  

if(uA.indexOf("EdgiOS") > -1){  
	window.location.href = "alert/crios.html";
	return;
}  

if(uA.indexOf("CriOS") > -1){  
	window.location.href = "alert/crios.html";
	return;
}  

function isBrave() {
   	brave = !!navigator.brave;
	return brave;
}

if((uA.indexOf("iPhone") > -1 || uA.indexOf("iPad") > -1) && isBrave() && navigator.platform.indexOf("Win") < 0){
	window.location.href = "alert/general.html";
	return;
}

if(uA.indexOf("CPU iPhone") > -1 || uA.indexOf("iPhone; CPU") > -1) { 
	safari = true;
	iPhone = true;
	return;	
}
if(uA.indexOf("iPad; CPU") > -1) { // iPad in mobile (not desktop) mode
	safari = true;
	iPad = true;
	return;	
}

if(uA.indexOf("Windows") > -1 || uA.indexOf("Linux") > -1 || 'serviceWorker' in navigator){
	//Ok
}else{
	window.location.href = "alert/general.html";
	return;
}

if(uA.indexOf("Mac OS X") > -1){ // iPad in desktop mode or a real Mac
	safari = true;
	iPad = (navigator.maxTouchPoints == 5);
	return;
}

if((uA.indexOf("iPad") > -1 || uA.indexOf("iPhone") > -1) &&
    uA.indexOf("Mobile") > -1){
	window.location.href = "alert/general.html"; // iDevice but not Safari
	return;
}

}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

addLoadEvent(browserCheck);