Add exclusive access category

This commit is contained in:
Ajay
2022-01-13 23:44:09 -05:00
parent c986860a42
commit 917e644822
6 changed files with 73 additions and 15 deletions

View File

@@ -537,6 +537,16 @@
"category_selfpromo_description": { "category_selfpromo_description": {
"message": "Similar to \"sponsor\" except for unpaid or self promotion. This includes sections about merchandise, donations, or information about who they collaborated with." "message": "Similar to \"sponsor\" except for unpaid or self promotion. This includes sections about merchandise, donations, or information about who they collaborated with."
}, },
"category_exclusive_access": {
"message": "Exclusive Access"
},
"category_exclusive_access_description": {
"message": "Only for labeling entire videos. Used when a video showcases a product, service or location that they've recieved free or subsidized access to."
},
"category_exclusive_access_pill": {
"message": "This video showcases a product, service or location that they've recieved free or subsidized access to",
"description": "Short description for this category"
},
"category_interaction": { "category_interaction": {
"message": "Interaction Reminder (Subscribe)" "message": "Interaction Reminder (Subscribe)"
}, },
@@ -618,6 +628,9 @@
"showOverlay_POI": { "showOverlay_POI": {
"message": "Show In Seek Bar" "message": "Show In Seek Bar"
}, },
"showOverlay_full": {
"message": "Show Label"
},
"autoSkipOnMusicVideos": { "autoSkipOnMusicVideos": {
"message": "Auto skip all segments when there is a non-music segment" "message": "Auto skip all segments when there is a non-music segment"
}, },

View File

@@ -33,15 +33,16 @@ class CategoryPillComponent extends React.Component<CategoryPillProps, CategoryP
render(): React.ReactElement { render(): React.ReactElement {
const style: React.CSSProperties = { const style: React.CSSProperties = {
backgroundColor: Config.config.barTypes["preview-" + this.state.segment?.category]?.color, backgroundColor: this.getColor(),
display: this.state.show ? "flex" : "none", display: this.state.show ? "flex" : "none",
color: this.state.segment?.category === "sponsor" ? "white" : "black", color: this.state.segment?.category === "sponsor"
|| this.state.segment?.category === "exclusive_access" ? "white" : "black",
} }
return ( return (
<span style={style} <span style={style}
className={"sponsorBlockCategoryPill"} className={"sponsorBlockCategoryPill"}
title={chrome.i18n.getMessage("categoryPillTitleText")} title={this.getTitleText()}
onClick={(e) => this.toggleOpen(e)}> onClick={(e) => this.toggleOpen(e)}>
<span className="sponsorBlockCategoryPillTitleSection"> <span className="sponsorBlockCategoryPillTitleSection">
<img className="sponsorSkipLogo sponsorSkipObject" <img className="sponsorSkipLogo sponsorSkipObject"
@@ -108,6 +109,17 @@ class CategoryPillComponent extends React.Component<CategoryPillProps, CategoryP
} }
} }
} }
private getColor(): string {
const configObject = Config.config.barTypes["preview-" + this.state.segment?.category]
|| Config.config.barTypes[this.state.segment?.category];
return configObject?.color;
}
getTitleText(): string {
const shortDescription = chrome.i18n.getMessage(`category_${this.state.segment?.category}_pill`);
return (shortDescription ? shortDescription + ". ": "") + chrome.i18n.getMessage("categoryPillTitleText");
}
} }
export default CategoryPillComponent; export default CategoryPillComponent;

View File

@@ -4,7 +4,7 @@ import Config from "../config"
import * as CompileConfig from "../../config.json"; import * as CompileConfig from "../../config.json";
import { Category, CategorySkipOption } from "../types"; import { Category, CategorySkipOption } from "../types";
import { getCategoryActionType } from "../utils/categoryUtils"; import { getCategorySuffix } from "../utils/categoryUtils";
export interface CategorySkipOptionsProps { export interface CategorySkipOptionsProps {
category: Category; category: Category;
@@ -78,14 +78,16 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
value={this.state.color} /> value={this.state.color} />
</td> </td>
<td id={this.props.category + "PreviewColorOption"} {this.props.category !== "exclusive_access" &&
className="previewColorOption"> <td id={this.props.category + "PreviewColorOption"}
<input className="previewColorOption">
className="categoryColorTextBox option-text-box" <input
type="color" className="categoryColorTextBox option-text-box"
onChange={(event) => this.setColorState(event, true)} type="color"
value={this.state.previewColor} /> onChange={(event) => this.setColorState(event, true)}
</td> value={this.state.previewColor} />
</td>
}
</tr> </tr>
@@ -154,12 +156,13 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
getCategorySkipOptions(): JSX.Element[] { getCategorySkipOptions(): JSX.Element[] {
const elements: JSX.Element[] = []; const elements: JSX.Element[] = [];
const optionNames = ["disable", "showOverlay", "manualSkip", "autoSkip"]; let optionNames = ["disable", "showOverlay", "manualSkip", "autoSkip"];
if (this.props.category === "exclusive_access") optionNames = ["disable", "showOverlay"];
for (const optionName of optionNames) { for (const optionName of optionNames) {
elements.push( elements.push(
<option key={optionName} value={optionName}> <option key={optionName} value={optionName}>
{chrome.i18n.getMessage(optionName !== "disable" ? optionName + getCategoryActionType(this.props.category) {chrome.i18n.getMessage(optionName !== "disable" ? optionName + getCategorySuffix(this.props.category)
: optionName)} : optionName)}
</option> </option>
); );

View File

@@ -199,7 +199,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
</div> </div>
{/* Action Type */} {/* Action Type */}
{CompileConfig.categorySupport[sponsorTime.category]?.length > 1 ? ( {CompileConfig.categorySupport[sponsorTime.category]?.length > 1
|| CompileConfig.categorySupport[sponsorTime.category][0] !== "skip" ? (
<div style={{position: "relative"}}> <div style={{position: "relative"}}>
<select id={"sponsorTimeActionTypes" + this.idSuffix} <select id={"sponsorTimeActionTypes" + this.idSuffix}
className="sponsorTimeEditSelector sponsorTimeActionTypes" className="sponsorTimeEditSelector sponsorTimeActionTypes"

View File

@@ -65,6 +65,7 @@ interface SBConfig {
"preview-sponsor": PreviewBarOption, "preview-sponsor": PreviewBarOption,
"selfpromo": PreviewBarOption, "selfpromo": PreviewBarOption,
"preview-selfpromo": PreviewBarOption, "preview-selfpromo": PreviewBarOption,
"exclusive_access": PreviewBarOption,
"interaction": PreviewBarOption, "interaction": PreviewBarOption,
"preview-interaction": PreviewBarOption, "preview-interaction": PreviewBarOption,
"intro": PreviewBarOption, "intro": PreviewBarOption,
@@ -214,6 +215,9 @@ const Config: SBObject = {
}, { }, {
name: "poi_highlight" as Category, name: "poi_highlight" as Category,
option: CategorySkipOption.ManualSkip option: CategorySkipOption.ManualSkip
}, {
name: "exclusive_access" as Category,
option: CategorySkipOption.ShowOverlay
}], }],
colorPalette: { colorPalette: {
@@ -244,6 +248,10 @@ const Config: SBObject = {
color: "#bfbf35", color: "#bfbf35",
opacity: "0.7" opacity: "0.7"
}, },
"exclusive_access": {
color: "#008a5c",
opacity: "0.7"
},
"interaction": { "interaction": {
color: "#cc00ff", color: "#cc00ff",
opacity: "0.7" opacity: "0.7"
@@ -395,6 +403,17 @@ function fetchConfig(): Promise<void> {
} }
function migrateOldFormats(config: SBConfig) { function migrateOldFormats(config: SBConfig) {
if (!config["exclusive_accessCategoryAdded"] && !config.categorySelections.some((s) => s.name === "exclusive_access")) {
config["exclusive_accessCategoryAdded"] = true;
config.categorySelections.push({
name: "exclusive_access" as Category,
option: CategorySkipOption.ShowOverlay
});
config.categorySelections = config.categorySelections;
}
if (config["fillerUpdate"] !== undefined) { if (config["fillerUpdate"] !== undefined) {
chrome.storage.sync.remove("fillerUpdate"); chrome.storage.sync.remove("fillerUpdate");
} }

View File

@@ -44,4 +44,14 @@ export function getCategoryActionType(category: Category): CategoryActionType {
} else { } else {
return CategoryActionType.Skippable; return CategoryActionType.Skippable;
} }
}
export function getCategorySuffix(category: Category): string {
if (category.startsWith("poi_")) {
return "_POI";
} else if (category === "exclusive_access") {
return "_full";
} else {
return "";
}
} }