@@ -5,48 +5,7 @@ import {ActionType, ActionTypes, CategorySelection, CategorySkipOption, SponsorS
55import { getSkipProfile , getSkipProfileBool } from "./skipProfiles" ;
66import { VideoLabelsCacheData } from "./videoLabels" ;
77import * as CompileConfig from "../../config.json" ;
8-
9- export interface Permission {
10- canSubmit : boolean ;
11- }
12-
13- // Note that attributes that are prefixes of other attributes (like `time.start`) need to be ordered *after*
14- // the longer attributes, because these are matched sequentially. Using the longer attribute would otherwise result
15- // in an error token.
16- export enum SkipRuleAttribute {
17- StartTimePercent = "time.startPercent" ,
18- StartTime = "time.start" ,
19- EndTimePercent = "time.endPercent" ,
20- EndTime = "time.end" ,
21- DurationPercent = "time.durationPercent" ,
22- Duration = "time.duration" ,
23- Category = "category" ,
24- ActionType = "actionType" ,
25- Description = "chapter.name" ,
26- Source = "chapter.source" ,
27- ChannelID = "channel.id" ,
28- ChannelName = "channel.name" ,
29- VideoDuration = "video.duration" ,
30- Title = "video.title"
31- }
32-
33- // Note that operators that are prefixes of other attributes (like `<`) need to be ordered *after* the longer
34- // operators, because these are matched sequentially. Using the longer operator would otherwise result
35- // in an error token.
36- export enum SkipRuleOperator {
37- LessOrEqual = "<=" ,
38- Less = "<" ,
39- GreaterOrEqual = ">=" ,
40- Greater = ">" ,
41- NotEqual = "!=" ,
42- Equal = "==" ,
43- NotContains = "!*=" ,
44- Contains = "*=" ,
45- NotRegex = "!~=" ,
46- Regex = "~=" ,
47- NotRegexIgnoreCase = "!~i=" ,
48- RegexIgnoreCase = "~i="
49- }
8+ import { AdvancedSkipCheck , AdvancedSkipPredicate , AdvancedSkipRule , PredicateOperator , SkipRuleAttribute , SkipRuleOperator } from "./skipRule.type" ;
509
5110const SKIP_RULE_ATTRIBUTES = Object . values ( SkipRuleAttribute ) ;
5211const SKIP_RULE_OPERATORS = Object . values ( SkipRuleOperator ) ;
@@ -68,34 +27,6 @@ const WORD_EXTRA_CHARACTER = /[a-zA-Z0-9.]/;
6827const OPERATOR_EXTRA_CHARACTER = / [ < > = ! ~ * & | - ] / ;
6928const ANY_EXTRA_CHARACTER = / [ a - z A - Z 0 - 9 < > = ! ~ * & | . - ] / ;
7029
71- export interface AdvancedSkipCheck {
72- kind : "check" ;
73- attribute : SkipRuleAttribute ;
74- operator : SkipRuleOperator ;
75- value : string | number ;
76- }
77-
78- export enum PredicateOperator {
79- And = "and" ,
80- Or = "or" ,
81- }
82-
83- export interface AdvancedSkipOperator {
84- kind : "operator" ;
85- operator : PredicateOperator ;
86- left : AdvancedSkipPredicate ;
87- right : AdvancedSkipPredicate ;
88- displayInverted ?: boolean ;
89- }
90-
91- export type AdvancedSkipPredicate = AdvancedSkipCheck | AdvancedSkipOperator ;
92-
93- export interface AdvancedSkipRule {
94- predicate : AdvancedSkipPredicate ;
95- skipOption : CategorySkipOption ;
96- comments : string [ ] ;
97- }
98-
9930export function getCategorySelection ( segment : SponsorTime | VideoLabelsCacheData ) : CategorySelection {
10031 // First check skip rules
10132 for ( const rule of Config . local . skipRules ) {
0 commit comments