mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 03:57:09 +03:00
Merge pull request #293 from ajayyy/experimental
Fixed double sponsor skip for zero second sponsors
This commit is contained in:
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -10,6 +10,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Build Artifacts
|
# Build Artifacts
|
||||||
|
- uses: actions/checkout@v1
|
||||||
- name: Build Artifacts
|
- name: Build Artifacts
|
||||||
uses: ./.github/workflows/ci.yml
|
uses: ./.github/workflows/ci.yml
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "__MSG_Name__",
|
"short_name": "__MSG_Name__",
|
||||||
"version": "1.2.17",
|
"version": "1.2.18",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ var lastPreviewBarUpdate;
|
|||||||
//whether the duration listener listening for the duration changes of the video has been setup yet
|
//whether the duration listener listening for the duration changes of the video has been setup yet
|
||||||
var durationListenerSetUp = false;
|
var durationListenerSetUp = false;
|
||||||
|
|
||||||
// Has a zero second sponsor been skipped yet
|
// Is the video currently being switched
|
||||||
var skippedZeroSecond = false;
|
var switchingVideos = false;
|
||||||
|
|
||||||
//the channel this video is about
|
//the channel this video is about
|
||||||
var channelURL;
|
var channelURL;
|
||||||
@@ -250,8 +250,6 @@ function resetValues() {
|
|||||||
|
|
||||||
//reset sponsor data found check
|
//reset sponsor data found check
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
|
|
||||||
skippedZeroSecond = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function videoIDChange(id) {
|
async function videoIDChange(id) {
|
||||||
@@ -266,6 +264,8 @@ async function videoIDChange(id) {
|
|||||||
//id is not valid
|
//id is not valid
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
|
||||||
|
switchingVideos = true;
|
||||||
|
|
||||||
// Wait for options to be ready
|
// Wait for options to be ready
|
||||||
await utils.wait(() => Config.config !== null, 5000, 1);
|
await utils.wait(() => Config.config !== null, 5000, 1);
|
||||||
|
|
||||||
@@ -460,8 +460,6 @@ function startSponsorSchedule(currentTime?: number): void {
|
|||||||
|
|
||||||
let skippingFunction = () => {
|
let skippingFunction = () => {
|
||||||
if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) {
|
if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) {
|
||||||
if (currentTime == 0) skippedZeroSecond = true;
|
|
||||||
|
|
||||||
skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice);
|
skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,8 +491,13 @@ function sponsorsLookup(id: string, channelIDPromise?) {
|
|||||||
if (!seekListenerSetUp && !Config.config.disableSkipping) {
|
if (!seekListenerSetUp && !Config.config.disableSkipping) {
|
||||||
seekListenerSetUp = true;
|
seekListenerSetUp = true;
|
||||||
|
|
||||||
video.addEventListener('seeked', () => startSponsorSchedule());
|
video.addEventListener('play', () => {
|
||||||
video.addEventListener('play', () => startSponsorSchedule());
|
switchingVideos = false;
|
||||||
|
startSponsorSchedule();
|
||||||
|
});
|
||||||
|
video.addEventListener('seeked', () => {
|
||||||
|
if (!video.paused) startSponsorSchedule();
|
||||||
|
});
|
||||||
video.addEventListener('ratechange', () => startSponsorSchedule());
|
video.addEventListener('ratechange', () => startSponsorSchedule());
|
||||||
video.addEventListener('seeking', cancelSponsorSchedule);
|
video.addEventListener('seeking', cancelSponsorSchedule);
|
||||||
video.addEventListener('pause', cancelSponsorSchedule);
|
video.addEventListener('pause', cancelSponsorSchedule);
|
||||||
@@ -569,11 +572,13 @@ function sponsorsLookup(id: string, channelIDPromise?) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zeroSecondSponsor && !skippedZeroSecond) {
|
if (!video.paused && !switchingVideos) {
|
||||||
|
if (zeroSecondSponsor) {
|
||||||
startSponsorSchedule(0);
|
startSponsorSchedule(0);
|
||||||
} else {
|
} else {
|
||||||
startSponsorSchedule();
|
startSponsorSchedule();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reset skip save
|
// Reset skip save
|
||||||
sponsorSkipped = [];
|
sponsorSkipped = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user