From 8f7408d815361f120d68450d4b58fffc4b65df62 Mon Sep 17 00:00:00 2001 From: Michael C Date: Tue, 27 Sep 2022 00:59:24 -0400 Subject: [PATCH] fix #1496 - force return bad videoID on clip - don't createbuttons on video ready, updateVisibility with more checks - don't switch to falsy videoIDs if already available --- src/content.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content.ts b/src/content.ts index 2a5b8c10..2a2766da 100644 --- a/src/content.ts +++ b/src/content.ts @@ -383,6 +383,8 @@ function resetValues() { } async function videoIDChange(id): Promise { + // don't switch to invalid value + if (!id && sponsorVideoID) return; //if the id has not changed return unless the video element has changed if (sponsorVideoID === id && (isVisible(video) || !video)) return; @@ -532,7 +534,7 @@ function durationChangeListener(): void { function videoOnReadyListener(): void { createPreviewBar(); updatePreviewBar(); - createButtons(); + updateVisibilityOfPlayerControlsButton() } function cancelSponsorSchedule(): void { @@ -1218,7 +1220,7 @@ function getYouTubeVideoID(document: Document, url?: string): string | boolean { // pageType shortcut if (pageType === PageType.Channel) return getYouTubeVideoIDFromDocument() // clips should never skip, going from clip to full video has no indications. - if (url.includes("youtube.com/clip/")) return false; + if (url.includes("youtube.com/clip/")) return "clipNoID"; // skip to document and don't hide if on /embed/ if (url.includes("/embed/") && url.includes("youtube.com")) return getYouTubeVideoIDFromDocument(false); // skip to URL if matches youtube watch or invidious or matches youtube pattern @@ -1756,16 +1758,14 @@ function shouldSkip(segment: SponsorTime): boolean { /** Creates any missing buttons on the YouTube player if possible. */ async function createButtons(): Promise { - if (onMobileYouTube) return; - controls = await utils.wait(getControls).catch(); // Add button if does not already exist in html createButton("startSegment", "sponsorStart", () => startOrEndTimingNewSegment(), "PlayerStartIconSponsorBlocker.svg"); createButton("cancelSegment", "sponsorCancel", () => cancelCreatingSegment(), "PlayerCancelSegmentIconSponsorBlocker.svg"); createButton("delete", "clearTimes", () => clearSponsorTimes(), "PlayerDeleteIconSponsorBlocker.svg"); - createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker.svg"); - createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker.svg"); + createButton("submit", "SubmitTimes", () => submitSponsorTimes(), "PlayerUploadIconSponsorBlocker.svg"); + createButton("info", "openPopup", () => openInfoMenu(), "PlayerInfoIconSponsorBlocker.svg"); const controlsContainer = getControls(); if (Config.config.autoHideInfoButton && !onInvidious && controlsContainer