mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 03:57:09 +03:00
Forced auto skip if previewing sponsor.
Resolves https://github.com/ajayyy/SponsorBlock/issues/222
This commit is contained in:
@@ -49,6 +49,10 @@ var channelWhitelisted = false;
|
|||||||
// create preview bar
|
// create preview bar
|
||||||
var previewBar = null;
|
var previewBar = null;
|
||||||
|
|
||||||
|
// When not null, a sponsor is currently being previewed and auto skip should be enabled.
|
||||||
|
// This is set to a timeout function when that happens that will reset it after 3 seconds.
|
||||||
|
var previewResetter: NodeJS.Timeout = null;
|
||||||
|
|
||||||
//the player controls on the YouTube player
|
//the player controls on the YouTube player
|
||||||
var controls = null;
|
var controls = null;
|
||||||
|
|
||||||
@@ -144,6 +148,13 @@ function messageListener(request: any, sender: any, sendResponse: (response: any
|
|||||||
video.play();
|
video.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start preview resetter
|
||||||
|
if (previewResetter !== null){
|
||||||
|
clearTimeout(previewResetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
previewResetter = setTimeout(() => previewResetter = null, 4000);
|
||||||
|
|
||||||
return
|
return
|
||||||
case "getCurrentTime":
|
case "getCurrentTime":
|
||||||
sendResponse({
|
sendResponse({
|
||||||
@@ -658,7 +669,7 @@ function checkIfTimeToSkip(currentVideoTime, startTime, endTime) {
|
|||||||
|
|
||||||
//skip fromt he start time to the end time for a certain index sponsor time
|
//skip fromt he start time to the end time for a certain index sponsor time
|
||||||
function skipToTime(v, index, sponsorTimes, openNotice) {
|
function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||||
if (!Config.config.disableAutoSkip) {
|
if (!Config.config.disableAutoSkip || previewResetter !== null) {
|
||||||
v.currentTime = sponsorTimes[index][1];
|
v.currentTime = sponsorTimes[index][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user