mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 05:57:07 +03:00
Add preview category
Closes https://github.com/ajayyy/SponsorBlock/issues/444
(cherry picked from commit a10d7c338c)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user