Move unlisted check request to background script

Resolves #566
This commit is contained in:
Ajay Ramachandran 2020-12-15 21:34:29 -05:00
parent fbe64c115b
commit 90d53a34b5

View file

@ -752,10 +752,11 @@ function startSkipScheduleCheckingForStartSponsors() {
/** /**
* Get the video info for the current tab from YouTube * Get the video info for the current tab from YouTube
*/ */
function getVideoInfo() { async function getVideoInfo(): Promise<void> {
sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID, function(xmlhttp, error) { const result = await utils.asyncRequestToCustomServer("GET", "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID);
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
const decodedData = decodeURIComponent(xmlhttp.responseText).match(/player_response=([^&]*)/)[1]; if (result.ok) {
const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1];
if (!decodedData) { if (!decodedData) {
console.error("[SB] Failed at getting video info from YouTube."); console.error("[SB] Failed at getting video info from YouTube.");
return; return;
@ -763,7 +764,6 @@ function getVideoInfo() {
videoInfo = JSON.parse(decodedData); videoInfo = JSON.parse(decodedData);
} }
});
} }
function getYouTubeVideoID(url: string) { function getYouTubeVideoID(url: string) {