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
#10807
very cool usercss needed for chat

// ==UserScript==
// @name chat cleaner - flashii.net
// @namespace Violentmonkey Scripts
// @match https://sockchat.flashii.net/
// @grant GM_addStyle
// @version 1.0
// @author jeff
// @description 6/7/2021, 5:31:12 PM
// @require https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==
GM_addStyle(' #user-173{display:none !important;} ')
$(".message:contains('Phi joined.')").remove();;
$(".message:contains('Phi joined.')").remove();;
https://i.imgur.com/ImOBqpg.jpg
#11398
i modded szy's script a bit to work with non-eeprom files too, using flash's mii thing which i never heard of until now but it's cute
it also shows the resolution and length if applicable, and for eeprom files, you can hover over the tag to see its original filename

// ==UserScript==
// @name Sockchat Embed File Sizes
// @description adds things to embeds
// @author szy, osk
// @match https://sockchat.flashii.net/
// @grant none
// ==/UserScript==

(function() {
'use strict';
function xhr(url) {
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'; }
const e = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes/Math.pow(1024, e)).toFixed(e === 0 ? 0 : 2)+'\u200b'+'\u200bKMGTP'.charAt(e)+'B';
}
function ParseMS(oms) {
const roms = Math.round(oms);

const ms = roms % 1000;
const s = Math.floor(roms / 1000) % 60;
const m = Math.floor(roms / 60000);

return {
ms: ms.toString().padStart(3, '0'),
s: s.toString().padStart(2, '0'),
m: m.toString()
};
}


window.addEventListener('umi:ui:message_add', function(ev) {
const embedButtons = ev.detail.element.querySelectorAll('a[onclick^="Umi.Parser.SockChatBBcode.Embed"]');

for (const embedButton of embedButtons) {
const embed = embedButton.parentElement;
let link = embed.getAttribute('title');
if (link.startsWith('//')) { link = `https:${ link }`; } // Mii 500s on //domain.name URIs

try {
const el = document.createElement('span');
el.classList.add('eeprom_extended_data');
el.style.color = '#AFF';
el.textContent = ' [...]';
embed.appendChild(el);

xhr(`https://mii.flashii.net/metadata?url=${ encodeURIComponent(link) }`).then((resp) => {
if (resp.errorMessage) {
throw resp.errorMessage;
}

if (!resp.media) {
if (resp.content_type) {
throw `Not a media file; detected as ${ resp.content_type.string }`;
}
throw 'Not a media file; content type unknown';
}

let size = resp.media.size || 0;

if (resp.eeprom_file_info) {
size = resp.eeprom_file_info.size;
el.title = resp.eeprom_file_info.name;
}

el.style.color = '#A0F5B8';
if (size >= 128*1024) { el.style.color = '#BAE9C7'; }
if (size >= 512*1024) { el.style.color = '#CDD'; }
if (size >= 1024*1024) { el.style.color = '#CCA1F4'; }
if (size >= 4*1024*1024) { el.style.color = '#DB5FF1'; }
if (size >= 10*1024*1024) { el.style.color = '#EC32A4'; }

let elText = sizeOf(size);

if (resp.is_image && resp.width && resp.height) {
elText += `・${ resp.width }x${ resp.height }`;
}
if (resp.is_video && resp.width && resp.height && resp.media.duration) {
const p = ParseMS(resp.media.duration * 1000);
elText += `・${ resp.width }x${ resp.height }・${ p.m }:${ p.s }<span style="font-size: 70%">.${ p.ms }</span>`;
}
if (resp.is_audio && resp.media.duration) {
const p = ParseMS(resp.media.duration * 1000);
elText += `・${ p.m }:${ p.s }<span style="font-size: 70%">.${ p.ms }</span>`;
}

el.innerHTML = ` [${ elText }]`;
}).catch((err) => {
console.error(err);
el.textContent = '[ERR]';
el.style.color = '#FAA';
el.title = err || 'Network error while requesting metadata';
})
} catch (ex) {
console.error(ex)
}
}
});
})();
https://kagari.moe/outer_assets/flashii/signature.png https://kagari.moe/outer_assets/flashii/signature-sites.pnghttps://kagari.moe/outer_assets/flashii/signature-kagarimoe.pnghttps://kagari.moe/outer_assets/flashii/signature-tetrio.png?v=2https://kagari.moe/outer_assets/flashii/signature-osksh.pnghttps://kagari.moe/outer_assets/flashii/signature-social.pnghttps://kagari.moe/outer_assets/flashii/signature-twitter.pnghttps://kagari.moe/outer_assets/flashii/signature-lastfm.pnghttps://kagari.moe/outer_assets/flashii/signature-github.pnghttps://kagari.moe/outer_assets/flashii/signature-blog.pnghttps://kagari.moe/outer_assets/flashii/signature-projects.pnghttps://kagari.moe/outer_assets/flashii/signature-wsmasher.pnghttps://kagari.moe/outer_assets/flashii/signature-yukari.pnghttps://kagari.moe/outer_assets/flashii/signature-kurumi.pnghttps://kagari.moe/outer_assets/flashii/signature-teto.pnghttps://kagari.moe/outer_assets/flashii/signature-rdg.pnghttps://kagari.moe/outer_assets/flashii/signature-attoch.png