Added category skip option to just show an overlay without skipping

This commit is contained in:
Ajay Ramachandran
2020-04-04 12:58:02 -04:00
parent d4d5e4743e
commit ec9f1efd55
4 changed files with 47 additions and 17 deletions

View File

@@ -505,7 +505,7 @@
"manualSkip": { "manualSkip": {
"message": "Manual Skip" "message": "Manual Skip"
}, },
"autoSkip": { "showOverlay": {
"message": "Auto Skip" "message": "Show Overlay On Player"
} }
} }

View File

@@ -1,6 +1,7 @@
import * as React from "react"; import * as React from "react";
import Config from "../config" import Config from "../config"
import { CategorySkipOption } from "../types";
export interface CategorySkipOptionsProps { export interface CategorySkipOptionsProps {
category: string; category: string;
@@ -27,7 +28,17 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
// Set the default opton properly // Set the default opton properly
for (const categorySelection of Config.config.categorySelections) { for (const categorySelection of Config.config.categorySelections) {
if (categorySelection.name === this.props.category) { 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 { skipOptionSelected(event: React.ChangeEvent<HTMLSelectElement>): void {
let option: CategorySkipOption;
this.removeCurrentCategorySelection();
switch (event.target.value) { switch (event.target.value) {
case "disable": case "disable":
this.removeCurrentCategorySelection(); return;
case "showOverlay":
option = CategorySkipOption.ShowOverlay;
break; break;
default: case "manualSkip":
this.removeCurrentCategorySelection(); option = CategorySkipOption.ManualSkip;
Config.config.categorySelections.push({ break;
name: this.props.category, case "autoSkip":
autoSkip: event.target.value === "autoSkip" option = CategorySkipOption.AutoSkip;
});
// Forces the Proxy to send this to the chrome storage API break;
Config.config.categorySelections = Config.config.categorySelections;
} }
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 */ /** Removes this category from the config list of category selections */
@@ -89,8 +112,8 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
getCategorySkipOptions(): JSX.Element[] { getCategorySkipOptions(): JSX.Element[] {
let elements: JSX.Element[] = []; let elements: JSX.Element[] = [];
""
let optionNames = ["disable", "manualSkip", "autoSkip"]; let optionNames = ["disable", "showOverlay", "manualSkip", "autoSkip"];
for (const optionName of optionNames) { for (const optionName of optionNames) {
elements.push( elements.push(

View File

@@ -1,5 +1,5 @@
import * as CompileConfig from "../config.json"; import * as CompileConfig from "../config.json";
import { CategorySelection } from "./types"; import { CategorySelection, CategorySkipOption } from "./types";
interface SBConfig { interface SBConfig {
userID: string, userID: string,
@@ -127,7 +127,7 @@ var Config: SBObject = {
mobileUpdateShowCount: 0, mobileUpdateShowCount: 0,
categorySelections: [{ categorySelections: [{
name: "sponsor", name: "sponsor",
autoSkip: true option: CategorySkipOption.AutoSkip
}] }]
}, },
localConfig: null, localConfig: null,

View File

@@ -26,13 +26,20 @@ interface VideoDurationResponse {
duration: number; duration: number;
} }
enum CategorySkipOption {
ShowOverlay,
ManualSkip,
AutoSkip
}
interface CategorySelection { interface CategorySelection {
name: string; name: string;
autoSkip: boolean; option: CategorySkipOption
} }
export { export {
VideoDurationResponse, VideoDurationResponse,
ContentContainer, ContentContainer,
CategorySkipOption,
CategorySelection CategorySelection
}; };