Flashii Chat Userscripts
#9630
if you have tried to extend the chat in ways flashwave couldn't be assed to do, post your results here

here is a filesize detection script made for reemo
// ==UserScript==
// @name Sockchat EEPROM File Sizes
// @description adds things to eeprom uploads
// @author szy
// @match https://sockchat.flashii.net/
// @grant none
// ==/UserScript==

(function() {
'use strict';
function xhr(url) { // fucking stolen from osk and then mutilated
return new Promise((resolve, reject) => {
const request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = () => {
if (request.readyState === 4) {
const json = JSON.parse(request.responseText);
if (json) {
resolve(json);
} else {
reject(json);
}
}
};
request.onerror = () => {
console.error(`Request ${url} returned onerror`);
reject();
};
request.send();
});
}
function sizeOf(bytes) { // https://stackoverflow.com/a/28120564
if (bytes == 0) { return "0B"; }
var e = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes/Math.pow(1024, e)).toFixed(2)+'\u200b'+'\u200bKMGTP'.charAt(e)+'B';
}


window.addEventListener('umi:ui:message_add', function(ev) {
var message = ev.detail.element;
var embeds = message.querySelectorAll('span[title^="//i.flashii.net/"]');
for (var i = 0; i < embeds.length; i++) {
const embed = embeds[i];
try {
let el = document.createElement('span');
el.classList.add('szy_eeprom_data');
el.style.color='#AFF';
el.textContent=' [...]';
embed.appendChild(el);
let href = embed.firstChild.firstChild.href;
let eeprom = href.replace(/i.flashii.net\/([A-Za-z0-9_-]+)/g, "eeprom.flashii.net/uploads/$1.json");
xhr(eeprom).then(resp=>{
var size = +resp['size'];
el.textContent = `[${sizeOf(size)}]`;
el.style.color = '#CDD';
}).catch(err=>{
console.error(err);
el.textContent='[ERR]';
el.style.color='#FAA';
});
} catch (ex) {
console.error(ex);
}
}
});
})();
https://szymszl.xyz/sig.png spɟsƃɟ
#9658
thank u suzy i will install monkeyscriptmonkeyscript just to use this female
http://aroltd.com/trash/R9trvwu.png