This commit is contained in:
Ajay
2022-01-20 16:03:43 -05:00
2 changed files with 44 additions and 4 deletions

View File

@@ -15,7 +15,6 @@ import { Message, MessageResponse, VoteResponse } from "./messageTypes";
import * as Chat from "./js-components/chat";
import { getCategoryActionType } from "./utils/categoryUtils";
import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
import { Tooltip } from "./render/Tooltip";
import { getStartTimeFromUrl } from "./utils/urlParser";
import { findValidElement, getControls, getHashParams, isVisible } from "./utils/pageUtils";
import { CategoryPill } from "./render/CategoryPill";
@@ -92,6 +91,8 @@ const playerButtons: Record<string, {button: HTMLButtonElement, image: HTMLImage
// Direct Links after the config is loaded
utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document)));
// wait for hover preview to appear, and refresh attachments if ever found
window.addEventListener("DOMContentLoaded", () => utils.waitForElement(".ytp-inline-preview-ui").then(() => refreshVideoAttachments()));
addPageListeners();
addHotkeyListener();
@@ -930,7 +931,7 @@ function getYouTubeVideoID(document: Document): string | boolean {
// skip to document if matches pattern
if (url.includes("/channel/") || url.includes("/user/") || url.includes("/c/")) return getYouTubeVideoIDFromDocument(document);
// not sure, try URL then document
return getYouTubeVideoIDFromURL(url) || getYouTubeVideoIDFromDocument(document);
return getYouTubeVideoIDFromURL(url) || getYouTubeVideoIDFromDocument(document, false);
}
function getYouTubeVideoIDFromDocument(document: Document, hideIcon = true): string | boolean {