mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Remove chapters payment checks
This commit is contained in:
@@ -6,8 +6,6 @@ import { Category, CategorySkipOption } from "../../types";
|
||||
|
||||
import { getCategorySuffix } from "../../utils/categoryUtils";
|
||||
import ToggleOptionComponent from "./ToggleOptionComponent";
|
||||
import { fetchingChaptersAllowed } from "../../utils/licenseKey";
|
||||
import LockSvg from "../../svg-icons/lock_svg";
|
||||
|
||||
export interface CategorySkipOptionsProps {
|
||||
category: Category;
|
||||
@@ -19,7 +17,6 @@ export interface CategorySkipOptionsProps {
|
||||
export interface CategorySkipOptionsState {
|
||||
color: string;
|
||||
previewColor: string;
|
||||
hideChapter: boolean;
|
||||
}
|
||||
|
||||
export interface ToggleOption {
|
||||
@@ -37,29 +34,11 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
// Setup state
|
||||
this.state = {
|
||||
color: props.defaultColor || Config.config.barTypes[this.props.category]?.color,
|
||||
previewColor: props.defaultPreviewColor || Config.config.barTypes["preview-" + this.props.category]?.color,
|
||||
hideChapter: true
|
||||
previewColor: props.defaultPreviewColor || Config.config.barTypes["preview-" + this.props.category]?.color
|
||||
};
|
||||
|
||||
fetchingChaptersAllowed().then((allowed) => {
|
||||
this.setState({
|
||||
hideChapter: !allowed
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render(): React.ReactElement {
|
||||
if (this.state.hideChapter) {
|
||||
// Ensure force update refreshes this
|
||||
fetchingChaptersAllowed().then((allowed) => {
|
||||
if (allowed) {
|
||||
this.setState({
|
||||
hideChapter: !allowed
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let defaultOption = "disable";
|
||||
// Set the default opton properly
|
||||
for (const categorySelection of Config.config.categorySelections) {
|
||||
@@ -80,20 +59,10 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
}
|
||||
}
|
||||
|
||||
let extraClasses = "";
|
||||
const disabled = this.props.category === "chapter" && this.state.hideChapter;
|
||||
if (disabled) {
|
||||
extraClasses += " disabled";
|
||||
|
||||
if (!Config.config.showUpsells) {
|
||||
return <></>;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<tr id={this.props.category + "OptionsRow"}
|
||||
className={`categoryTableElement${extraClasses}`} >
|
||||
className={`categoryTableElement`} >
|
||||
<td id={this.props.category + "OptionName"}
|
||||
className="categoryTableLabel">
|
||||
{chrome.i18n.getMessage("category_" + this.props.category)}
|
||||
@@ -104,14 +73,9 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
<select
|
||||
className="optionsSelector"
|
||||
defaultValue={defaultOption}
|
||||
disabled={disabled}
|
||||
onChange={this.skipOptionSelected.bind(this)}>
|
||||
{this.getCategorySkipOptions()}
|
||||
</select>
|
||||
|
||||
{disabled &&
|
||||
<LockSvg className="upsellButton" onClick={() => chrome.tabs.create({url: chrome.runtime.getURL('upsell/index.html')})}/>
|
||||
}
|
||||
</td>
|
||||
|
||||
{this.props.category !== "chapter" &&
|
||||
@@ -120,7 +84,6 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
<input
|
||||
className="categoryColorTextBox option-text-box"
|
||||
type="color"
|
||||
disabled={disabled}
|
||||
onChange={(event) => this.setColorState(event, false)}
|
||||
value={this.state.color} />
|
||||
</td>
|
||||
@@ -140,7 +103,7 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
</tr>
|
||||
|
||||
<tr id={this.props.category + "DescriptionRow"}
|
||||
className={`small-description categoryTableDescription${extraClasses}`}>
|
||||
className={`small-description categoryTableDescription`}>
|
||||
<td
|
||||
colSpan={2}>
|
||||
{chrome.i18n.getMessage("category_" + this.props.category + "_description")}
|
||||
@@ -151,7 +114,7 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{this.getExtraOptionComponents(this.props.category, extraClasses, disabled)}
|
||||
{this.getExtraOptionComponents(this.props.category)}
|
||||
|
||||
</>
|
||||
);
|
||||
@@ -235,16 +198,15 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
|
||||
}, 50);
|
||||
}
|
||||
|
||||
getExtraOptionComponents(category: string, extraClasses: string, disabled: boolean): JSX.Element[] {
|
||||
getExtraOptionComponents(category: string): JSX.Element[] {
|
||||
const result = [];
|
||||
for (const option of this.getExtraOptions(category)) {
|
||||
result.push(
|
||||
<tr key={option.configKey} className={extraClasses}>
|
||||
<tr key={option.configKey}>
|
||||
<td id={`${category}_${option.configKey}`} className="categoryExtraOptions">
|
||||
<ToggleOptionComponent
|
||||
configKey={option.configKey}
|
||||
label={option.label}
|
||||
disabled={!option.dontDisable && disabled}
|
||||
style={{width: "inherit"}}
|
||||
/>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user