mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-17 10:16:57 +00:00
4.20.75
* Added: Better options for highlight / block terms, letting you make rules case sensitive, match whole words, and highlight in chat or not. * Added: Documentation of glob syntax. * Changed: Split `Chat > Filtering` into several sub-categories to make it easier to find specific options. * Changed: Display seconds with the up-time metadata by default, matching Twitch. * Fixed: The Unfollow button not hiding on the standalone player. * Fixed: Loading issue for graphs on the dashboard. * API Added: Allow add-ons to target the `player` flavor.
This commit is contained in:
parent
715a92e298
commit
16ab515b4b
26 changed files with 523 additions and 220 deletions
|
@ -564,11 +564,35 @@ export const CustomHighlights = {
|
|||
if ( user && user.login && user.login == msg.user.login && ! this.context.get('chat.filtering.process-own') )
|
||||
return tokens;
|
||||
|
||||
const colors = this.context.get('chat.filtering.highlight-basic-terms--color-regex');
|
||||
if ( ! colors || ! colors.size )
|
||||
const data = this.context.get('chat.filtering.highlight-basic-terms--color-regex');
|
||||
if ( ! data )
|
||||
return tokens;
|
||||
|
||||
for(const [color, regex] of colors) {
|
||||
if ( data.non ) {
|
||||
for(const [color, regexes] of data.non) {
|
||||
let matched = false;
|
||||
if ( regexes[0] ) {
|
||||
regexes[0].lastIndex = 0;
|
||||
matched = regexes[0].test(msg.message);
|
||||
}
|
||||
if ( ! matched && regexes[1] ) {
|
||||
regexes[1].lastIndex = 0;
|
||||
matched = regexes[1].test(msg.message);
|
||||
}
|
||||
|
||||
if ( matched ) {
|
||||
(msg.highlights = (msg.highlights || new Set())).add('term');
|
||||
msg.mentioned = true;
|
||||
msg.mention_color = color || msg.mention_color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! data.hl )
|
||||
return tokens;
|
||||
|
||||
for(const [color, regexes] of data.hl) {
|
||||
const out = [];
|
||||
for(const token of tokens) {
|
||||
if ( token.type !== 'text' ) {
|
||||
|
@ -576,11 +600,23 @@ export const CustomHighlights = {
|
|||
continue;
|
||||
}
|
||||
|
||||
regex.lastIndex = 0;
|
||||
const text = token.text;
|
||||
let idx = 0, match;
|
||||
|
||||
while((match = regex.exec(text))) {
|
||||
while(idx < text.length) {
|
||||
if ( regexes[0] )
|
||||
regexes[0].lastIndex = idx;
|
||||
if ( regexes[1] )
|
||||
regexes[1].lastIndex = idx;
|
||||
|
||||
match = regexes[0] ? regexes[0].exec(text) : null;
|
||||
const second = regexes[1] ? regexes[1].exec(text) : null;
|
||||
if ( second && (! match || match.index > second.index) )
|
||||
match = second;
|
||||
|
||||
if ( ! match )
|
||||
break;
|
||||
|
||||
const raw_nix = match.index,
|
||||
offset = match[1] ? match[1].length : 0,
|
||||
nix = raw_nix + offset;
|
||||
|
@ -590,7 +626,8 @@ export const CustomHighlights = {
|
|||
|
||||
(msg.highlights = (msg.highlights || new Set())).add('term');
|
||||
msg.mentioned = true;
|
||||
msg.mention_color = color || msg.mention_color;
|
||||
if ( ! msg.mention_color )
|
||||
msg.mention_color = color;
|
||||
|
||||
out.push({
|
||||
type: 'highlight',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue