diff --git a/src/ami.js/chat.js b/src/ami.js/chat.js index f012363..c7d3c21 100644 --- a/src/ami.js/chat.js +++ b/src/ami.js/chat.js @@ -9,7 +9,6 @@ #include submitbox.js #include title.js #include utility.js -#include mami/settings.js var AmiChat = function(chat, title, parent) { var container = $e({ attrs: { id: 'chat' } }); @@ -76,8 +75,6 @@ var AmiChat = function(chat, title, parent) { if(parent !== undefined) pub.appendTo(parent); - if(MamiSettings.isSupported()) - optionIcons.create('export', 'Export modern client settings', 'export', () => MamiSettings.exportFile()); optionIcons.create('unembed', 'Unembed any embedded media', 'unembed', function() { var buttons = $c('js-unembed-btn'); while(buttons.length > 0) diff --git a/src/ami.js/main.js b/src/ami.js/main.js index f8ceff1..92e1af9 100644 --- a/src/ami.js/main.js +++ b/src/ami.js/main.js @@ -6,7 +6,6 @@ #include loadoverlay.js #include mszauth.js #include ts_chat.js -#include mami/settings.js (function() { var loading = new AmiLoadingOverlay(document.body, true); diff --git a/src/ami.js/mami/settings.js b/src/ami.js/mami/settings.js deleted file mode 100644 index 1f485bf..0000000 --- a/src/ami.js/mami/settings.js +++ /dev/null @@ -1,80 +0,0 @@ -#include utility.js - -const MamiSettings = (function() { - const isSupported = () => { - 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 { - eval('const c = 1; let l = 2;'); - } catch(e) { - return false; - } - - try { - eval('for(const i of ["a", "b"]);'); - } catch(e) { - return false; - } - - return true; - } - - const exportFile = () => { - const data = { a: 'Mami Settings Export', v: 1, d: [] }; - - for(let i = 0; i < localStorage.length; ++i) { - const key = localStorage.key(i); - if(key.substring(0, 4) !== 'umi-') - continue; - - data.d.push({ - i: key.substring(4), - v: JSON.parse(localStorage.getItem(key)), - }); - } - - const exp = $e('a', { - href: URL.createObjectURL(new Blob( - [btoa(JSON.stringify(data))], - { type: 'application/octet-stream' } - )), - download: 'settings.mami', - target: '_blank', - style: { display: 'none' } - }); - document.body.appendChild(exp); - exp.click(); - $r(exp); - }; - - return { - isSupported: isSupported, - exportFile: exportFile, - }; -})();