diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 16707c26..2fcae408 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -254,7 +254,7 @@ class SponsorTimeEditComponent extends React.Component + className={this.getCategoryLockedClass(category)}> {chrome.i18n.getMessage("category_" + category)} ); diff --git a/src/content.ts b/src/content.ts index e147bd6d..260e9760 100644 --- a/src/content.ts +++ b/src/content.ts @@ -37,7 +37,7 @@ let videoInfo: VideoInfo = null; // The channel this video is about let channelIDInfo: ChannelIDInfo; // Locked Categories in this tab, like: ["sponsor","intro","outro"] -const lockedCategories: Category[] = []; +let lockedCategories: Category[] = []; // Skips are scheduled to ensure precision. // Skips are rescheduled every seeking event. @@ -234,6 +234,7 @@ function resetValues() { status: ChannelIDStatus.Fetching, id: null }; + lockedCategories = []; //empty the preview bar if (previewBar !== null) { @@ -808,10 +809,13 @@ async function lockedSegmentsLookup(): Promise { async function lockedCategoriesLookup(id: string): Promise { const response = await utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id }); - if (response.status === 200 && response.ok) { - for (const category of JSON.parse(response.responseText).categories) { - lockedCategories.push(category); - } + if (response.ok) { + try { + const categoriesResponse = JSON.parse(response.responseText).categories; + if (Array.isArray(categoriesResponse)) { + lockedCategories = categoriesResponse; + } + } catch (e) { } //eslint-disable-line no-empty } }