From 4646f471bcc7b0709267eb0bc70e82ca1902f3c2 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 23 Oct 2025 03:25:01 -0400 Subject: [PATCH] Fix background script broken on chromium --- maze-utils | 2 +- src/config.ts | 4 +-- src/utils/skipRule.ts | 71 +------------------------------------- src/utils/skipRule.type.ts | 71 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 73 deletions(-) create mode 100644 src/utils/skipRule.type.ts diff --git a/maze-utils b/maze-utils index 04ddfb9b..49dad0e6 160000 --- a/maze-utils +++ b/maze-utils @@ -1 +1 @@ -Subproject commit 04ddfb9be1dbdfadad87909031e2519babb8b009 +Subproject commit 49dad0e67b0f56d0446a6e605b7294ef38799b27 diff --git a/src/config.ts b/src/config.ts index e26cfd73..1ec04475 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,8 +2,8 @@ import * as CompileConfig from "../config.json"; import * as invidiousList from "../ci/invidiouslist.json"; import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorHideType, SponsorTime, VideoID, SegmentListDefaultTab } from "./types"; import { Keybind, keybindEquals, ProtoConfig } from "../maze-utils/src/config"; -import { HashedValue } from "../maze-utils/src/hash"; -import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule"; +import type { HashedValue } from "../maze-utils/src/hash"; +import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule.type"; interface SBConfig { userID: string; diff --git a/src/utils/skipRule.ts b/src/utils/skipRule.ts index b94961dd..f8001368 100644 --- a/src/utils/skipRule.ts +++ b/src/utils/skipRule.ts @@ -5,48 +5,7 @@ import {ActionType, ActionTypes, CategorySelection, CategorySkipOption, SponsorS import { getSkipProfile, getSkipProfileBool } from "./skipProfiles"; import { VideoLabelsCacheData } from "./videoLabels"; import * as CompileConfig from "../../config.json"; - -export interface Permission { - canSubmit: boolean; -} - -// Note that attributes that are prefixes of other attributes (like `time.start`) need to be ordered *after* -// the longer attributes, because these are matched sequentially. Using the longer attribute would otherwise result -// in an error token. -export enum SkipRuleAttribute { - StartTimePercent = "time.startPercent", - StartTime = "time.start", - EndTimePercent = "time.endPercent", - EndTime = "time.end", - DurationPercent = "time.durationPercent", - Duration = "time.duration", - Category = "category", - ActionType = "actionType", - Description = "chapter.name", - Source = "chapter.source", - ChannelID = "channel.id", - ChannelName = "channel.name", - VideoDuration = "video.duration", - Title = "video.title" -} - -// Note that operators that are prefixes of other attributes (like `<`) need to be ordered *after* the longer -// operators, because these are matched sequentially. Using the longer operator would otherwise result -// in an error token. -export enum SkipRuleOperator { - LessOrEqual = "<=", - Less = "<", - GreaterOrEqual = ">=", - Greater = ">", - NotEqual = "!=", - Equal = "==", - NotContains = "!*=", - Contains = "*=", - NotRegex = "!~=", - Regex = "~=", - NotRegexIgnoreCase = "!~i=", - RegexIgnoreCase = "~i=" -} +import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, PredicateOperator, SkipRuleAttribute, SkipRuleOperator } from "./skipRule.type"; const SKIP_RULE_ATTRIBUTES = Object.values(SkipRuleAttribute); const SKIP_RULE_OPERATORS = Object.values(SkipRuleOperator); @@ -68,34 +27,6 @@ const WORD_EXTRA_CHARACTER = /[a-zA-Z0-9.]/; const OPERATOR_EXTRA_CHARACTER = /[<>=!~*&|-]/; const ANY_EXTRA_CHARACTER = /[a-zA-Z0-9<>=!~*&|.-]/; -export interface AdvancedSkipCheck { - kind: "check"; - attribute: SkipRuleAttribute; - operator: SkipRuleOperator; - value: string | number; -} - -export enum PredicateOperator { - And = "and", - Or = "or", -} - -export interface AdvancedSkipOperator { - kind: "operator"; - operator: PredicateOperator; - left: AdvancedSkipPredicate; - right: AdvancedSkipPredicate; - displayInverted?: boolean; -} - -export type AdvancedSkipPredicate = AdvancedSkipCheck | AdvancedSkipOperator; - -export interface AdvancedSkipRule { - predicate: AdvancedSkipPredicate; - skipOption: CategorySkipOption; - comments: string[]; -} - export function getCategorySelection(segment: SponsorTime | VideoLabelsCacheData): CategorySelection { // First check skip rules for (const rule of Config.local.skipRules) { diff --git a/src/utils/skipRule.type.ts b/src/utils/skipRule.type.ts new file mode 100644 index 00000000..76f6bee6 --- /dev/null +++ b/src/utils/skipRule.type.ts @@ -0,0 +1,71 @@ +import type { CategorySkipOption } from "../types"; + +export interface Permission { + canSubmit: boolean; +} + +// Note that attributes that are prefixes of other attributes (like `time.start`) need to be ordered *after* +// the longer attributes, because these are matched sequentially. Using the longer attribute would otherwise result +// in an error token. +export enum SkipRuleAttribute { + StartTimePercent = "time.startPercent", + StartTime = "time.start", + EndTimePercent = "time.endPercent", + EndTime = "time.end", + DurationPercent = "time.durationPercent", + Duration = "time.duration", + Category = "category", + ActionType = "actionType", + Description = "chapter.name", + Source = "chapter.source", + ChannelID = "channel.id", + ChannelName = "channel.name", + VideoDuration = "video.duration", + Title = "video.title" +} + +// Note that operators that are prefixes of other attributes (like `<`) need to be ordered *after* the longer +// operators, because these are matched sequentially. Using the longer operator would otherwise result +// in an error token. +export enum SkipRuleOperator { + LessOrEqual = "<=", + Less = "<", + GreaterOrEqual = ">=", + Greater = ">", + NotEqual = "!=", + Equal = "==", + NotContains = "!*=", + Contains = "*=", + NotRegex = "!~=", + Regex = "~=", + NotRegexIgnoreCase = "!~i=", + RegexIgnoreCase = "~i=" +} + +export interface AdvancedSkipCheck { + kind: "check"; + attribute: SkipRuleAttribute; + operator: SkipRuleOperator; + value: string | number; +} + +export enum PredicateOperator { + And = "and", + Or = "or", +} + +export interface AdvancedSkipOperator { + kind: "operator"; + operator: PredicateOperator; + left: AdvancedSkipPredicate; + right: AdvancedSkipPredicate; + displayInverted?: boolean; +} + +export type AdvancedSkipPredicate = AdvancedSkipCheck | AdvancedSkipOperator; + +export interface AdvancedSkipRule { + predicate: AdvancedSkipPredicate; + skipOption: CategorySkipOption; + comments: string[]; +} \ No newline at end of file