mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-07 06:40:54 +00:00
4.20.12
* Fixed: The Channel Title settings profile not working. * Fixed: Remove an unnecessary import that VS Code *helpfully* forced into the channel module last commit. * Changed: Only load the `safe-regex` module on demand, it's kind of hefty.
This commit is contained in:
parent
22c60050e0
commit
5b76e7c22a
6 changed files with 50 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "frankerfacez",
|
||||
"author": "Dan Salvato LLC",
|
||||
"version": "4.20.11",
|
||||
"version": "4.20.12",
|
||||
"description": "FrankerFaceZ is a Twitch enhancement suite.",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
|
|
|
@ -4,17 +4,25 @@
|
|||
// Profile Filters for Settings
|
||||
// ============================================================================
|
||||
|
||||
import safety from 'safe-regex';
|
||||
|
||||
import {glob_to_regex, escape_regex} from 'utilities/object';
|
||||
import {createTester} from 'utilities/filtering';
|
||||
|
||||
let safety = null;
|
||||
|
||||
function loadSafety(cb) {
|
||||
import(/* webpackChunkName: 'regex' */ 'safe-regex').then(thing => {
|
||||
safety = thing.default;
|
||||
if ( cb )
|
||||
cb();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Logical Components
|
||||
|
||||
export const Invert = {
|
||||
createTest(config, rule_types) {
|
||||
return createTester(config, rule_types, true)
|
||||
createTest(config, rule_types, rebuild) {
|
||||
return createTester(config, rule_types, true, false, rebuild)
|
||||
},
|
||||
|
||||
maxRules: 1,
|
||||
|
@ -29,8 +37,8 @@ export const Invert = {
|
|||
};
|
||||
|
||||
export const Or = {
|
||||
createTest(config, rule_types) {
|
||||
return createTester(config, rule_types, false, true);
|
||||
createTest(config, rule_types, rebuild) {
|
||||
return createTester(config, rule_types, false, true, rebuild);
|
||||
},
|
||||
|
||||
childRules: true,
|
||||
|
@ -44,10 +52,10 @@ export const Or = {
|
|||
};
|
||||
|
||||
export const If = {
|
||||
createTest(config, rule_types) {
|
||||
const cond = createTester(config[0], rule_types),
|
||||
if_true = createTester(config[1], rule_types),
|
||||
if_false = createTester(config[2], rule_types);
|
||||
createTest(config, rule_types, rebuild) {
|
||||
const cond = createTester(config[0], rule_types, false, false, rebuild),
|
||||
if_true = createTester(config[1], rule_types, false, false, rebuild),
|
||||
if_false = createTester(config[2], rule_types, false, false, rebuild);
|
||||
|
||||
return ctx => cond(ctx) ? if_true(ctx) : if_false(ctx)
|
||||
},
|
||||
|
@ -289,20 +297,30 @@ export const Category = {
|
|||
}
|
||||
|
||||
export const Title = {
|
||||
createTest(config = {}) {
|
||||
createTest(config = {}, _, reload) {
|
||||
const mode = config.mode;
|
||||
let title = config.title;
|
||||
let title = config.title,
|
||||
need_safety = true;
|
||||
|
||||
if ( ! title || ! mode )
|
||||
return () => false;
|
||||
|
||||
if ( mode === 'text' )
|
||||
if ( mode === 'text' ) {
|
||||
title = escape_regex(title);
|
||||
else if ( mode === 'glob' )
|
||||
need_safety = false;
|
||||
} else if ( mode === 'glob' )
|
||||
title = glob_to_regex(title);
|
||||
else if ( mode !== 'raw' )
|
||||
return () => false;
|
||||
|
||||
if ( need_safety ) {
|
||||
if ( ! safety )
|
||||
loadSafety(reload);
|
||||
|
||||
if ( ! safety || ! safety(title) )
|
||||
return () => false;
|
||||
}
|
||||
|
||||
if ( ! safety(title) )
|
||||
return () => false;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
import Module from 'utilities/module';
|
||||
import {deep_equals, has} from 'utilities/object';
|
||||
import {deep_equals, has, debounce} from 'utilities/object';
|
||||
|
||||
import {CloudStorageProvider, LocalStorageProvider} from './providers';
|
||||
import SettingsProfile from './profile';
|
||||
|
@ -32,6 +32,8 @@ export default class SettingsManager extends Module {
|
|||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.updateSoon = debounce(() => this.updateRoutes(), 50, false);
|
||||
|
||||
// State
|
||||
this.__contexts = [];
|
||||
this.__profiles = [];
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class SettingsProfile extends EventEmitter {
|
|||
|
||||
matches(context) {
|
||||
if ( ! this.matcher )
|
||||
this.matcher = createTester(this.context, this.manager.filters);
|
||||
this.matcher = createTester(this.context, this.manager.filters, false, false, () => this.manager.updateSoon());
|
||||
|
||||
return this.matcher(context);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import Module from 'utilities/module';
|
||||
import { Color } from 'utilities/color';
|
||||
import {debounce} from 'utilities/object';
|
||||
import { valueToNode } from 'C:/Users/Stendec/AppData/Local/Microsoft/TypeScript/3.8/node_modules/@babel/types/lib/index';
|
||||
|
||||
|
||||
const USER_PAGES = ['user', 'video', 'user-video', 'user-clip', 'user-videos', 'user-clips', 'user-collections', 'user-events', 'user-followers', 'user-following'];
|
||||
|
@ -182,13 +181,23 @@ export default class Channel extends Module {
|
|||
}
|
||||
|
||||
const react = this.fine.getReactInstance(el),
|
||||
props = react?.memoizedProps?.children?.props;
|
||||
props = react?.child?.memoizedProps;
|
||||
|
||||
if ( ! el._ffz_cont || ! props?.channelID ) {
|
||||
this.updateSubscription(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const other_props = react.child.child?.child?.child?.child?.child?.child?.child?.child?.memoizedProps,
|
||||
title = other_props?.title;
|
||||
|
||||
if ( title !== el._ffz_title_cache ) {
|
||||
el._ffz_title_cache = title;
|
||||
this.settings.updateContext({
|
||||
title
|
||||
});
|
||||
}
|
||||
|
||||
if ( ! this.settings.get('channel.hosting.enable') && props.hostLogin )
|
||||
this.setHost(props.channelID, props.channelLogin, null, null);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Advanced Filter System
|
||||
// ============================================================================
|
||||
|
||||
export function createTester(rules, filter_types, inverted = false, or = false) {
|
||||
export function createTester(rules, filter_types, inverted = false, or = false, rebuild) {
|
||||
if ( ! Array.isArray(rules) || ! filter_types )
|
||||
return inverted ? () => false : () => true;
|
||||
|
||||
|
@ -21,7 +21,7 @@ export function createTester(rules, filter_types, inverted = false, or = false)
|
|||
continue;
|
||||
|
||||
i++;
|
||||
tests.push(type.createTest(rule.data, filter_types));
|
||||
tests.push(type.createTest(rule.data, filter_types, rebuild));
|
||||
names.push(`f${i}`);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue