mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-27 21:05:53 +00:00
4.52.0
* Added: Setting for customizing how tab-completion matches emote names. * Added: Clips pages now have support for opening emote cards when clicking an emote in the chat replay. * Fixed: Issue where chat was not rendering as intended on clips pages. * Fixed: Issue where the FFZ Control Center link was not added to clips pages. * Fixed: The chat actions module being instantiated in memory twice. * Fixed: Blank badges appearing in chat, most notably in historic messages, when a chat message has invalid badge data associated with it. * Fixed: Use a mutation observer for detecting the drops Claim button, rather than a simple timeout, for better consistency. * Fixed: Issue when using the webpack public path variable that may lead to URL generation with extra `/` characters, breaking some behavior in Firefox when packaged as a local extension. * API Added: Support for displaying an emote's original name, if an emote has been given a collection-specific name, using an `original_name` field.
This commit is contained in:
parent
fc009a84e7
commit
8ac95f3a52
25 changed files with 654 additions and 52 deletions
|
@ -56,4 +56,83 @@ export function deserializeBlob(data) {
|
|||
return new Uint8Array(data.buffer);
|
||||
|
||||
throw new TypeError('Invalid type');
|
||||
}
|
||||
}
|
||||
|
||||
export function serializeBlobUrl(blob) {
|
||||
return new Promise((s,f) => {
|
||||
const reader = new FileReader();
|
||||
reader.onabort = f;
|
||||
reader.onerror = f;
|
||||
reader.onload = e => {
|
||||
s(e.target.result);
|
||||
}
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
export function deserializeBlobUrl(url) {
|
||||
return fetch(blob).then(res => res.blob())
|
||||
}
|
||||
|
||||
export function deserializeABUrl(url) {
|
||||
return fetch(blob).then(res => res.arrayBuffer())
|
||||
}
|
||||
|
||||
export async function serializeBlobForExt(blob) {
|
||||
if ( ! blob )
|
||||
return null;
|
||||
|
||||
if ( blob instanceof Blob )
|
||||
return {
|
||||
type: 'blob',
|
||||
mime: blob.type,
|
||||
url: await serializeBlobUrl(blob)
|
||||
}
|
||||
|
||||
if ( blob instanceof File )
|
||||
return {
|
||||
type: 'file',
|
||||
mime: blob.type,
|
||||
name: blob.name,
|
||||
modified: blob.lastModified,
|
||||
url: await serializeBlobUrl(blob)
|
||||
}
|
||||
|
||||
if ( blob instanceof ArrayBuffer )
|
||||
return {
|
||||
type: 'ab',
|
||||
url: await serializeBlobUrl(new Blob([blob]))
|
||||
}
|
||||
|
||||
if ( blob instanceof Uint8Array )
|
||||
return {
|
||||
type: 'u8',
|
||||
url: await serializeBlobUrl(new Blob([blob]))
|
||||
}
|
||||
|
||||
throw new TypeError('Invalid type');
|
||||
|
||||
}
|
||||
|
||||
export async function deserializeBlobForExt(data) {
|
||||
if ( ! data || ! data.type )
|
||||
return null;
|
||||
|
||||
if ( data.type === 'blob' )
|
||||
return await deserializeBlobUrl(data.url);
|
||||
|
||||
if ( data.type === 'file' )
|
||||
return new File(
|
||||
[await deserializeBlobUrl(data.url)],
|
||||
data.name,
|
||||
{type: data.mime, lastModified: data.modified}
|
||||
);
|
||||
|
||||
if ( data.type === 'ab' )
|
||||
return await deserializeABUrl(data.url);
|
||||
|
||||
if ( data.type === 'u8' )
|
||||
return new Uint8Array(await deserializeABUrl(data.url));
|
||||
|
||||
throw new TypeError('Invalid type');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue