#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, }; })();