diff --git a/resources/liriklive/icon.png b/resources/liriklive/icon.png index 2f089b9..39d3c59 100644 Binary files a/resources/liriklive/icon.png and b/resources/liriklive/icon.png differ diff --git a/src/entry.js b/src/entry.js index eb270b1..ce345ed 100644 --- a/src/entry.js +++ b/src/entry.js @@ -1,15 +1,18 @@ -/* global window, XMLHttpRequest */ +/* global window */ /* eslint no-console: ["error", { allow: ["warn"] }] */ 'use strict'; (() => { - const script = window.document.createElement('script'); - const checkFFZInterval = attempts => { if (window.FrankerFaceZ) { - if (!window.document.head.querySelector('#ffz-ap-script')) { - window.document.head.appendChild(script); + if (window.localStorage.ffz_ap_converted !== 'true') { + window.ffz.addons.on(':ready', () => { + window.ffz.addons.enableAddon('ffzap-core'); + window.ffz.addons.enableAddon('ffzap-bttv'); + window.ffz.addons.enableAddon('ffzap-liriklive'); + window.localStorage.ffz_ap_converted = true; + }); } } else { const newAttempts = (attempts || 0) + 1; @@ -24,27 +27,5 @@ // Don't run on certain sub-domains. if (/^(?:player|im|chatdepot|tmi|api|spade|api-akamai|dev|)\./.test(window.location.hostname)) return; - const DEBUG = window.localStorage.ffz_ap_debug_mode === 'true' && !window.Ember; - const SERVER = DEBUG ? '//localhost:3000' : '//cdn.ffzap.com'; - const FLAVOR = window.Ember ? 'hades' : 'demeter'; - - script.id = 'ffz-ap-script'; - script.src = `${SERVER}/script/${FLAVOR}.js`; - - if (DEBUG) { - const xhr = new XMLHttpRequest(); - xhr.open('GET', script.src, true); - xhr.onload = () => { - console.warn('[FFZ:AP] Development server is present.'); - setTimeout(checkFFZInterval, 1000); - }; - xhr.onerror = () => { - console.warn('[FFZ:AP] Development server not present. Falling back to CDN.'); - script.src = `//cdn.ffzap.com/script/${FLAVOR}.js`; - setTimeout(checkFFZInterval, 1000); - }; - xhr.send(null); - } else { - setTimeout(checkFFZInterval, 1000); - } + setTimeout(checkFFZInterval, 1000); })(); diff --git a/src/v4/betterttv/index.js b/src/v4/betterttv/index.js index eec491c..0a8bb15 100644 --- a/src/v4/betterttv/index.js +++ b/src/v4/betterttv/index.js @@ -9,7 +9,7 @@ const GIF_EMOTES_MODE = { ANIMATED: 2, }; -class BetterTTV extends FrankerFaceZ.utilities.module.Module { +class BetterTTV extends FrankerFaceZ.utilities.addon.Addon { constructor(...args) { super(...args); @@ -23,7 +23,7 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { default: true, ui: { - path: 'Add-Ons > FFZ:AP > BetterTTV >> Emotes', + path: 'Add-Ons > BetterTTV Emotes >> Emotes', title: 'Global Emotes', description: 'Enable to show global BetterTTV emoticons.', component: 'setting-check-box', @@ -34,7 +34,7 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { default: true, ui: { - path: 'Add-Ons > FFZ:AP > BetterTTV >> Emotes', + path: 'Add-Ons > BetterTTV Emotes >> Emotes', title: 'Arbitrary Emotes', description: 'Enable to show arbitrary emoticons (like D:, :tf:, (poolparty), :\'( and similar).', component: 'setting-check-box', @@ -45,7 +45,7 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { default: true, ui: { - path: 'Add-Ons > FFZ:AP > BetterTTV >> Emotes', + path: 'Add-Ons > BetterTTV Emotes >> Emotes', title: 'Channel Emotes', description: 'Enable to show per-channel BetterTTV emoticons.', component: 'setting-check-box', @@ -56,7 +56,7 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { default: 1, ui: { - path: 'Add-Ons > FFZ:AP > BetterTTV >> Emotes', + path: 'Add-Ons > BetterTTV Emotes >> Emotes', title: 'GIF Emotes', description: 'Change the mode of how GIF emoticons are showing up.', component: 'setting-select-box', @@ -72,7 +72,7 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { default: true, ui: { - path: 'Add-Ons > FFZ:AP > BetterTTV >> Emotes', + path: 'Add-Ons > BetterTTV Emotes >> Emotes', title: 'Pro Emotes', description: 'Enable to show BetterTTV Pro emoticons.', component: 'setting-check-box', @@ -105,10 +105,12 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { this.pro_users = {}; this.night_subs = {}; this.socket = false; + + this.enable(); } onEnable() { - this.log.debug('FFZ:AP\'s BetterTTV module was enabled successfully.'); + this.log.debug('FFZ:AP\'s BetterTTV Emotes module was enabled successfully.'); this.on('chat:room-add', this.roomAdd); this.on('chat:room-remove', this.roomRemove); @@ -474,4 +476,5 @@ class BetterTTV extends FrankerFaceZ.utilities.module.Module { } } -FrankerFaceZ.get().register('addon.ffzap.betterttv', BetterTTV).enable(); +// FrankerFaceZ.get().register('addon.ffzap.betterttv', BetterTTV).enable(); +BetterTTV.register('ffzap-bttv'); diff --git a/src/v4/core/index.js b/src/v4/core/index.js index d266a28..56085a9 100644 --- a/src/v4/core/index.js +++ b/src/v4/core/index.js @@ -1,6 +1,6 @@ /* global FrankerFaceZ, fetch */ -class FFZAP extends FrankerFaceZ.utilities.module.Module { +class FFZAP extends FrankerFaceZ.utilities.addon.Addon { constructor(...args) { super(...args); @@ -38,7 +38,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { default: false, ui: { - path: 'Add-Ons > FFZ:AP > Core >> Emotes', + path: 'Add-Ons > FFZ:AP Core >> Emotes', title: 'Remove Spaces Between Emotes', description: 'Enable to remove spaces inbetween emotes when they are right after one another. (e.g. combo emotes)', component: 'setting-check-box', @@ -49,7 +49,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { default: 0, ui: { - path: 'Add-Ons > FFZ:AP > Core >> Chat', + path: 'Add-Ons > FFZ:AP Core >> Chat', title: 'Message User-Level Filtering', description: 'Messages will be removed from chat entirely if they aren\'t sent by a user of this level or higher.', component: 'setting-select-box', @@ -65,7 +65,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { default: false, ui: { - path: 'Add-Ons > FFZ:AP > Core >> Highlight Sounds', + path: 'Add-Ons > FFZ:AP Core >> Highlight Sounds', title: 'Enable Highlight Sound', description: 'Enable to hear a sound every time you\'re mentioned.', component: 'setting-check-box', @@ -76,7 +76,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { default: false, ui: { - path: 'Add-Ons > FFZ:AP > Core >> Highlight Sounds', + path: 'Add-Ons > FFZ:AP Core >> Highlight Sounds', title: 'Prevent in own Channel', description: 'Enable to prevent the sound from playing in your own channel.', component: 'setting-check-box', @@ -87,7 +87,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { default: 'https://cdn.ffzap.com/sounds/default_wet.mp3', ui: { - path: 'Add-Ons > FFZ:AP > Core >> Highlight Sounds', + path: 'Add-Ons > FFZ:AP Core >> Highlight Sounds', title: 'Sound File', description: 'Change the sound that will play when you get mentioned.', component: 'setting-combo-box', @@ -126,7 +126,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { default: 50, ui: { - path: 'Add-Ons > FFZ:AP > Core >> Highlight Sounds', + path: 'Add-Ons > FFZ:AP Core >> Highlight Sounds', title: 'Highlight Sound Volume', description: 'Change the volume at which the highlight sounds will be played at.', component: 'setting-select-box', @@ -192,6 +192,8 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { }; this.chat.addTokenizer(this.remove_spaces_tokenizer); + + this.enable(); } onEnable() { @@ -240,7 +242,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { } } - async initDeveloper() { + initDeveloper() { const developerBadge = { id: 'developer', title: 'FFZ:AP Developer', @@ -261,8 +263,6 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { async fetchSupporters() { const host = 'https://api.ffzap.com/supporters'; - const local_user = this.resolve('site').getUser(); - let needsNotify = false; const supporterBadge = { id: 'supporter', @@ -289,10 +289,6 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { if (!user.tier) continue; - if (local_user && local_user.id == user.id && user.legacy) { - needsNotify = true; - } - const ffzUser = this.chat.getUser(user.id); const badge = { @@ -315,23 +311,8 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module { this.added_supporters.push(user.id); } } - - if (needsNotify) { - setTimeout(this.showGameWispNotification, 1000); - } } - - // async initTier2Emotes() { // eslint-disable-line class-methods-use-this - // const response = await fetch('https://api.frankerfacez.com/v1/set/105031'); - // if (response.ok) { - // const data = await response.json(); - // data.set.title = 'Monthly Emote-Vote'; - // data.set.source = 'FFZ:AP'; - // this.emotes.loadSetData('addon--ffzap.core--emotes-tier2', data.set); - - // this.chat.getUser(undefined, 'lordmau5').addSet('addon--ffzap.core', 'addon--ffzap.core--emotes-tier2'); - // } - // } } -FrankerFaceZ.get().register('addon.ffzap.core', FFZAP).enable(); +// FrankerFaceZ.get().register('addon.ffzap.core', FFZAP).enable(); +FFZAP.register('ffzap-core'); diff --git a/src/v4/liriklive/index.js b/src/v4/liriklive/index.js index 7d28f66..733ecdd 100644 --- a/src/v4/liriklive/index.js +++ b/src/v4/liriklive/index.js @@ -8,7 +8,7 @@ const GIF_EMOTES_MODE = { ANIMATED: 2, }; -class LirikLIVE extends FrankerFaceZ.utilities.module.Module { +class LirikLIVE extends FrankerFaceZ.utilities.addon.Addon { constructor(...args) { super(...args); @@ -21,7 +21,7 @@ class LirikLIVE extends FrankerFaceZ.utilities.module.Module { default: true, ui: { - path: 'Add-Ons > FFZ:AP > LIRIK LIVE @{"description": "LIRIK LIVE idea by OBAN_INTERNET"} >> Emotes', + path: 'Add-Ons > Lirik LIVE >> Emotes', title: 'Global Emotes', description: 'Enable to show LIRIK LIVE global emotes.', component: 'setting-check-box', @@ -32,7 +32,7 @@ class LirikLIVE extends FrankerFaceZ.utilities.module.Module { default: 2, ui: { - path: 'Add-Ons > FFZ:AP > LIRIK LIVE >> Emotes', + path: 'Add-Ons > Lirik LIVE >> Emotes', title: 'GIF Emotes', description: 'Change the mode of how GIF emotes are showing up.', component: 'setting-select-box', @@ -48,7 +48,7 @@ class LirikLIVE extends FrankerFaceZ.utilities.module.Module { default: true, ui: { - path: 'Add-Ons > FFZ:AP > LIRIK LIVE >> Emotes', + path: 'Add-Ons > Lirik LIVE >> Emotes', title: 'Subscriber Emotes', description: 'Enable to show additional LIRIK LIVE subscriber emotes.', component: 'setting-check-box', @@ -61,10 +61,12 @@ class LirikLIVE extends FrankerFaceZ.utilities.module.Module { this.socket = false; this._last_emote_id = 0; + + this.enable(); } onEnable() { - this.log.debug('FFZ:AP\'s LirikLIVE module was enabled successfully.'); + this.log.debug('FFZ:AP\'s Lirik LIVE module was enabled successfully.'); this.updateEmotes(); @@ -322,4 +324,5 @@ class LirikLIVE extends FrankerFaceZ.utilities.module.Module { } } -FrankerFaceZ.get().register('addon.ffzap.liriklive', LirikLIVE).enable(); +// FrankerFaceZ.get().register('addon.ffzap.liriklive', LirikLIVE).enable(); +LirikLIVE.register('ffzap-liriklive');