mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Added category skip option to just show an overlay without skipping
This commit is contained in:
parent
d4d5e4743e
commit
ec9f1efd55
4 changed files with 47 additions and 17 deletions
|
@ -505,7 +505,7 @@
|
|||
"manualSkip": {
|
||||
"message": "Manual Skip"
|
||||
},
|
||||
"autoSkip": {
|
||||
"message": "Auto Skip"
|
||||
"showOverlay": {
|
||||
"message": "Show Overlay On Player"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as React from "react";
|
||||
|
||||
import Config from "../config"
|
||||
import { CategorySkipOption } from "../types";
|
||||
|
||||
export interface CategorySkipOptionsProps {
|
||||
category: string;
|
||||
|
@ -27,7 +28,17 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
|||
// Set the default opton properly
|
||||
for (const categorySelection of Config.config.categorySelections) {
|
||||
if (categorySelection.name === this.props.category) {
|
||||
defaultOption = categorySelection.autoSkip ? "autoSkip" : "manualSkip";
|
||||
switch (categorySelection.option) {
|
||||
case CategorySkipOption.ShowOverlay:
|
||||
defaultOption = "showOverlay";
|
||||
break;
|
||||
case CategorySkipOption.ManualSkip:
|
||||
defaultOption = "manualSkip";
|
||||
break;
|
||||
case CategorySkipOption.AutoSkip:
|
||||
defaultOption = "autoSkip";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,22 +65,34 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
|||
}
|
||||
|
||||
skipOptionSelected(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||
let option: CategorySkipOption;
|
||||
|
||||
this.removeCurrentCategorySelection();
|
||||
|
||||
switch (event.target.value) {
|
||||
case "disable":
|
||||
this.removeCurrentCategorySelection();
|
||||
return;
|
||||
case "showOverlay":
|
||||
option = CategorySkipOption.ShowOverlay;
|
||||
|
||||
break;
|
||||
default:
|
||||
this.removeCurrentCategorySelection();
|
||||
case "manualSkip":
|
||||
option = CategorySkipOption.ManualSkip;
|
||||
|
||||
Config.config.categorySelections.push({
|
||||
name: this.props.category,
|
||||
autoSkip: event.target.value === "autoSkip"
|
||||
});
|
||||
break;
|
||||
case "autoSkip":
|
||||
option = CategorySkipOption.AutoSkip;
|
||||
|
||||
// Forces the Proxy to send this to the chrome storage API
|
||||
Config.config.categorySelections = Config.config.categorySelections;
|
||||
break;
|
||||
}
|
||||
|
||||
Config.config.categorySelections.push({
|
||||
name: this.props.category,
|
||||
option: option
|
||||
});
|
||||
|
||||
// Forces the Proxy to send this to the chrome storage API
|
||||
Config.config.categorySelections = Config.config.categorySelections;
|
||||
}
|
||||
|
||||
/** Removes this category from the config list of category selections */
|
||||
|
@ -89,8 +112,8 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
|||
|
||||
getCategorySkipOptions(): JSX.Element[] {
|
||||
let elements: JSX.Element[] = [];
|
||||
|
||||
let optionNames = ["disable", "manualSkip", "autoSkip"];
|
||||
""
|
||||
let optionNames = ["disable", "showOverlay", "manualSkip", "autoSkip"];
|
||||
|
||||
for (const optionName of optionNames) {
|
||||
elements.push(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as CompileConfig from "../config.json";
|
||||
import { CategorySelection } from "./types";
|
||||
import { CategorySelection, CategorySkipOption } from "./types";
|
||||
|
||||
interface SBConfig {
|
||||
userID: string,
|
||||
|
@ -127,7 +127,7 @@ var Config: SBObject = {
|
|||
mobileUpdateShowCount: 0,
|
||||
categorySelections: [{
|
||||
name: "sponsor",
|
||||
autoSkip: true
|
||||
option: CategorySkipOption.AutoSkip
|
||||
}]
|
||||
},
|
||||
localConfig: null,
|
||||
|
|
|
@ -26,13 +26,20 @@ interface VideoDurationResponse {
|
|||
duration: number;
|
||||
}
|
||||
|
||||
enum CategorySkipOption {
|
||||
ShowOverlay,
|
||||
ManualSkip,
|
||||
AutoSkip
|
||||
}
|
||||
|
||||
interface CategorySelection {
|
||||
name: string;
|
||||
autoSkip: boolean;
|
||||
option: CategorySkipOption
|
||||
}
|
||||
|
||||
export {
|
||||
VideoDurationResponse,
|
||||
ContentContainer,
|
||||
CategorySkipOption,
|
||||
CategorySelection
|
||||
};
|
Loading…
Reference in a new issue