mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +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
|
//the actual time (not video time) that the last skip happened
|
||||||
var lastUnixTimeSkipped = -1;
|
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
|
//the last time in the video a sponsor was skipped
|
||||||
//used for the go back button
|
//used for the go back button
|
||||||
var lastSponsorTimeSkipped = null;
|
var lastSponsorTimeSkipped = null;
|
||||||
@@ -195,6 +199,7 @@ function videoIDChange(id) {
|
|||||||
sponsorTimes = null;
|
sponsorTimes = null;
|
||||||
UUIDs = null;
|
UUIDs = null;
|
||||||
sponsorVideoID = id;
|
sponsorVideoID = id;
|
||||||
|
sponsorLookupRetries = 0;
|
||||||
|
|
||||||
//see if there is a video start time
|
//see if there is a video start time
|
||||||
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
|
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
|
||||||
@@ -275,7 +280,8 @@ function sponsorsLookup(id) {
|
|||||||
|
|
||||||
getChannelID();
|
getChannelID();
|
||||||
|
|
||||||
} else if (xmlhttp.readyState == 4) {
|
sponsorLookupRetries = 0;
|
||||||
|
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 404) {
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
|
|
||||||
//check if this video was uploaded recently
|
//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