Add preview category

Closes https://github.com/ajayyy/SponsorBlock/issues/444

(cherry picked from commit a10d7c338c)
This commit is contained in:
Ajay Ramachandran
2021-03-30 22:50:36 -04:00
parent e587addeee
commit 861ba4869e
5 changed files with 66 additions and 45 deletions

View File

@@ -14,7 +14,7 @@ const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
export interface PreviewBarSegment {
segment: [number, number];
category: string;
preview: boolean;
unsubmitted: boolean;
}
class PreviewBar {
@@ -117,8 +117,8 @@ class PreviewBar {
} else if (segment !== null) {
this.tooltipContainer.classList.add(TOOLTIP_VISIBLE_CLASS);
if (segment.preview) {
this.categoryTooltip.textContent = chrome.i18n.getMessage("preview") + " " + utils.shortCategoryName(segment.category);
if (segment.unsubmitted) {
this.categoryTooltip.textContent = chrome.i18n.getMessage("unsubmitted") + " " + utils.shortCategoryName(segment.category);
} else {
this.categoryTooltip.textContent = utils.shortCategoryName(segment.category);
}
@@ -181,13 +181,12 @@ class PreviewBar {
});
}
createBar({category, preview, segment}: PreviewBarSegment): HTMLLIElement {
createBar({category, unsubmitted, segment}: PreviewBarSegment): HTMLLIElement {
const bar = document.createElement('li');
bar.classList.add('previewbar');
bar.innerHTML = ' ';
const fullCategoryName = (preview ? 'preview-' : '') + category;
const fullCategoryName = (unsubmitted ? 'preview-' : '') + category;
bar.setAttribute('sponsorblock-category', fullCategoryName);
bar.style.backgroundColor = Config.config.barTypes[fullCategoryName]?.color;