Merge pull request #109 from ajayyy/experimental-ajay

Fixed preview bar
This commit is contained in:
Ajay Ramachandran
2019-08-13 13:05:52 -04:00
committed by GitHub
2 changed files with 22 additions and 3 deletions

View File

@@ -16,6 +16,8 @@ var youtubeVideoStartTime = null;
//the video
var v;
var listenerAdded;
//the channel this video is about
var channelURL;
@@ -241,6 +243,9 @@ function videoIDChange(id) {
sponsorVideoID = id;
sponsorLookupRetries = 0;
//empty the preview bar
previewBar.set([], [], 0);
//see if there is a video start time
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
@@ -320,7 +325,14 @@ function sponsorsLookup(id) {
//update the preview bar
//leave the type blank for now until categories are added
previewBar.set(sponsorTimes, [], v.duration);
console.log(v.duration)
if (isNaN(v.duration)) {
//wait until it is loaded
v.addEventListener('durationchange', updatePreviewBar);
} else {
//set it now
updatePreviewBar();
}
getChannelID();
@@ -342,7 +354,7 @@ function sponsorsLookup(id) {
});
sponsorLookupRetries = 0;
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 15) {
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90) {
//some error occurred, try again in a second
setTimeout(() => sponsorsLookup(id), 1000);
@@ -356,6 +368,13 @@ function sponsorsLookup(id) {
};
}
function updatePreviewBar() {
previewBar.set(sponsorTimes, [], v.duration);
//the listener is only needed once
v.removeEventListener('durationchange', updatePreviewBar);
}
function getChannelID() {
//get channel id
let channelContainers = document.querySelectorAll("#owner-name");

View File

@@ -1,7 +1,7 @@
{
"name": "SponsorBlock for YouTube - Skip Sponsorships",
"short_name": "SponsorBlock",
"version": "1.0.34",
"version": "1.0.35",
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
"content_scripts": [
{