From 5ee279dec7d074dd266c23892ff27b118f5bb504 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Sun, 4 Aug 2019 19:06:07 +0100 Subject: [PATCH] Added getYouTubeVideoStartTime --- utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils.js b/utils.js index c2803729..1e4da828 100644 --- a/utils.js +++ b/utils.js @@ -9,3 +9,14 @@ function getYouTubeVideoID(url) { // Returns with video id else returns false return (match && match[7].length == 11) ? id : false; } + +//returns the start time of the video if there was one specified (ex. ?t=5s) +function getYouTubeVideoStartTime(url) { + let searchParams = new URL(url).searchParams; + var startTime = searchParams.get("t"); + if (startTime == null) { + startTime = searchParams.get("time_continue"); + } + + return startTime; +}