Fixed sponsor data found check

This commit is contained in:
Ajay Ramachandran
2019-07-09 17:03:44 -04:00
parent 7baff32b55
commit 9b370af340

View File

@@ -1,4 +1,6 @@
if(id = getYouTubeVideoID(document.URL)){ // Direct Links if(id = getYouTubeVideoID(document.URL)){ // Direct Links
//reset sponsor data found check
sponsorDataFound = false;
sponsorsLookup(id); sponsorsLookup(id);
} }
@@ -13,7 +15,10 @@ var lastTime;
chrome.runtime.onMessage.addListener( // Detect URL Changes chrome.runtime.onMessage.addListener( // Detect URL Changes
function(request, sender, sendResponse) { function(request, sender, sendResponse) {
if (request.message === 'ytvideoid') { // Message from background script //message from background script
if (request.message === 'ytvideoid') {
//reset sponsor data found check
sponsorDataFound = false;
sponsorsLookup(request.id); sponsorsLookup(request.id);
} }
@@ -44,6 +49,8 @@ function sponsorsLookup(id) {
xmlhttp.onreadystatechange = function () { xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
sponsorDataFound = true;
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes; sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
// If the sponsor data exists, add the event to run on the videos "ontimeupdate" // If the sponsor data exists, add the event to run on the videos "ontimeupdate"