mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Use new Poi action type fetch method
This commit is contained in:
@@ -1,51 +1,41 @@
|
||||
import { ActionType, Category, CategoryActionType, SponsorTime } from "../types";
|
||||
import { ActionType, Category, SponsorTime } from "../types";
|
||||
|
||||
export function getSkippingText(segments: SponsorTime[], autoSkip: boolean): string {
|
||||
const categoryName = chrome.i18n.getMessage(segments.length > 1 ? "multipleSegments"
|
||||
: "category_" + segments[0].category + "_short") || chrome.i18n.getMessage("category_" + segments[0].category);
|
||||
if (autoSkip) {
|
||||
let messageId = "";
|
||||
if (getCategoryActionType(segments[0].category) === CategoryActionType.Skippable) {
|
||||
switch (segments[0].actionType) {
|
||||
case ActionType.Skip:
|
||||
messageId = "skipped";
|
||||
break;
|
||||
case ActionType.Mute:
|
||||
messageId = "muted";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
messageId = "skipped_to_category";
|
||||
switch (segments[0].actionType) {
|
||||
case ActionType.Skip:
|
||||
messageId = "skipped";
|
||||
break;
|
||||
case ActionType.Mute:
|
||||
messageId = "muted";
|
||||
break;
|
||||
case ActionType.Poi:
|
||||
messageId = "skipped_to_category";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return chrome.i18n.getMessage(messageId).replace("{0}", categoryName);
|
||||
} else {
|
||||
let messageId = "";
|
||||
if (getCategoryActionType(segments[0].category) === CategoryActionType.Skippable) {
|
||||
switch (segments[0].actionType) {
|
||||
case ActionType.Skip:
|
||||
messageId = "skip_category";
|
||||
break;
|
||||
case ActionType.Mute:
|
||||
messageId = "mute_category";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
messageId = "skip_to_category";
|
||||
switch (segments[0].actionType) {
|
||||
case ActionType.Skip:
|
||||
messageId = "skip_category";
|
||||
break;
|
||||
case ActionType.Mute:
|
||||
messageId = "mute_category";
|
||||
break;
|
||||
case ActionType.Poi:
|
||||
messageId = "skip_to_category";
|
||||
break;
|
||||
}
|
||||
|
||||
return chrome.i18n.getMessage(messageId).replace("{0}", categoryName);
|
||||
}
|
||||
}
|
||||
|
||||
export function getCategoryActionType(category: Category): CategoryActionType {
|
||||
if (category.startsWith("poi_")) {
|
||||
return CategoryActionType.POI;
|
||||
} else {
|
||||
return CategoryActionType.Skippable;
|
||||
}
|
||||
}
|
||||
|
||||
export function getCategorySuffix(category: Category): string {
|
||||
if (category.startsWith("poi_")) {
|
||||
return "_POI";
|
||||
|
||||
Reference in New Issue
Block a user