aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-10-03 13:07:47 -0400
committerAjay Ramachandran <[email protected]>2021-10-03 13:07:47 -0400
commit66f0cc8883c2c16bead0b199ef19e07fde266d41 (patch)
treefc7bcf7dc46256cfc008c7b814e42900dcc5d3b3
parent1a0ac27e49071954444952eb9c08de66fb4232bd (diff)
downloadSponsorBlock-66f0cc8883c2c16bead0b199ef19e07fde266d41.tar.gz
SponsorBlock-66f0cc8883c2c16bead0b199ef19e07fde266d41.zip
Support shorts
-rw-r--r--src/content.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/content.ts b/src/content.ts
index 89e78938..8c178bd1 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -851,7 +851,7 @@ function getYouTubeVideoID(url: string): string | boolean {
if(url.startsWith("https://www.youtube.com/tv#/")) url = url.replace("#", "");
//Attempt to parse url
- let urlObject = null;
+ let urlObject: URL = null;
try {
urlObject = new URL(url);
} catch (e) {
@@ -877,9 +877,10 @@ function getYouTubeVideoID(url: string): string | boolean {
if (urlObject.searchParams.has("v") && ["/watch", "/watch/"].includes(urlObject.pathname) || urlObject.pathname.startsWith("/tv/watch")) {
const id = urlObject.searchParams.get("v");
return id.length == 11 ? id : false;
- } else if (urlObject.pathname.startsWith("/embed/")) {
+ } else if (urlObject.pathname.startsWith("/embed/") || urlObject.pathname.startsWith("/shorts/")) {
try {
- return urlObject.pathname.substr(7, 11);
+ const id = urlObject.pathname.split("/")[2];
+ if (id && id.length == 11) return id;
} catch (e) {
console.error("[SB] Video ID not valid for " + url);
return false;