mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 22:47:18 +03:00
Highlight segment on hover
This commit is contained in:
@@ -49,7 +49,13 @@ div:hover > #previewbar.sbNotInvidious {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.previewbar.requiredSegment {
|
.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 */
|
/* Make sure settings are upfront */
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ const skipNotices: SkipNotice[] = [];
|
|||||||
let activeSkipKeybindElement: ToggleSkippable = null;
|
let activeSkipKeybindElement: ToggleSkippable = null;
|
||||||
let retryFetchTimeout: NodeJS.Timeout = null;
|
let retryFetchTimeout: NodeJS.Timeout = null;
|
||||||
let shownSegmentFailedToFetchWarning = false;
|
let shownSegmentFailedToFetchWarning = false;
|
||||||
|
let selectedSegment: SegmentUUID | null = null;
|
||||||
|
|
||||||
// JSON video info
|
// JSON video info
|
||||||
let videoInfo: VideoInfo = null;
|
let videoInfo: VideoInfo = null;
|
||||||
@@ -300,6 +301,10 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
|||||||
case "reskip":
|
case "reskip":
|
||||||
reskipSponsorTime(sponsorTimes.find((segment) => segment.UUID === request.UUID), true);
|
reskipSponsorTime(sponsorTimes.find((segment) => segment.UUID === request.UUID), true);
|
||||||
break;
|
break;
|
||||||
|
case "selectSegment":
|
||||||
|
selectedSegment = request.UUID;
|
||||||
|
updatePreviewBar();
|
||||||
|
break;
|
||||||
case "submitVote":
|
case "submitVote":
|
||||||
vote(request.type, request.UUID).then((response) => sendResponse(response));
|
vote(request.type, request.UUID).then((response) => sendResponse(response));
|
||||||
return true;
|
return true;
|
||||||
@@ -1369,7 +1374,8 @@ function updatePreviewBar(): void {
|
|||||||
showLarger: segment.actionType === ActionType.Poi,
|
showLarger: segment.actionType === ActionType.Poi,
|
||||||
description: segment.description,
|
description: segment.description,
|
||||||
source: segment.source,
|
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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export interface PreviewBarSegment {
|
|||||||
description: string;
|
description: string;
|
||||||
source: SponsorSourceType;
|
source: SponsorSourceType;
|
||||||
requiredSegment?: boolean;
|
requiredSegment?: boolean;
|
||||||
|
selectedSegment?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChapterGroup extends SegmentContainer {
|
interface ChapterGroup extends SegmentContainer {
|
||||||
@@ -332,6 +333,7 @@ class PreviewBar {
|
|||||||
const bar = document.createElement('li');
|
const bar = document.createElement('li');
|
||||||
bar.classList.add('previewbar');
|
bar.classList.add('previewbar');
|
||||||
if (barSegment.requiredSegment) bar.classList.add("requiredSegment");
|
if (barSegment.requiredSegment) bar.classList.add("requiredSegment");
|
||||||
|
if (barSegment.selectedSegment) bar.classList.add("selectedSegment");
|
||||||
bar.innerHTML = showLarger ? ' ' : ' ';
|
bar.innerHTML = showLarger ? ' ' : ' ';
|
||||||
|
|
||||||
const fullCategoryName = (unsubmitted ? 'preview-' : '') + category;
|
const fullCategoryName = (unsubmitted ? 'preview-' : '') + category;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ interface IsInfoFoundMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface SkipMessage {
|
interface SkipMessage {
|
||||||
message: "unskip" | "reskip";
|
message: "unskip" | "reskip" | "selectSegment";
|
||||||
UUID: SegmentUUID;
|
UUID: SegmentUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/popup.ts
11
src/popup.ts
@@ -687,6 +687,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
: chrome.i18n.getMessage("skipSegment");
|
: chrome.i18n.getMessage("skipSegment");
|
||||||
skipButton.addEventListener("click", () => skipSegment(actionType, UUID, skipButton));
|
skipButton.addEventListener("click", () => skipSegment(actionType, UUID, skipButton));
|
||||||
votingButtons.addEventListener("dblclick", () => skipSegment(actionType, UUID));
|
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
|
//add thumbs up, thumbs down and uuid copy buttons to the container
|
||||||
voteButtonsContainer.appendChild(upvoteButton);
|
voteButtonsContainer.appendChild(upvoteButton);
|
||||||
@@ -718,6 +720,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
|
|
||||||
container.appendChild(votingButtons);
|
container.appendChild(votingButtons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container.addEventListener("mouseleave", () => selectSegment(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitTimes() {
|
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)
|
* Should skipping be disabled (visuals stay)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user