mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 04:27:15 +03:00
Fix video labels showing all categories regardless of settings
This commit is contained in:
@@ -31,6 +31,7 @@ export interface VideoDurationResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum CategorySkipOption {
|
export enum CategorySkipOption {
|
||||||
|
Disabled = -1,
|
||||||
ShowOverlay,
|
ShowOverlay,
|
||||||
ManualSkip,
|
ManualSkip,
|
||||||
AutoSkip
|
AutoSkip
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Config, { VideoDownvotes } from "./config";
|
import Config, { VideoDownvotes } from "./config";
|
||||||
import { CategorySelection, SponsorTime, BackgroundScriptContainer, Registration, VideoID, SponsorHideType } from "./types";
|
import { CategorySelection, SponsorTime, BackgroundScriptContainer, Registration, VideoID, SponsorHideType, CategorySkipOption } from "./types";
|
||||||
|
|
||||||
import { getHash, HashedValue } from "@ajayyy/maze-utils/lib/hash";
|
import { getHash, HashedValue } from "@ajayyy/maze-utils/lib/hash";
|
||||||
import * as CompileConfig from "../config.json";
|
import * as CompileConfig from "../config.json";
|
||||||
@@ -225,7 +225,7 @@ export default class Utils {
|
|||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { name: "None", option: 0} as CategorySelection;
|
return { name: category, option: CategorySkipOption.Disabled} as CategorySelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Category, VideoID } from "../types";
|
import { Category, CategorySkipOption, VideoID } from "../types";
|
||||||
import { getHash } from "@ajayyy/maze-utils/lib/hash";
|
import { getHash } from "@ajayyy/maze-utils/lib/hash";
|
||||||
import Utils from "../utils";
|
import Utils from "../utils";
|
||||||
import { logWarn } from "./logger";
|
import { logWarn } from "./logger";
|
||||||
@@ -58,7 +58,12 @@ export async function getVideoLabel(videoID: VideoID): Promise<Category | null>
|
|||||||
const result = await getLabelHashBlock(prefix);
|
const result = await getLabelHashBlock(prefix);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
return result.videos[videoID] ?? null;
|
const category = result.videos[videoID];
|
||||||
|
if (category && utils.getCategorySelection(category).option !== CategorySkipOption.Disabled) {
|
||||||
|
return category;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user