1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-11 08:30:55 +00:00
FrankerFaceZ/src/settings/filters.js
SirStendec 275248ca36 4.4.1
* Added: `Current Channel` rule for profiles, to match all pages associated with a certain channel without needing many page rules.
* Fixed: Unreadable text in light theme when importing a profile.
* Changed: Display a matching page URL in the `Current Page` rule for profiles.
* Changed: Do not display an inactive profile warning on the Add-Ons settings page, since those are not affected by profiles.
* Changed: Update Vue to a more recent version.
* Maintenance: Update the chat types enum based on the latest version of Twitch.
* API Added: `TwitchData` module (`site.twitch_data`) for querying Twitch's API for data.
2019-06-14 21:24:48 -04:00

163 lines
No EOL
3.4 KiB
JavaScript

'use strict';
// ============================================================================
// Profile Filters for Settings
// ============================================================================
import {createTester} from 'utilities/filtering';
// Logical Components
export const Invert = {
createTest(config, rule_types) {
return createTester(config, rule_types, true)
},
maxRules: 1,
childRules: true,
tall: true,
title: 'Invert',
i18n: 'settings.filter.invert',
default: () => [],
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/nested.vue')
};
export const Or = {
createTest(config, rule_types) {
return createTester(config, rule_types, false, true);
},
childRules: true,
tall: true,
title: 'Or',
i18n: 'settings.filter.or',
default: () => [],
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/nested.vue')
};
// Context Stuff
export const TheaterMode = {
createTest(config) {
return ctx => ctx.ui && ctx.ui.theatreModeEnabled === config;
},
title: 'Theater Mode',
i18n: 'settings.filter.theater',
default: true,
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/basic-toggle.vue')
};
export const Moderator = {
createTest(config) {
return ctx => ctx.moderator === config;
},
title: 'Is Moderator',
i18n: 'settings.filter.moderator',
default: true,
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/basic-toggle.vue')
};
export const SquadMode = {
createTest(config) {
return ctx => ctx.ui && ctx.ui.squadModeEnabled === config;
},
title: 'Squad Mode',
i18n: 'settings.filter.squad',
default: true,
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/basic-toggle.vue')
};
export const NativeDarkTheme = {
createTest(config) {
const val = config ? 1 : 0;
return ctx => ctx.ui && ctx.ui.theme === val;
},
title: 'Dark Theme',
i18n: 'settings.filter.native-dark',
default: true,
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/basic-toggle.vue')
};
export const Page = {
createTest(config = {}) {
const name = config.route,
parts = [];
if ( Object.keys(config.values).length ) {
const ffz = FrankerFaceZ.get(),
router = ffz && ffz.resolve('site.router');
if ( router ) {
const route = router.getRoute(name);
if ( ! route || ! route.parts )
return () => false;
let i = 1;
for(const part of route.parts) {
if ( typeof part === 'object' ) {
const val = config.values[part.name];
if ( val && val.length )
parts.push([i, val]);
i++;
}
}
} else
return () => false;
}
return ctx => {
if ( ! ctx.route || ! ctx.route_data || ctx.route.name !== name )
return false;
for(const [index, value] of parts)
if ( ctx.route_data[index] !== value )
return false;
return true;
}
},
tall: true,
title: 'Current Page',
i18n: 'settings.filter.page',
default: () => ({
route: 'front-page',
values: {}
}),
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/page.vue')
};
export const Channel = {
createTest(config = {}) {
const login = config.login,
id = config.id;
return ctx => ctx.channelID === id || (ctx.channelID == null && ctx.channelLogin === login);
},
title: 'Current Channel',
i18n: 'settings.filter.channel',
default: () => ({
login: null,
id: null
}),
editor: () => import(/* webpackChunkName: 'main-menu' */ './components/channel.vue')
};