mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-13 23:17:05 +03:00
Add retry logic to popup info
This commit is contained in:
15
src/popup.ts
15
src/popup.ts
@@ -94,6 +94,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
type PageElements = { [key: string]: HTMLElement } & InputPageElements
|
type PageElements = { [key: string]: HTMLElement } & InputPageElements
|
||||||
|
|
||||||
let stopLoadingAnimation = null;
|
let stopLoadingAnimation = null;
|
||||||
|
// For loading video info from the page
|
||||||
|
let loadRetryCount = 0;
|
||||||
|
|
||||||
//the start and end time pairs (2d)
|
//the start and end time pairs (2d)
|
||||||
let sponsorTimes: SponsorTime[] = [];
|
let sponsorTimes: SponsorTime[] = [];
|
||||||
@@ -409,9 +411,18 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
currentVideoID = result.videoID;
|
currentVideoID = result.videoID;
|
||||||
|
|
||||||
loadTabData(tabs, updating);
|
loadTabData(tabs, updating);
|
||||||
} else if (result === undefined && chrome.runtime.lastError) {
|
} else {
|
||||||
//this isn't a YouTube video then, or at least the content script is not loaded
|
// Handle error if it exists
|
||||||
|
chrome.runtime.lastError;
|
||||||
|
|
||||||
|
// This isn't a YouTube video then, or at least the content script is not loaded
|
||||||
displayNoVideo();
|
displayNoVideo();
|
||||||
|
|
||||||
|
// Try again in some time if a failure
|
||||||
|
loadRetryCount++;
|
||||||
|
if (loadRetryCount < 6) {
|
||||||
|
setTimeout(() => getSegmentsFromContentScript(false), 100 * loadRetryCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user