Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Push changes from Add-On system merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordmau5 committed Jun 13, 2019
1 parent d882576 commit 511e68b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 73 deletions.
Binary file modified resources/liriklive/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 9 additions & 28 deletions src/entry.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
})();
19 changes: 11 additions & 8 deletions src/v4/betterttv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
43 changes: 12 additions & 31 deletions src/v4/core/index.js
Original file line number Diff line number Diff line change
@@ -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);

Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -192,6 +192,8 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module {
};

this.chat.addTokenizer(this.remove_spaces_tokenizer);

this.enable();
}

onEnable() {
Expand Down Expand Up @@ -240,7 +242,7 @@ class FFZAP extends FrankerFaceZ.utilities.module.Module {
}
}

async initDeveloper() {
initDeveloper() {
const developerBadge = {
id: 'developer',
title: 'FFZ:AP Developer',
Expand All @@ -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',
Expand All @@ -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 = {
Expand All @@ -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');
15 changes: 9 additions & 6 deletions src/v4/liriklive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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();

Expand Down Expand Up @@ -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');

0 comments on commit 511e68b

Please sign in to comment.