mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +03:00
Add channel id and name attribute for advanced skip options
This commit is contained in:
@@ -2,11 +2,10 @@ import { DataCache } from "../../maze-utils/src/cache";
|
||||
import { getHash, HashedValue } from "../../maze-utils/src/hash";
|
||||
import Config, { } from "../config";
|
||||
import * as CompileConfig from "../../config.json";
|
||||
import { ActionType, ActionTypes, CategorySkipOption, SponsorSourceType, SponsorTime, VideoID } from "../types";
|
||||
import { ActionType, ActionTypes, SponsorSourceType, SponsorTime, VideoID } from "../types";
|
||||
import { getHashParams } from "./pageUtils";
|
||||
import { asyncRequestToServer } from "./requests";
|
||||
import { extensionUserAgent } from "../../maze-utils/src";
|
||||
import { getCategorySelection } from "./skipRule";
|
||||
|
||||
const segmentDataCache = new DataCache<VideoID, SegmentResponse>(() => {
|
||||
return {
|
||||
@@ -66,8 +65,7 @@ async function fetchSegmentsForVideo(videoID: VideoID): Promise<SegmentResponse>
|
||||
const receivedSegments: SponsorTime[] = JSON.parse(response.responseText)
|
||||
?.filter((video) => video.videoID === videoID)
|
||||
?.map((video) => video.segments)?.[0]
|
||||
?.filter((segment) => enabledActionTypes.includes(segment.actionType)
|
||||
&& getCategorySelection(segment).option !== CategorySkipOption.Disabled)
|
||||
?.filter((segment) => enabledActionTypes.includes(segment.actionType))
|
||||
?.map((segment) => ({
|
||||
...segment,
|
||||
source: SponsorSourceType.Server
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getVideoDuration } from "../../maze-utils/src/video";
|
||||
import { getChannelIDInfo, getVideoDuration } from "../../maze-utils/src/video";
|
||||
import Config from "../config";
|
||||
import { CategorySelection, CategorySkipOption, SponsorSourceType, SponsorTime } from "../types";
|
||||
import { VideoLabelsCacheData } from "./videoLabels";
|
||||
@@ -8,16 +8,18 @@ export interface Permission {
|
||||
}
|
||||
|
||||
export enum SkipRuleAttribute {
|
||||
StartTime = "startTime",
|
||||
EndTime = "endTime",
|
||||
Duration = "duration",
|
||||
StartTimePercent = "startTimePercent",
|
||||
EndTimePercent = "endTimePercent",
|
||||
DurationPercent = "durationPercent",
|
||||
StartTime = "time.start",
|
||||
EndTime = "time.end",
|
||||
Duration = "time.duration",
|
||||
StartTimePercent = "time.startPercent",
|
||||
EndTimePercent = "time.endPercent",
|
||||
DurationPercent = "time.durationPercent",
|
||||
Category = "category",
|
||||
ActionType = "actionType",
|
||||
Description = "description",
|
||||
Source = "source"
|
||||
Description = "chapter.name",
|
||||
Source = "chapter.source",
|
||||
ChannelID = "channel.id",
|
||||
ChannelName = "channel.name"
|
||||
}
|
||||
|
||||
export enum SkipRuleOperator {
|
||||
@@ -105,9 +107,15 @@ function getSkipRuleValue(segment: SponsorTime | VideoLabelsCacheData, rule: Adv
|
||||
return "autogenerated";
|
||||
case SponsorSourceType.Server:
|
||||
return "server";
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
break;
|
||||
case SkipRuleAttribute.ChannelID:
|
||||
getChannelIDInfo()
|
||||
return getChannelIDInfo().id;
|
||||
case SkipRuleAttribute.ChannelName:
|
||||
getChannelIDInfo()
|
||||
return getChannelIDInfo().author;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user