From 6380d0a6bf07b2e5b0d1d41ee538861cd68aebfb Mon Sep 17 00:00:00 2001 From: Davi Rodrigues <30713947+daviirodrig@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:20:06 -0300 Subject: [PATCH] 7TV Emotes 1.4.23 * Added: A new option to select between WEBP and AVIF for the emote file format (Thanks to daviirodrig) --- src/7tv-emotes/manifest.json | 4 ++-- src/7tv-emotes/modules/emotes.js | 36 ++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/7tv-emotes/manifest.json b/src/7tv-emotes/manifest.json index 9d9ff536..3e20bbee 100644 --- a/src/7tv-emotes/manifest.json +++ b/src/7tv-emotes/manifest.json @@ -5,7 +5,7 @@ "main", "clips" ], - "version": "1.4.22", + "version": "1.4.23", "short_name": "7TV", "name": "7TV Emotes", "author": "Melonify", @@ -14,5 +14,5 @@ "website": "https://7tv.app", "settings": "add_ons.7tv_emotes", "created": "2021-07-12T23:18:04.000Z", - "updated": "2024-03-29T22:03:31.676Z" + "updated": "2024-08-06T06:04:34.114Z" } \ No newline at end of file diff --git a/src/7tv-emotes/modules/emotes.js b/src/7tv-emotes/modules/emotes.js index 2dca11c4..5e57a306 100644 --- a/src/7tv-emotes/modules/emotes.js +++ b/src/7tv-emotes/modules/emotes.js @@ -30,6 +30,21 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module { } }); + this.settings.add('addon.seventv_emotes.emote_format', { + default: 'WEBP', + ui: { + path: 'Add-Ons > 7TV Emotes >> Emotes', + title: 'Emote Format', + description: 'The file format of the emotes to be used.', + component: 'setting-select-box', + data: [ + { value: 'WEBP', title: 'Webp' }, + { value: 'AVIF', title: 'Avif' }, + ], + + }, + }); + this.settings.add('addon.seventv_emotes.unlisted_emotes', { default: false, ui: { @@ -52,6 +67,8 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module { onEnable() { this.on('settings:changed:addon.seventv_emotes.global_emotes', () => this.updateGlobalEmotes()); + this.on('settings:changed:addon.seventv_emotes.emote_format', () => this.updateGlobalEmotes()); + this.on('settings:changed:addon.seventv_emotes.emote_format', () => this.updateChannelSets()); this.on('settings:changed:addon.seventv_emotes.channel_emotes', () => this.updateChannelSets()); this.on('settings:changed:addon.seventv_emotes.unlisted_emotes', () => this.updateChannelSets()); @@ -74,7 +91,7 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module { for (const emote of globalSet.emotes) { const convertedEmote = this.convertEmote(emote); if (!convertedEmote) continue; - + ffzEmotes.push(convertedEmote); } @@ -306,17 +323,18 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module { const emoteHostUrl = emote?.data?.host?.url; if (!emoteHostUrl) return null; - const webpEmoteVersions = emote.data.host.files.filter((value => value.format === 'WEBP')); - if (!webpEmoteVersions.length) return null; - - const emoteUrls = webpEmoteVersions.reduce((acc, value, key) => { + const format = this.settings.get('addon.seventv_emotes.emote_format'); + const formatEmoteVersions = emote.data.host.files.filter((value => value.format === format)); + if (!formatEmoteVersions.length) return null; + + const emoteUrls = formatEmoteVersions.reduce((acc, value, key) => { acc[key + 1] = `${emoteHostUrl}/${value.name}`; return acc; }, {}); let staticEmoteUrls; if (emote.data.animated) { - staticEmoteUrls = webpEmoteVersions.reduce((acc, value, key) => { + staticEmoteUrls = formatEmoteVersions.reduce((acc, value, key) => { acc[key + 1] = `${emoteHostUrl}/${value.static_name}`; return acc; }, {}); @@ -332,8 +350,8 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module { urls: emoteUrls, modifier: this.isZeroWidthEmote(emote.flags), modifier_offset: '0', - width: webpEmoteVersions[0]?.width, - height: webpEmoteVersions[0]?.height, + width: formatEmoteVersions[0]?.width, + height: formatEmoteVersions[0]?.height, click_url: this.api.getEmoteAppURL(emote), SEVENTV_emote: emote }; @@ -349,4 +367,4 @@ export default class Emotes extends FrankerFaceZ.utilities.module.Module { isEmoteUnlisted(emote) { return !emote.data.listed; } -} \ No newline at end of file +}