Skip to content

Commit 4646f47

Browse files
committed
Fix background script broken on chromium
1 parent 60c4a05 commit 4646f47

File tree

4 files changed

+75
-73
lines changed

4 files changed

+75
-73
lines changed

maze-utils

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as CompileConfig from "../config.json";
22
import * as invidiousList from "../ci/invidiouslist.json";
33
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorHideType, SponsorTime, VideoID, SegmentListDefaultTab } from "./types";
44
import { Keybind, keybindEquals, ProtoConfig } from "../maze-utils/src/config";
5-
import { HashedValue } from "../maze-utils/src/hash";
6-
import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule";
5+
import type { HashedValue } from "../maze-utils/src/hash";
6+
import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule.type";
77

88
interface SBConfig {
99
userID: string;

src/utils/skipRule.ts

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,7 @@ import {ActionType, ActionTypes, CategorySelection, CategorySkipOption, SponsorS
55
import { getSkipProfile, getSkipProfileBool } from "./skipProfiles";
66
import { VideoLabelsCacheData } from "./videoLabels";
77
import * 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

5110
const SKIP_RULE_ATTRIBUTES = Object.values(SkipRuleAttribute);
5211
const SKIP_RULE_OPERATORS = Object.values(SkipRuleOperator);
@@ -68,34 +27,6 @@ const WORD_EXTRA_CHARACTER = /[a-zA-Z0-9.]/;
6827
const OPERATOR_EXTRA_CHARACTER = /[<>=!~*&|-]/;
6928
const ANY_EXTRA_CHARACTER = /[a-zA-Z0-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-
9930
export function getCategorySelection(segment: SponsorTime | VideoLabelsCacheData): CategorySelection {
10031
// First check skip rules
10132
for (const rule of Config.local.skipRules) {

src/utils/skipRule.type.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import type { CategorySkipOption } from "../types";
2+
3+
export interface Permission {
4+
canSubmit: boolean;
5+
}
6+
7+
// Note that attributes that are prefixes of other attributes (like `time.start`) need to be ordered *after*
8+
// the longer attributes, because these are matched sequentially. Using the longer attribute would otherwise result
9+
// in an error token.
10+
export enum SkipRuleAttribute {
11+
StartTimePercent = "time.startPercent",
12+
StartTime = "time.start",
13+
EndTimePercent = "time.endPercent",
14+
EndTime = "time.end",
15+
DurationPercent = "time.durationPercent",
16+
Duration = "time.duration",
17+
Category = "category",
18+
ActionType = "actionType",
19+
Description = "chapter.name",
20+
Source = "chapter.source",
21+
ChannelID = "channel.id",
22+
ChannelName = "channel.name",
23+
VideoDuration = "video.duration",
24+
Title = "video.title"
25+
}
26+
27+
// Note that operators that are prefixes of other attributes (like `<`) need to be ordered *after* the longer
28+
// operators, because these are matched sequentially. Using the longer operator would otherwise result
29+
// in an error token.
30+
export enum SkipRuleOperator {
31+
LessOrEqual = "<=",
32+
Less = "<",
33+
GreaterOrEqual = ">=",
34+
Greater = ">",
35+
NotEqual = "!=",
36+
Equal = "==",
37+
NotContains = "!*=",
38+
Contains = "*=",
39+
NotRegex = "!~=",
40+
Regex = "~=",
41+
NotRegexIgnoreCase = "!~i=",
42+
RegexIgnoreCase = "~i="
43+
}
44+
45+
export interface AdvancedSkipCheck {
46+
kind: "check";
47+
attribute: SkipRuleAttribute;
48+
operator: SkipRuleOperator;
49+
value: string | number;
50+
}
51+
52+
export enum PredicateOperator {
53+
And = "and",
54+
Or = "or",
55+
}
56+
57+
export interface AdvancedSkipOperator {
58+
kind: "operator";
59+
operator: PredicateOperator;
60+
left: AdvancedSkipPredicate;
61+
right: AdvancedSkipPredicate;
62+
displayInverted?: boolean;
63+
}
64+
65+
export type AdvancedSkipPredicate = AdvancedSkipCheck | AdvancedSkipOperator;
66+
67+
export interface AdvancedSkipRule {
68+
predicate: AdvancedSkipPredicate;
69+
skipOption: CategorySkipOption;
70+
comments: string[];
71+
}

0 commit comments

Comments
 (0)