aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-05-31 14:45:39 -0400
committerAjay Ramachandran <[email protected]>2021-05-31 14:45:39 -0400
commit9478bfe6a4b17886401ae609ced5e5a95969194c (patch)
treedadee49e7e096cc4a5a82cc9a73bdcde70372b0b
parent42fa6c44c4c885543812da9d79406df38ce23e68 (diff)
downloadSponsorBlock-9478bfe6a4b17886401ae609ced5e5a95969194c.tar.gz
SponsorBlock-9478bfe6a4b17886401ae609ced5e5a95969194c.zip
Don't crash if bar types are missing
-rw-r--r--src/components/CategorySkipOptionsComponent.tsx4
-rw-r--r--src/js-components/previewBar.ts2
-rw-r--r--src/popup.ts2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/components/CategorySkipOptionsComponent.tsx b/src/components/CategorySkipOptionsComponent.tsx
index 3cc03527..a59e3f54 100644
--- a/src/components/CategorySkipOptionsComponent.tsx
+++ b/src/components/CategorySkipOptionsComponent.tsx
@@ -21,8 +21,8 @@ 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,
+ color: props.defaultColor || Config.config.barTypes[this.props.category]?.color,
+ previewColor: props.defaultPreviewColor || Config.config.barTypes["preview-" + this.props.category]?.color,
}
}
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts
index 7f011f0d..67d28c1a 100644
--- a/src/js-components/previewBar.ts
+++ b/src/js-components/previewBar.ts
@@ -194,7 +194,7 @@ class PreviewBar {
bar.setAttribute('data-vs-segment-type', barSegmentType);
- bar.style.backgroundColor = Config.config.barTypes[barSegmentType].color;
+ bar.style.backgroundColor = Config.config.barTypes[barSegmentType]?.color;
if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[barSegmentType].opacity;
bar.style.position = "absolute";
diff --git a/src/popup.ts b/src/popup.ts
index 7ae6f6d5..5a9cc8be 100644
--- a/src/popup.ts
+++ b/src/popup.ts
@@ -374,7 +374,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
const categoryColorCircle = document.createElement("span");
categoryColorCircle.id = "sponsorTimesCategoryColorCircle" + UUID;
- categoryColorCircle.style.backgroundColor = Config.config.barTypes[segmentTimes[i].category].color;
+ categoryColorCircle.style.backgroundColor = Config.config.barTypes[segmentTimes[i].category]?.color;
categoryColorCircle.classList.add("dot");
categoryColorCircle.classList.add("sponsorTimesCategoryColorCircle");