From 1db9d25f3ba928f18a17bb17cad1dae77005c2cb Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 29 Dec 2019 21:39:19 +0000 Subject: [PATCH] getYouTubeVideoID ~ TV support --- utils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils.js b/utils.js index 838769a2..51a54cc3 100644 --- a/utils.js +++ b/utils.js @@ -19,6 +19,9 @@ async function wait(condition, timeout = 5000, check = 100) { } function getYouTubeVideoID(url) { + + if(document.URL.startsWith("https://www.youtube.com/tv#/")) url = url.replace("#", ""); + //Attempt to parse url let urlObject = null; try { @@ -32,7 +35,7 @@ function getYouTubeVideoID(url) { if(!["www.youtube.com","www.youtube-nocookie.com"].includes(urlObject.host)) return false; //Get ID from searchParam - if ((urlObject.pathname == "/watch" || urlObject.pathname == "/watch/") && urlObject.searchParams.has("v")) { + if (["/watch", "/watch/"].includes(urlObject.pathname) || urlObject.pathname.startsWith("/tv/watch")) { id = urlObject.searchParams.get("v"); return id.length == 11 ? id : false; } else if (urlObject.pathname.startsWith("/embed/")) { @@ -42,8 +45,7 @@ function getYouTubeVideoID(url) { console.error("[SB] Video ID not valid for " + url); return false; } - } - + } return false; } @@ -104,4 +106,4 @@ function getErrorMessage(statusCode) { } return errorMessage; -} \ No newline at end of file +}