diff --git a/src/submission/ThumbnailComponent.tsx b/src/submission/ThumbnailComponent.tsx index 483d14f..4c2f3ef 100644 --- a/src/submission/ThumbnailComponent.tsx +++ b/src/submission/ThumbnailComponent.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import { drawCenteredToCanvas, renderThumbnail, setupPreRenderedThumbnail } from "../thumbnails/thumbnailRenderer"; import { waitFor } from "../../maze-utils/src" -import { VideoID } from "../../maze-utils/src/video"; +import { getCurrentTime, verifyCurrentTime, VideoID } from "../../maze-utils/src/video"; import { ThumbnailSubmission } from "../thumbnails/thumbnailData"; import { logError } from "../utils/logger"; import { isFirefoxOrSafari } from "../../maze-utils/src"; @@ -80,7 +80,7 @@ export const ThumbnailComponent = (props: ThumbnailComponentProps) => { if (props.type === ThumbnailType.SpecifiedTime) { canvasRef.current?.getContext("2d")?.clearRect(0, 0, canvasRef.current?.width, canvasRef.current?.height); - if (props.video.paused && props.time === props.video.currentTime) { + if (props.video.paused && props.time === getCurrentTime()) { // Skip rendering and just use existing video frame renderCurrentFrame(props, canvasRef, inRenderingLoop, false, true); } else { @@ -115,11 +115,16 @@ export const ThumbnailComponent = (props: ThumbnailComponentProps) => { if (submitted) return; submitted = true; + if (props.type === ThumbnailType.CurrentTime) { + // To handle server-side ads + verifyCurrentTime(); + } + props.onClick?.(props.type === ThumbnailType.Original ? { original: true } : { original: false, - timestamp: props.type === ThumbnailType.CurrentTime ? props.video.currentTime : props.time! + timestamp: props.type === ThumbnailType.CurrentTime ? (getCurrentTime() || 0) : props.time! }); } diff --git a/src/submission/submitButton.tsx b/src/submission/submitButton.tsx index 97136ab..ec59b81 100644 --- a/src/submission/submitButton.tsx +++ b/src/submission/submitButton.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { createRoot, Root } from "react-dom/client"; import { BrandingResult, replaceCurrentVideoBranding } from "../videoBranding/videoBranding"; import { SubmissionComponent } from "./SubmissionComponent"; -import { getVideo, getVideoID, getYouTubeVideoID, isOnMobileYouTube } from "../../maze-utils/src/video"; +import { getVideo, getVideoID, getYouTubeVideoID, isCurrentTimeWrong, isOnMobileYouTube } from "../../maze-utils/src/video"; import { log, logError } from "../utils/logger"; import { TitleSubmission } from "../titles/titleData"; import { ThumbnailSubmission } from "../thumbnails/thumbnailData"; @@ -222,6 +222,11 @@ export class SubmitButton { alert(chrome.i18n.getMessage("videoIDWrongWhenSubmittingError")); return false; } + + if (isCurrentTimeWrong()) { + alert(chrome.i18n.getMessage("submissionFailedServerSideAds")); + return false; + } const result = await submitVideoBranding(getVideoID()!, title, thumbnail, false, actAsVip);