Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into copySegment

This commit is contained in:
FlorianZahn
2021-10-13 05:55:21 +02:00
8 changed files with 60 additions and 16 deletions

View File

@@ -464,7 +464,7 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
}
// Don't skip if this category should not be skipped
if (!shouldSkip(currentSkip) && skipInfo.array !== sponsorTimesSubmitting) return;
if (!shouldSkip(currentSkip) && !sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment)) return;
const skippingFunction = () => {
let forcedSkipTime: number = null;
@@ -915,7 +915,7 @@ function getYouTubeVideoID(url: string): string | boolean {
if(url.startsWith("https://www.youtube.com/tv#/")) url = url.replace("#", "");
//Attempt to parse url
let urlObject = null;
let urlObject: URL = null;
try {
urlObject = new URL(url);
} catch (e) {
@@ -941,9 +941,10 @@ function getYouTubeVideoID(url: string): string | boolean {
if (urlObject.searchParams.has("v") && ["/watch", "/watch/"].includes(urlObject.pathname) || urlObject.pathname.startsWith("/tv/watch")) {
const id = urlObject.searchParams.get("v");
return id.length == 11 ? id : false;
} else if (urlObject.pathname.startsWith("/embed/")) {
} else if (urlObject.pathname.startsWith("/embed/") || urlObject.pathname.startsWith("/shorts/")) {
try {
return urlObject.pathname.substr(7, 11);
const id = urlObject.pathname.split("/")[2];
if (id && id.length >= 11) return id.substr(0, 11);
} catch (e) {
console.error("[SB] Video ID not valid for " + url);
return false;

View File

@@ -189,14 +189,20 @@ export default class Utils {
element.classList.add("animationDone");
if (!rightSlide) element.classList.add("autoHideLeft");
let mouseEntered = false;
container.addEventListener("mouseenter", () => {
mouseEntered = true;
element.classList.remove("animationDone");
// Wait for next event loop
setTimeout(() => element.classList.remove("hidden"), 10);
setTimeout(() => {
if (mouseEntered) element.classList.remove("hidden")
}, 10);
});
container.addEventListener("mouseleave", () => {
mouseEntered = false;
if (element.classList.contains("autoHiding")) {
element.classList.add("hidden");
}
@@ -205,10 +211,12 @@ export default class Utils {
enableAutoHideAnimation(element: Element): void {
element.classList.add("autoHiding");
element.classList.add("hidden");
}
disableAutoHideAnimation(element: Element): void {
element.classList.remove("autoHiding");
element.classList.remove("hidden");
}
/**

View File

@@ -11,13 +11,13 @@ export function urlTimeToSeconds(time: string): number {
return 0;
}
const re = /(?:(?<hours>\d{1,3})h)?(?:(?<minutes>\d{1,2})m)?(?<seconds>\d+)s?/;
const re = /(?:(\d{1,3})h)?(?:(\d{1,2})m)?(\d+)s?/;
const match = re.exec(time);
if (match) {
const hours = parseInt(match.groups.hours ?? '0', 10);
const minutes = parseInt(match.groups.minutes ?? '0', 10);
const seconds = parseInt(match.groups.seconds ?? '0', 10);
const hours = parseInt(match[1] ?? '0', 10);
const minutes = parseInt(match[2] ?? '0', 10);
const seconds = parseInt(match[3] ?? '0', 10);
return hours * 3600 + minutes * 60 + seconds;
} else if (/\d+/.test(time)) {