mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 22:17:21 +03:00
Made it keep checking for submitted sponsor times every 10 seconds on recent videos.
This commit is contained in:
@@ -29,4 +29,6 @@ None at the moment
|
|||||||
|
|
||||||
# Credit
|
# Credit
|
||||||
|
|
||||||
|
The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) is used to grab the time the video was published.
|
||||||
|
|
||||||
Some i made by <a href="https://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> and are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
|
Some i made by <a href="https://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> and are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
|
||||||
34
content.js
34
content.js
@@ -131,8 +131,21 @@ function sponsorsLookup(id) {
|
|||||||
v.ontimeupdate = function () {
|
v.ontimeupdate = function () {
|
||||||
sponsorCheck(sponsorTimes);
|
sponsorCheck(sponsorTimes);
|
||||||
};
|
};
|
||||||
} else {
|
} else if (xmlhttp.readyState == 4) {
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
|
|
||||||
|
//check if this video was uploaded recently
|
||||||
|
//use the invidious api to get the time published
|
||||||
|
sendRequestToCustomServer('GET', "https://invidio.us/api/v1/videos/" + id, function(xmlhttp, error) {
|
||||||
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
|
let unixTimePublished = JSON.parse(xmlhttp.responseText).published;
|
||||||
|
|
||||||
|
//if less than 3 days old
|
||||||
|
if ((Date.now() / 1000) - unixTimePublished < 259200) {
|
||||||
|
setTimeout(() => sponsorsLookup(id), 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -551,6 +564,25 @@ function sendRequestToServer(type, address, callback) {
|
|||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendRequestToCustomServer(type, fullAddress, callback) {
|
||||||
|
let xmlhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xmlhttp.open(type, fullAddress, true);
|
||||||
|
|
||||||
|
if (callback != undefined) {
|
||||||
|
xmlhttp.onreadystatechange = function () {
|
||||||
|
callback(xmlhttp, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
xmlhttp.onerror = function(ev) {
|
||||||
|
callback(xmlhttp, true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//submit this request
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
function getYouTubeVideoID(url) { // Returns with video id else returns false
|
function getYouTubeVideoID(url) { // Returns with video id else returns false
|
||||||
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
||||||
var match = url.match(regExp);
|
var match = url.match(regExp);
|
||||||
|
|||||||
Reference in New Issue
Block a user