From 8f7408d815361f120d68450d4b58fffc4b65df62 Mon Sep 17 00:00:00 2001 From: Michael C Date: Tue, 27 Sep 2022 00:59:24 -0400 Subject: [PATCH 1/2] 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 From 5296c437cc6457150edee445f078748062035326 Mon Sep 17 00:00:00 2001 From: Ajay Date: Wed, 5 Oct 2022 00:55:19 -0400 Subject: [PATCH 2/2] Make the clip ignore less sketchy --- src/content.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index 2a2766da..9301f9c8 100644 --- a/src/content.ts +++ b/src/content.ts @@ -384,7 +384,7 @@ function resetValues() { async function videoIDChange(id): Promise { // don't switch to invalid value - if (!id && sponsorVideoID) return; + if (!id && sponsorVideoID && !document?.URL?.includes("youtube.com/clip/")) return; //if the id has not changed return unless the video element has changed if (sponsorVideoID === id && (isVisible(video) || !video)) return; @@ -1220,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 "clipNoID"; + if (url.includes("youtube.com/clip/")) return false; // 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 @@ -2252,7 +2252,8 @@ function getSegmentsMessage(sponsorTimes: SponsorTime[]): string { function windowListenerHandler(event: MessageEvent): void { const data = event.data; const dataType = data.type; - if (data.source !== "sponsorblock") return; + + if (data.source !== "sponsorblock" || document?.URL?.includes("youtube.com/clip/")) return; if (dataType === "navigation" && data.videoID) { pageType = data.pageType;