mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 03:57:09 +03:00
Made it retry a sponsor lookup each second if there is a connection error.
It will stop after 15 tries.
This commit is contained in:
15
content.js
15
content.js
@@ -29,6 +29,10 @@ var lastTime = -1;
|
||||
//the actual time (not video time) that the last skip happened
|
||||
var lastUnixTimeSkipped = -1;
|
||||
|
||||
//the amount of times the sponsor lookup has retried
|
||||
//this only happens if there is an error
|
||||
var sponsorLookupRetries = 0;
|
||||
|
||||
//the last time in the video a sponsor was skipped
|
||||
//used for the go back button
|
||||
var lastSponsorTimeSkipped = null;
|
||||
@@ -195,6 +199,7 @@ function videoIDChange(id) {
|
||||
sponsorTimes = null;
|
||||
UUIDs = null;
|
||||
sponsorVideoID = id;
|
||||
sponsorLookupRetries = 0;
|
||||
|
||||
//see if there is a video start time
|
||||
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
|
||||
@@ -275,7 +280,8 @@ function sponsorsLookup(id) {
|
||||
|
||||
getChannelID();
|
||||
|
||||
} else if (xmlhttp.readyState == 4) {
|
||||
sponsorLookupRetries = 0;
|
||||
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 404) {
|
||||
sponsorDataFound = false;
|
||||
|
||||
//check if this video was uploaded recently
|
||||
@@ -290,6 +296,13 @@ function sponsorsLookup(id) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
sponsorLookupRetries = 0;
|
||||
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 15) {
|
||||
//some error occurred, try again in a second
|
||||
setTimeout(() => sponsorsLookup(id), 1000);
|
||||
|
||||
sponsorLookupRetries++;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user