mami/src/init.js/main.js
flash cf71bab92d Rewrote connection handling.
This has been in the works for over a month and might break things because it's a very radical change.
If it causes you to be unable to join chat, report it on the forum or try joining using the legacy chat on https://sockchat.flashii.net.
2024-04-17 15:42:50 +00:00

52 lines
1.6 KiB
JavaScript

#buildvars
(function() {
var isCompatible = (function() {
if(navigator.userAgent.indexOf('MSIE') >= 0)
return false;
if(navigator.userAgent.indexOf('Trident/') >= 0)
return false;
if(!('Blob' in window) || !('prototype' in window.Blob)
|| window.Blob.prototype.constructor.name !== 'Blob')
return false;
if(!('AudioContext' in window) && !('webkitAudioContext' in window))
return false;
if(!('URL' in window) || !('createObjectURL' in window.URL)
|| window.URL.prototype.constructor.name !== 'URL')
return false;
if(!('localStorage' in window))
return false;
try {
var testVar = 'test';
localStorage.setItem(testVar, testVar);
if(localStorage.getItem(testVar) !== testVar)
throw '';
localStorage.removeItem(testVar);
} catch(e) {
return false;
}
try {
// this is eval'd to allow a parse exception to be thrown without cancelling the entire script
eval('for(const i of ["a", "b"]); let obj; obj?.test(); obj ??= {};');
} catch(e) {
return false;
}
return true;
})();
if(isCompatible) {
(function(script) {
script.src = MAMI_MAIN_JS;
script.type = 'text/javascript';
script.charset = 'utf-8';
document.body.appendChild(script);
})(document.createElement('script'));
} else location.assign(window.AMI_URL);
})();