aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay <[email protected]>2023-09-17 12:06:33 -0400
committerAjay <[email protected]>2023-09-17 12:06:33 -0400
commit8ab126f502c8920de141b4681d1714cdc57b1c3a (patch)
treebf330fc5007a3e38994952dc86f40f9c8a320365
parent4954abf9e385beb02ffde8b47bd5ad0a8fc5a4f5 (diff)
downloadSponsorBlock-8ab126f502c8920de141b4681d1714cdc57b1c3a.tar.gz
SponsorBlock-8ab126f502c8920de141b4681d1714cdc57b1c3a.zip
Highlight segment on hover
-rw-r--r--public/content.css8
-rw-r--r--src/content.ts8
-rw-r--r--src/js-components/previewBar.ts2
-rw-r--r--src/messageTypes.ts2
-rw-r--r--src/popup.ts11
5 files changed, 28 insertions, 3 deletions
diff --git a/public/content.css b/public/content.css
index 8e23aaa3..48f11bd9 100644
--- a/public/content.css
+++ b/public/content.css
@@ -49,7 +49,13 @@ div:hover > #previewbar.sbNotInvidious {
}
.previewbar.requiredSegment {
- transform: scaleY(3)
+ transform: scaleY(3);
+}
+
+.previewbar.selectedSegment {
+ opacity: 1 !important;
+ z-index: 100;
+ transform: scaleY(1.5);
}
/* Make sure settings are upfront */
diff --git a/src/content.ts b/src/content.ts
index 48fa4fcd..6b44520f 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -110,6 +110,7 @@ const skipNotices: SkipNotice[] = [];
let activeSkipKeybindElement: ToggleSkippable = null;
let retryFetchTimeout: NodeJS.Timeout = null;
let shownSegmentFailedToFetchWarning = false;
+let selectedSegment: SegmentUUID | null = null;
// JSON video info
let videoInfo: VideoInfo = null;
@@ -300,6 +301,10 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
case "reskip":
reskipSponsorTime(sponsorTimes.find((segment) => segment.UUID === request.UUID), true);
break;
+ case "selectSegment":
+ selectedSegment = request.UUID;
+ updatePreviewBar();
+ break;
case "submitVote":
vote(request.type, request.UUID).then((response) => sendResponse(response));
return true;
@@ -1369,7 +1374,8 @@ function updatePreviewBar(): void {
showLarger: segment.actionType === ActionType.Poi,
description: segment.description,
source: segment.source,
- requiredSegment: requiredSegment && (segment.UUID === requiredSegment || segment.UUID.startsWith(requiredSegment))
+ requiredSegment: requiredSegment && (segment.UUID === requiredSegment || segment.UUID.startsWith(requiredSegment)),
+ selectedSegment: selectedSegment && segment.UUID === selectedSegment
});
});
}
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts
index 74fae236..dcee1797 100644
--- a/src/js-components/previewBar.ts
+++ b/src/js-components/previewBar.ts
@@ -27,6 +27,7 @@ export interface PreviewBarSegment {
description: string;
source: SponsorSourceType;
requiredSegment?: boolean;
+ selectedSegment?: boolean;
}
interface ChapterGroup extends SegmentContainer {
@@ -332,6 +333,7 @@ class PreviewBar {
const bar = document.createElement('li');
bar.classList.add('previewbar');
if (barSegment.requiredSegment) bar.classList.add("requiredSegment");
+ if (barSegment.selectedSegment) bar.classList.add("selectedSegment");
bar.innerHTML = showLarger ? '&nbsp;&nbsp;' : '&nbsp;';
const fullCategoryName = (unsubmitted ? 'preview-' : '') + category;
diff --git a/src/messageTypes.ts b/src/messageTypes.ts
index 78cf59cf..339bfafe 100644
--- a/src/messageTypes.ts
+++ b/src/messageTypes.ts
@@ -31,7 +31,7 @@ interface IsInfoFoundMessage {
}
interface SkipMessage {
- message: "unskip" | "reskip";
+ message: "unskip" | "reskip" | "selectSegment";
UUID: SegmentUUID;
}
diff --git a/src/popup.ts b/src/popup.ts
index 02404b6a..ac2eba75 100644
--- a/src/popup.ts
+++ b/src/popup.ts
@@ -687,6 +687,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
: chrome.i18n.getMessage("skipSegment");
skipButton.addEventListener("click", () => skipSegment(actionType, UUID, skipButton));
votingButtons.addEventListener("dblclick", () => skipSegment(actionType, UUID));
+ votingButtons.addEventListener("dblclick", () => skipSegment(actionType, UUID));
+ votingButtons.addEventListener("mouseenter", () => selectSegment(UUID));
//add thumbs up, thumbs down and uuid copy buttons to the container
voteButtonsContainer.appendChild(upvoteButton);
@@ -718,6 +720,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
container.appendChild(votingButtons);
}
+
+ container.addEventListener("mouseleave", () => selectSegment(null));
}
function submitTimes() {
@@ -968,6 +972,13 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
}
}
+ function selectSegment(UUID: SegmentUUID | null): void {
+ sendTabMessage({
+ message: "selectSegment",
+ UUID: UUID
+ });
+ }
+
/**
* Should skipping be disabled (visuals stay)
*/