Load existing chapters

This commit is contained in:
Ajay
2022-02-22 21:22:30 -05:00
parent cf3b3c5c48
commit 2ebc5489cd
7 changed files with 90 additions and 28 deletions

View File

@@ -9,6 +9,7 @@ import Config from "../config";
import { ActionType, Category, SegmentContainer, SponsorTime } from "../types";
import Utils from "../utils";
import { partition } from "../utils/arrayUtils";
import { GenericUtils } from "../utils/genericUtils";
const utils = new Utils();
const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
@@ -111,7 +112,7 @@ class PreviewBar {
const tooltipText = tooltipTextElement.textContent;
if (tooltipText === null || tooltipText.length === 0) continue;
timeInSeconds = utils.getFormattedTimeToSeconds(tooltipText);
timeInSeconds = GenericUtils.getFormattedTimeToSeconds(tooltipText);
if (timeInSeconds !== null) break;
}
@@ -389,6 +390,8 @@ class PreviewBar {
const chapterBar = document.querySelector(".ytp-chapters-container:not(.sponsorBlockChapterBar)") as HTMLElement;
if (!progressBar || !chapterBar) return;
// todo: Can this same mutation observer be reused to import chapters
// maybe not, looks like it has to be imported from the skipping to chapters page
const observer = new MutationObserver((mutations) => {
const changes: Record<string, HTMLElement> = {};
for (const mutation of mutations) {