mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Added sanity check
This commit is contained in:
7
utils.js
7
utils.js
@@ -1,11 +1,8 @@
|
|||||||
function getYouTubeVideoID(url) { // Returns with video id else returns false
|
function getYouTubeVideoID(url) { // Returns with video id else returns false
|
||||||
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
||||||
var match = url.match(regExp);
|
var match = url.match(regExp);
|
||||||
var id = new URL(url).searchParams.get("v");
|
var id = url.includes("/embed/") ? match[7] : new URL(url).searchParams.get("v");
|
||||||
if (url.includes("/embed/")) { //it is an embed, don't search for v
|
return (match && id.length === 11) ? id : false;
|
||||||
id = match[7];
|
|
||||||
}
|
|
||||||
return (match) ? id : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns the start time of the video if there was one specified (ex. ?t=5s)
|
//returns the start time of the video if there was one specified (ex. ?t=5s)
|
||||||
|
|||||||
Reference in New Issue
Block a user