Compare commits
2 commits
c2159598c9
...
111057bd7b
Author | SHA1 | Date | |
---|---|---|---|
111057bd7b | |||
331c7c49a5 |
6 changed files with 5 additions and 86 deletions
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 18 KiB |
|
@ -9,7 +9,6 @@
|
||||||
#include submitbox.js
|
#include submitbox.js
|
||||||
#include title.js
|
#include title.js
|
||||||
#include utility.js
|
#include utility.js
|
||||||
#include mami/settings.js
|
|
||||||
|
|
||||||
var AmiChat = function(chat, title, parent) {
|
var AmiChat = function(chat, title, parent) {
|
||||||
var container = $e({ attrs: { id: 'chat' } });
|
var container = $e({ attrs: { id: 'chat' } });
|
||||||
|
@ -76,8 +75,6 @@ var AmiChat = function(chat, title, parent) {
|
||||||
if(parent !== undefined)
|
if(parent !== undefined)
|
||||||
pub.appendTo(parent);
|
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() {
|
optionIcons.create('unembed', 'Unembed any embedded media', 'unembed', function() {
|
||||||
var buttons = $c('js-unembed-btn');
|
var buttons = $c('js-unembed-btn');
|
||||||
while(buttons.length > 0)
|
while(buttons.length > 0)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include loadoverlay.js
|
#include loadoverlay.js
|
||||||
#include mszauth.js
|
#include mszauth.js
|
||||||
#include ts_chat.js
|
#include ts_chat.js
|
||||||
#include mami/settings.js
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var loading = new AmiLoadingOverlay(document.body, true);
|
var loading = new AmiLoadingOverlay(document.body, true);
|
||||||
|
|
|
@ -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,
|
|
||||||
};
|
|
||||||
})();
|
|
|
@ -46,8 +46,8 @@ var Utils = (function () {
|
||||||
link.classList[holder.title == 'link' ? 'remove' : 'add']('js-unembed-btn');
|
link.classList[holder.title == 'link' ? 'remove' : 'add']('js-unembed-btn');
|
||||||
};
|
};
|
||||||
Utils.ToggleSpoiler = function(element) {
|
Utils.ToggleSpoiler = function(element) {
|
||||||
var container = element.parentElement,
|
var container = element.parentElement;
|
||||||
target = container.getElementsByTagName("span")[0];
|
var target = container.getElementsByTagName("span")[0];
|
||||||
|
|
||||||
if(container.dataset.revealed === 'yes') {
|
if(container.dataset.revealed === 'yes') {
|
||||||
container.dataset.revealed = 'no';
|
container.dataset.revealed = 'no';
|
||||||
|
@ -58,6 +58,9 @@ var Utils = (function () {
|
||||||
target.textContent = container.dataset.shit;
|
target.textContent = container.dataset.shit;
|
||||||
element.textContent = 'Hide';
|
element.textContent = 'Hide';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
element.classList[container.dataset.revealed == 'no' ? 'add' : 'remove']('js-embed-btn');
|
||||||
|
element.classList[container.dataset.revealed == 'no' ? 'remove' : 'add']('js-unembed-btn');
|
||||||
}
|
}
|
||||||
Utils.SanitizeRegex = function (input) {
|
Utils.SanitizeRegex = function (input) {
|
||||||
var out = "";
|
var out = "";
|
||||||
|
|
Loading…
Reference in a new issue