mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-01 22:29:20 +03:00
Fixed sponsor data found check
This commit is contained in:
21
content.js
21
content.js
@@ -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,8 +15,11 @@ 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
|
||||||
sponsorsLookup(request.id);
|
if (request.message === 'ytvideoid') {
|
||||||
|
//reset sponsor data found check
|
||||||
|
sponsorDataFound = false;
|
||||||
|
sponsorsLookup(request.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//messages from popup script
|
//messages from popup script
|
||||||
@@ -44,12 +49,14 @@ function sponsorsLookup(id) {
|
|||||||
|
|
||||||
xmlhttp.onreadystatechange = function () {
|
xmlhttp.onreadystatechange = function () {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
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"
|
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
|
||||||
v.ontimeupdate = function () {
|
|
||||||
sponsorCheck(sponsorTimes);
|
// If the sponsor data exists, add the event to run on the videos "ontimeupdate"
|
||||||
};
|
v.ontimeupdate = function () {
|
||||||
|
sponsorCheck(sponsorTimes);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user