diff options
author | Ajay Ramachandran <[email protected]> | 2020-12-15 21:34:29 -0500 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2020-12-15 21:34:29 -0500 |
commit | 90d53a34b54e8eeb9b5d8604728e2e2d30b2d214 (patch) | |
tree | 2a9dd5f9ec6e03329b4f0b4c453179829d2953c2 | |
parent | fbe64c115b703b405e3d76a54c6b73786bdca7a8 (diff) | |
download | SponsorBlock-90d53a34b54e8eeb9b5d8604728e2e2d30b2d214.tar.gz SponsorBlock-90d53a34b54e8eeb9b5d8604728e2e2d30b2d214.zip |
Move unlisted check request to background script
Resolves #566
-rw-r--r-- | src/content.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/content.ts b/src/content.ts index 5124030d..7cda28dc 100644 --- a/src/content.ts +++ b/src/content.ts @@ -752,18 +752,18 @@ function startSkipScheduleCheckingForStartSponsors() { /** * Get the video info for the current tab from YouTube */ -function getVideoInfo() { - sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID, function(xmlhttp, error) { - if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { - const decodedData = decodeURIComponent(xmlhttp.responseText).match(/player_response=([^&]*)/)[1]; - if (!decodedData) { - console.error("[SB] Failed at getting video info from YouTube."); - return; - } +async function getVideoInfo(): Promise<void> { + const result = await utils.asyncRequestToCustomServer("GET", "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID); - videoInfo = JSON.parse(decodedData); + if (result.ok) { + const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1]; + if (!decodedData) { + console.error("[SB] Failed at getting video info from YouTube."); + return; } - }); + + videoInfo = JSON.parse(decodedData); + } } function getYouTubeVideoID(url: string) { |