mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 03:27:03 +03:00
Fix background script broken on chromium
This commit is contained in:
Submodule maze-utils updated: 04ddfb9be1...49dad0e67b
@@ -2,8 +2,8 @@ import * as CompileConfig from "../config.json";
|
|||||||
import * as invidiousList from "../ci/invidiouslist.json";
|
import * as invidiousList from "../ci/invidiouslist.json";
|
||||||
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorHideType, SponsorTime, VideoID, SegmentListDefaultTab } from "./types";
|
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorHideType, SponsorTime, VideoID, SegmentListDefaultTab } from "./types";
|
||||||
import { Keybind, keybindEquals, ProtoConfig } from "../maze-utils/src/config";
|
import { Keybind, keybindEquals, ProtoConfig } from "../maze-utils/src/config";
|
||||||
import { HashedValue } from "../maze-utils/src/hash";
|
import type { HashedValue } from "../maze-utils/src/hash";
|
||||||
import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule";
|
import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule.type";
|
||||||
|
|
||||||
interface SBConfig {
|
interface SBConfig {
|
||||||
userID: string;
|
userID: string;
|
||||||
|
|||||||
@@ -5,48 +5,7 @@ import {ActionType, ActionTypes, CategorySelection, CategorySkipOption, SponsorS
|
|||||||
import { getSkipProfile, getSkipProfileBool } from "./skipProfiles";
|
import { getSkipProfile, getSkipProfileBool } from "./skipProfiles";
|
||||||
import { VideoLabelsCacheData } from "./videoLabels";
|
import { VideoLabelsCacheData } from "./videoLabels";
|
||||||
import * as CompileConfig from "../../config.json";
|
import * as CompileConfig from "../../config.json";
|
||||||
|
import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, PredicateOperator, SkipRuleAttribute, SkipRuleOperator } from "./skipRule.type";
|
||||||
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="
|
|
||||||
}
|
|
||||||
|
|
||||||
const SKIP_RULE_ATTRIBUTES = Object.values(SkipRuleAttribute);
|
const SKIP_RULE_ATTRIBUTES = Object.values(SkipRuleAttribute);
|
||||||
const SKIP_RULE_OPERATORS = Object.values(SkipRuleOperator);
|
const SKIP_RULE_OPERATORS = Object.values(SkipRuleOperator);
|
||||||
@@ -68,34 +27,6 @@ const WORD_EXTRA_CHARACTER = /[a-zA-Z0-9.]/;
|
|||||||
const OPERATOR_EXTRA_CHARACTER = /[<>=!~*&|-]/;
|
const OPERATOR_EXTRA_CHARACTER = /[<>=!~*&|-]/;
|
||||||
const ANY_EXTRA_CHARACTER = /[a-zA-Z0-9<>=!~*&|.-]/;
|
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 {
|
export function getCategorySelection(segment: SponsorTime | VideoLabelsCacheData): CategorySelection {
|
||||||
// First check skip rules
|
// First check skip rules
|
||||||
for (const rule of Config.local.skipRules) {
|
for (const rule of Config.local.skipRules) {
|
||||||
|
|||||||
71
src/utils/skipRule.type.ts
Normal file
71
src/utils/skipRule.type.ts
Normal file
@@ -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[];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user