mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-05 18:48:31 +00:00
4.0.0-rc4.6
* Fixed: Add support for Twitch's new emote data structure.
This commit is contained in:
parent
17fb41f083
commit
46da3ee4ee
6 changed files with 59 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
|||
<div class="list-header">4.0.0-rc4.6<span>@88d18379ce08c403e3f0</span> <time datetime="2018-07-13">(2018-07-13)</time></div>
|
||||
<ul class="chat-menu-content menu-side-padding">
|
||||
<li>Fixed: Add support for Twitch's new emote data structure format.</li>
|
||||
</ul>
|
||||
|
||||
<div class="list-header">4.0.0-rc4.5<span>@f47412afa7703e2d3b18</span> <time datetime="2018-07-13">(2018-07-13)</time></div>
|
||||
<ul class="chat-menu-content menu-side-padding">
|
||||
<li>Added: Whisper Support</li>
|
||||
|
|
|
@ -100,7 +100,7 @@ class FrankerFaceZ extends Module {
|
|||
FrankerFaceZ.Logger = Logger;
|
||||
|
||||
const VER = FrankerFaceZ.version_info = {
|
||||
major: 4, minor: 0, revision: 0, extra: '-rc4.5',
|
||||
major: 4, minor: 0, revision: 0, extra: '-rc4.6',
|
||||
build: __webpack_hash__,
|
||||
toString: () =>
|
||||
`${VER.major}.${VER.minor}.${VER.revision}${VER.extra || ''}${DEBUG ? '-dev' : ''}`
|
||||
|
|
|
@ -636,6 +636,10 @@ export default class Chat extends Module {
|
|||
msg.message = msg.content.text;
|
||||
}
|
||||
|
||||
// Standardize Emotes
|
||||
if ( ! msg.ffz_emotes )
|
||||
this.standardizeEmotes(msg);
|
||||
|
||||
// Standardize Badges
|
||||
if ( ! msg.badges && user.displayBadges ) {
|
||||
const b = msg.badges = {};
|
||||
|
@ -655,7 +659,39 @@ export default class Chat extends Module {
|
|||
}
|
||||
|
||||
|
||||
detokenizeContent(msg) { // eslint-disable-line class-methods-use-this
|
||||
standardizeEmotes(msg) { // eslint-disable-line class-methods-use-this
|
||||
if ( msg.emotes && msg.message ) {
|
||||
const emotes = {},
|
||||
chars = split_chars(msg.message);
|
||||
|
||||
for(const key in msg.emotes)
|
||||
if ( has(msg.emotes, key) ) {
|
||||
const raw_emote = msg.emotes[key];
|
||||
if ( Array.isArray(raw_emote) )
|
||||
return msg.ffz_emotes = msg.emotes;
|
||||
|
||||
const em = emotes[raw_emote.id] = emotes[raw_emote.id] || [],
|
||||
idx = chars.indexOf(' ', raw_emote.startIndex);
|
||||
|
||||
em.push({
|
||||
startIndex: raw_emote.startIndex,
|
||||
endIndex: (idx === -1 ? chars.length : idx) - 1
|
||||
});
|
||||
}
|
||||
|
||||
msg.ffz_emotes = emotes;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( msg.messageParts )
|
||||
this.detokenizeMessage(msg, true);
|
||||
|
||||
else if ( msg.content && msg.content.fragments )
|
||||
this.detokenizeContent(msg, true);
|
||||
}
|
||||
|
||||
|
||||
detokenizeContent(msg, emotes_only = false) { // eslint-disable-line class-methods-use-this
|
||||
const out = [],
|
||||
parts = msg.content.fragments,
|
||||
l = parts.length,
|
||||
|
@ -688,13 +724,15 @@ export default class Chat extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! emotes_only )
|
||||
msg.message = out.join('');
|
||||
msg.emotes = emotes;
|
||||
|
||||
msg.ffz_emotes = emotes;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
detokenizeMessage(msg) { // eslint-disable-line class-methods-use-this
|
||||
detokenizeMessage(msg, emotes_only = false) { // eslint-disable-line class-methods-use-this
|
||||
const out = [],
|
||||
parts = msg.messageParts,
|
||||
l = parts.length,
|
||||
|
@ -742,14 +780,16 @@ export default class Chat extends Module {
|
|||
continue;
|
||||
|
||||
if ( ret ) {
|
||||
idx += ret.length;
|
||||
idx += split_chars(ret).length;
|
||||
last_type = part.type;
|
||||
out.push(ret)
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! emotes_only )
|
||||
msg.message = out.join('');
|
||||
msg.emotes = emotes;
|
||||
|
||||
msg.ffz_emotes = emotes;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
|
@ -921,10 +921,10 @@ export const TwitchEmotes = {
|
|||
priority: 20,
|
||||
|
||||
process(tokens, msg) {
|
||||
if ( ! msg.emotes )
|
||||
if ( ! msg.ffz_emotes )
|
||||
return tokens;
|
||||
|
||||
const data = msg.emotes,
|
||||
const data = msg.ffz_emotes,
|
||||
emotes = [];
|
||||
|
||||
for(const emote_id in data)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import {ColorAdjuster} from 'utilities/color';
|
||||
import {setChildren} from 'utilities/dom';
|
||||
import {has, split_chars, shallow_object_equals} from 'utilities/object';
|
||||
import {has, split_chars, shallow_object_equals, deep_copy} from 'utilities/object';
|
||||
import {FFZEvent} from 'utilities/events';
|
||||
|
||||
import Module from 'utilities/module';
|
||||
|
@ -658,7 +658,7 @@ export default class ChatHook extends Module {
|
|||
this.onChatMessageEvent = function(e) {
|
||||
if ( e && e.sentByCurrentUser ) {
|
||||
try {
|
||||
e.message.user.emotes = findEmotes(
|
||||
e.message.ffz_emotes = findEmotes(
|
||||
e.message.body,
|
||||
i.ffzGetEmotes()
|
||||
);
|
||||
|
@ -676,7 +676,7 @@ export default class ChatHook extends Module {
|
|||
this.onChatActionEvent = function(e) {
|
||||
if ( e && e.sentByCurrentUser ) {
|
||||
try {
|
||||
e.message.user.emotes = findEmotes(
|
||||
e.message.ffz_emotes = findEmotes(
|
||||
e.message.body.slice(8, -1),
|
||||
i.ffzGetEmotes()
|
||||
);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
.get-bits-button,
|
||||
.chat-input button[data-a-target="bits-button"],
|
||||
button[data-test-selector="get-bits-button__top-nav-button"],
|
||||
.channel-header__right > .tw-mg-l-1 > div > div > button:not([data-a-target]) {
|
||||
display: none;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue