Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into add-invidious

This commit is contained in:
Ajay Ramachandran
2019-12-30 17:40:32 -05:00

View File

@@ -22,6 +22,9 @@ async function wait(condition, timeout = 5000, check = 100) {
} }
function getYouTubeVideoID(url) { function getYouTubeVideoID(url) {
// For YouTube TV support
if(document.URL.startsWith("https://www.youtube.com/tv#/")) url = url.replace("#", "");
//Attempt to parse url //Attempt to parse url
let urlObject = null; let urlObject = null;
try { try {
@@ -39,7 +42,7 @@ function getYouTubeVideoID(url) {
} }
//Get ID from searchParam //Get ID from searchParam
if ((urlObject.pathname == "/watch" || urlObject.pathname == "/watch/") && urlObject.searchParams.has("v")) { if (urlObject.searchParams.has("v") && ["/watch", "/watch/"].includes(urlObject.pathname) || urlObject.pathname.startsWith("/tv/watch")) {
id = urlObject.searchParams.get("v"); id = urlObject.searchParams.get("v");
return id.length == 11 ? id : false; return id.length == 11 ? id : false;
} else if (urlObject.pathname.startsWith("/embed/")) { } else if (urlObject.pathname.startsWith("/embed/")) {
@@ -50,7 +53,6 @@ function getYouTubeVideoID(url) {
return false; return false;
} }
} }
return false; return false;
} }