mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Fixed sponsor data found check
This commit is contained in:
parent
7baff32b55
commit
9b370af340
1 changed files with 14 additions and 7 deletions
21
content.js
21
content.js
|
@ -1,4 +1,6 @@
|
|||
if(id = getYouTubeVideoID(document.URL)){ // Direct Links
|
||||
//reset sponsor data found check
|
||||
sponsorDataFound = false;
|
||||
sponsorsLookup(id);
|
||||
}
|
||||
|
||||
|
@ -13,8 +15,11 @@ var lastTime;
|
|||
|
||||
chrome.runtime.onMessage.addListener( // Detect URL Changes
|
||||
function(request, sender, sendResponse) {
|
||||
if (request.message === 'ytvideoid') { // Message from background script
|
||||
sponsorsLookup(request.id);
|
||||
//message from background script
|
||||
if (request.message === 'ytvideoid') {
|
||||
//reset sponsor data found check
|
||||
sponsorDataFound = false;
|
||||
sponsorsLookup(request.id);
|
||||
}
|
||||
|
||||
//messages from popup script
|
||||
|
@ -44,12 +49,14 @@ function sponsorsLookup(id) {
|
|||
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||
sponsorDataFound = true;
|
||||
|
||||
// If the sponsor data exists, add the event to run on the videos "ontimeupdate"
|
||||
v.ontimeupdate = function () {
|
||||
sponsorCheck(sponsorTimes);
|
||||
};
|
||||
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||
|
||||
// If the sponsor data exists, add the event to run on the videos "ontimeupdate"
|
||||
v.ontimeupdate = function () {
|
||||
sponsorCheck(sponsorTimes);
|
||||
};
|
||||
} else {
|
||||
sponsorDataFound = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue